Skip to content

feat(cli): add set command group for equipment control#146

Open
tonyfruzza wants to merge 2 commits into
cryptk:mainfrom
tonyfruzza:feat/cli-set-commands
Open

feat(cli): add set command group for equipment control#146
tonyfruzza wants to merge 2 commits into
cryptk:mainfrom
tonyfruzza:feat/cli-set-commands

Conversation

@tonyfruzza
Copy link
Copy Markdown

Summary

Adds a new set command group to the CLI exposing equipment control operations that were previously only available through the Python library API.

Closes #145

New CLI commands

# Set heater target temperature (Fahrenheit)
omnilogic --host 192.168.1.100 set heater-temp 4 82

# Set solar heater set-point
omnilogic --host 192.168.1.100 set solar-temp 4 90

# Set pump/filter speed (0-100%)
omnilogic --host 192.168.1.100 set speed 3 75

# Turn equipment on/off (works with any controllable equipment)
omnilogic --host 192.168.1.100 set on 5
omnilogic --host 192.168.1.100 set off 5

Motivation

The library has comprehensive control methods (heater.set_temperature(), pump.set_speed(), light.turn_on(), etc.) but the CLI only exposed read-only operations via get and debug. This made it impossible to control equipment from shell scripts, cron jobs, or lightweight HTTP wrappers without writing Python.

Implementation

  • New pyomnilogic_local/cli/set/ module following the same pattern as cli/get/
  • Uses the existing OmniLogic instance from Click context (already initialized by entrypoint)
  • Equipment lookup uses all_heaters.get_by_id(), all_pumps.get_by_id(), all_filters.get_by_id(), and get_equipment_by_id() for generic on/off
  • Each command validates equipment exists and supports the requested operation before calling it
  • Follows existing code style: Click decorators, asyncio.run() for async calls, mypy error suppression for Click decorators

Files changed

File Change
cli/cli.py Import and register set command group
cli/set/__init__.py Package init
cli/set/commands.py Click group definition, registers subcommands
cli/set/heater_temp.py heater-temp and solar-temp commands
cli/set/speed.py speed command for pumps/filters
cli/set/equipment.py Generic on/off commands

Testing

I have been testing these control operations against a live Hayward OmniLogic controller (firmware 5.1.85) via an HTTP wrapper that uses the same library methods. Temperature set-points, pump speed, and on/off all confirmed working.

Note: I do not have the test harness set up locally (missing pydantic/dev dependencies) so I have not run the existing test suite. Happy to add unit tests if desired — would follow the mock-based pattern in tests/.

@cryptk
Copy link
Copy Markdown
Owner

cryptk commented May 28, 2026

The library was very recently refactored and the CLI just hasn't gotten the same level of love yet. I think I kind of want to invert the way the CLI works, so it would be something like this:

  • omnilogic heater ## get (returns all data about the heater with ID ##)
  • omnilogic heater ## turn_on (calls the turn_on control method for the heater)
  • omnilogic heater ## turn_off (calls the turn_off control method for the heater)

There would be a similar heater subcommand for every heater control_method. This way the CLI structure mirrors the new library layout.

Add a new 'set' command group to the CLI that exposes equipment control
operations that were previously only available through the Python API:

- set heater-temp <system_id> <temperature> — Set heater target temp (°F)
- set solar-temp <system_id> <temperature> — Set solar heater target (°F)
- set speed <system_id> <percent> — Set pump/filter speed (0-100%)
- set on <system_id> — Turn equipment on
- set off <system_id> — Turn equipment off

This allows scripting and automation of pool control without writing
Python code, complementing the existing read-only 'get' and 'debug'
command groups.

Resolves cryptk#145
Address reviewer feedback to mirror the library layout in the CLI.

Instead of a flat 'set' command group:
  omnilogic set on 5
  omnilogic set heater-temp 4 82
  omnilogic set speed 3 75

The CLI now uses equipment-type subcommands with control methods:
  omnilogic heater 4              (show heater info)
  omnilogic heater 4 turn_on
  omnilogic heater 4 set_temperature 82
  omnilogic pump 3 set_speed 75
  omnilogic filter 3 turn_off
  omnilogic relay 6 turn_on
  omnilogic light 5 turn_off

Each equipment type is a Click group that:
- Takes a system_id argument
- Shows all properties when called without a subcommand
- Exposes control methods as subcommands matching the library API

Equipment commands added: heater, pump, filter, relay, light
@tonyfruzza tonyfruzza force-pushed the feat/cli-set-commands branch from df9dae6 to 67a217e Compare May 29, 2026 15:43
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(cli): Add control commands (set temperature, on/off, speed)

2 participants