Skip to content

Add optional open_service/close_service per zone - #248

Open
matteobreschig wants to merge 1 commit into
rgc99:masterfrom
matteobreschig:master
Open

Add optional open_service/close_service per zone#248
matteobreschig wants to merge 1 commit into
rgc99:masterfrom
matteobreschig:master

Conversation

@matteobreschig

Copy link
Copy Markdown

Summary

Adds two optional pairs of zone-level config parameters: open_service/open_data and close_service/close_data. When set, IU calls the specified service instead of the default valve.open_valve/close_valve (or switch.turn_on/turn_off) when opening/closing that zone.

An open_data payload can use the {{ duration_minutes }} template variable, which is replaced with the zone's calculated run time in minutes (rounded to the nearest minute).

Motivation

See #[numero issue]. Some controllers (e.g. Orbit B-Hyve) expose valves as standard HA valve entities but ignore valve.open_valve — they require a proprietary service call with an explicit duration (bhyve.start_watering / bhyve.stop_watering) to work correctly. Without a duration, B-Hyve falls back to a hardware-configured default runtime.

entity_states: 'off' + an external automation is a working alternative for this (confirmed in the issue), but requires one automation (or one trigger block per zone) outside of IU to make the proprietary call. This PR moves that logic into the zone config itself, so a controller's proprietary integration lives next to the rest of its definition.

Example

zones:
  - zone_id: "1"
    name: "Zone 1"
    entity_id: valve.bhyve_zone_1
    open_service: bhyve.start_watering
    open_data:
      entity_id: valve.bhyve_zone_1
      minutes: "{{ duration_minutes }}"
    close_service: bhyve.stop_watering
    close_data:
      entity_id: valve.bhyve_zone_1

Backwards compatibility

Fully backwards compatible — if open_service/close_service are not set, behavior is unchanged (falls back to the existing valve/switch/cover logic).

Testing

  • Added test_switch_open_close_service to tests/test_switch.py, covering both the custom service path and the fallback to default behavior when unset.
  • Running in production on a real 8-zone B-Hyve garden controller + 1-zone balcony controller for about 2 weeks, in combination with Smart Irrigation for duration calculation and a check_back delay tuned for B-Hyve's cloud polling latency. No issues since it's been running.

Happy to adjust naming, scope, or drop config validation strictness based on feedback.

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.

1 participant