rgc99 / irrigation_unlimited

β™’Irrigation controller for Home Assistant
MIT License
324 stars 47 forks source link

Orbit B-hyve zones run for 5 minutes maximum regardless of time set #180

Open sisaacrussell opened 2 weeks ago

sisaacrussell commented 2 weeks ago

Version of the custom_component

2024.8.0

Configuration

logger:
  default: info
  logs:
    custom_components.irrigation_unlimited: debug
    custom_components.bhyve: debug

irrigation_unlimited:
  controllers:
    - name: "b-hyve"
      all_zones_config:
        check_back:
          states: "all"
      zones:
        - name: "πŸ’¦ Z1: FYd N Drive"
          entity_id: switch.bhyve_c1_z1
        - name: "πŸ’¦ Z2: FYd Street"
          entity_id: switch.bhyve_c2_z1
        - name: "πŸ’¦ Z3: FYd Utility"
          entity_id: switch.bhyve_c2_z3
        - name: "πŸ’¦ Z4: FYd N Walk"
          entity_id: switch.bhyve_c1_z2
        - name: "πŸ’¦ Z5: FYd Steps"
          entity_id: switch.bhyve_c2_z2
        - name: "πŸ’¦ Z6: SYd East"
          entity_id: switch.bhyve_c2_z4
        - name: "πŸ’¦ Z7: SYd West"
          entity_id: switch.bhyve_c1_z3
      sequences:
        - name: "Daily Sequences"
          delay: "-00:00:15"
          schedules:
            - name: "Pre-Sunrise"
              time:
                sun: "sunrise"
                before: "01:30"
            - name: "Pre-Sunset"
              time:
                sun: "sunset"
                before: "01:30"
          zones:
            - zone_id: 1
              duration: "00:10"
            - zone_id: 2
              duration: "00:10"
            - zone_id: 3
              duration: "00:10"
            - zone_id: 4
              duration: "00:10"
            - zone_id: 5
              duration: "00:15"
            - zone_id: 6
              duration: "00:20"
            - zone_id: 7
              duration: "00:15"

Describe the bug

When running a sequence, Irrigation Unlimited will turn on the zone switch, but doesn't set a run time with the bhyve service. This then defaults to the switch's manual_preset_runtime which is 300s by default. This, in effect, limits Irrigation Unlimited from running any zone longer than 5 minutes. The correct way, to call the bhyve zones is using the start_watering services as below. This will start a manual run with the minutes specified instead of the default 300s. Any ideas on how to get Irrigation Unlimited to play nicely with this type of switch setup?

action: bhyve.start_watering
data:
  entity_id: switch.bhyve_c2_z1
  minutes: 30

Debug log

irrigation_unlimited Logs:

2024-08-26 19:22:12.264 INFO (MainThread) [homeassistant.setup] Setting up irrigation_unlimited
2024-08-26 19:22:12.264 INFO (MainThread) [custom_components.irrigation_unlimited]
https://github.com/rgc99/irrigation_unlimited/issues
2024-08-26 19:22:12.265 DEBUG (MainThread) [custom_components.irrigation_unlimited] LOAD
2024-08-26 19:22:12.265 DEBUG (MainThread) [custom_components.irrigation_unlimited] REGISTER [2024-08-26 19:22:12] controller: 0, zone: 0, sequence: 0, entity: irrigation_unlimited.coordinator
2024-08-26 19:22:12.265 DEBUG (MainThread) [custom_components.irrigation_unlimited] CALL [2024-08-26 19:22:12] service: enable, controller: 1, zone: 0, sequence: 0, data: {}
2024-08-26 19:22:12.265 DEBUG (MainThread) [custom_components.irrigation_unlimited] CALL [2024-08-26 19:22:12] service: suspend, controller: 1, zone: 0, sequence: 0, data: {"reset": null}
2024-08-26 19:22:12.265 DEBUG (MainThread) [custom_components.irrigation_unlimited] CALL [2024-08-26 19:22:12] service: enable, controller: 1, zone: 0, sequence: 0, data: {"sequence_id": 1}
2024-08-26 19:22:12.265 DEBUG (MainThread) [custom_components.irrigation_unlimited] CALL [2024-08-26 19:22:12] service: suspend, controller: 1, zone: 0, sequence: 0, data: {"reset": null, "sequence_id": 1}
2024-08-26 19:22:12.269 INFO (MainThread) [custom_components.irrigation_unlimited] CALL [2024-08-26 19:22:12] service: adjust_time, controller: 1, zone: 0, sequence: 0, data: {"increase": "0:00:00", "sequence_id": 1}
2024-08-26 19:22:12.269 DEBUG (MainThread) [custom_components.irrigation_unlimited] CALL [2024-08-26 19:22:12] service: enable, controller: 1, zone: 0, sequence: 0, data: {"sequence_id": 1, "zones": [1]}
2024-08-26 19:22:12.269 DEBUG (MainThread) [custom_components.irrigation_unlimited] CALL [2024-08-26 19:22:12] service: suspend, controller: 1, zone: 0, sequence: 0, data: {"reset": null, "sequence_id": 1, "zones": [1]}
2024-08-26 19:22:12.269 DEBUG (MainThread) [custom_components.irrigation_unlimited] CALL [2024-08-26 19:22:12] service: adjust_time, controller: 1, zone: 0, sequence: 0, data: {"reset": null, "sequence_id": 1, "zones": [1]}
2024-08-26 19:22:12.269 WARNING (MainThread) [custom_components.irrigation_unlimited] RESTORE Invalid data: msg: TypeError("'NoneType' object is not iterable"), data: {"version": "1.0.1", "controllers": [{"index": 0, "name": "b-hyve", "enabled": true, "suspended": null, "zones": [{"index": 0, "name": "\ud83d\udca6 Z1: FYd N Drive", "state": "on", "enabled": true, "suspended": null, "adjustment": ""}, {"index": 1, "name": "\ud83d\udca6 Z2: FYd Street", "state": "off", "enabled": true, "suspended": null, "adjustment": ""}, {"index": 2, "name": "\ud83d\udca6 Z3: FYd Utility", "state": "off", "enabled": true, "suspended": null, "adjustment": ""}, {"index": 3, "name": "\ud83d\udca6 Z4: FYd N Walk", "state": "off", "enabled": true, "suspended": null, "adjustment": ""}, {"index": 4, "name": "\ud83d\udca6 Z5: FYd Steps", "state": "off", "enabled": true, "suspended": null, "adjustment": ""}, {"index": 5, "name": "\ud83d\udca6 Z6: SYd East", "state": "off", "enabled": true, "suspended": null, "adjustment": ""}, {"index": 6, "name": "\ud83d\udca6 Z7: SYd West", "state": "off", "enabled": true, "suspended": null, "adjustment": ""}], "sequences": [{"index": 0, "name": "Daily Sequences", "state": "on", "enabled": true, "suspended": null, "adjustment": "+0:00:00", "sequence_zones": [{"index": 0, "state": "on", "enabled": true, "suspended": null, "adjustment": ""}, {"index": 1, "state": "off", "enabled": true, "suspended": null, "adjustment": ""}, {"index": 2, "state": "off", "enabled": true, "suspended": null, "adjustment": ""}, {"index": 3, "state": "off", "enabled": true, "suspended": null, "adjustment": ""}, {"index": 4, "state": "off", "enabled": true, "suspended": null, "adjustment": ""}, {"index": 5, "state": "off", "enabled": true, "suspended": null, "adjustment": ""}, {"index": 6, "state": "off", "enabled": true, "suspended": null, "adjustment": ""}]}], "state": "on"}]}
2024-08-26 19:22:12.270 DEBUG (MainThread) [custom_components.irrigation_unlimited] START [2024-08-26 19:22:12]
2024-08-26 19:22:12.270 INFO (MainThread) [homeassistant.setup] Setup of domain irrigation_unlimited took 0.01 seconds
2024-08-26 19:22:17.265 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up irrigation_unlimited.binary_sensor
2024-08-26 19:22:17.265 DEBUG (MainThread) [custom_components.irrigation_unlimited] REGISTER [2024-08-26 19:22:17] controller: 1, zone: 0, sequence: 0, entity: binary_sensor.irrigation_unlimited_c1_m
2024-08-26 19:22:17.265 DEBUG (MainThread) [custom_components.irrigation_unlimited] CALL [2024-08-26 19:22:17] service: enable, controller: 1, zone: 0, sequence: 0, data: {}
2024-08-26 19:22:17.266 DEBUG (MainThread) [custom_components.irrigation_unlimited] REGISTER [2024-08-26 19:22:17] controller: 1, zone: 1, sequence: 0, entity: binary_sensor.irrigation_unlimited_c1_z1
2024-08-26 19:22:17.266 DEBUG (MainThread) [custom_components.irrigation_unlimited] CALL [2024-08-26 19:22:17] service: enable, controller: 1, zone: 1, sequence: 0, data: {}
2024-08-26 19:22:17.266 DEBUG (MainThread) [custom_components.irrigation_unlimited] REGISTER [2024-08-26 19:22:17] controller: 1, zone: 2, sequence: 0, entity: binary_sensor.irrigation_unlimited_c1_z2
2024-08-26 19:22:17.266 DEBUG (MainThread) [custom_components.irrigation_unlimited] CALL [2024-08-26 19:22:17] service: enable, controller: 1, zone: 2, sequence: 0, data: {}
2024-08-26 19:22:17.266 DEBUG (MainThread) [custom_components.irrigation_unlimited] REGISTER [2024-08-26 19:22:17] controller: 1, zone: 3, sequence: 0, entity: binary_sensor.irrigation_unlimited_c1_z3
2024-08-26 19:22:17.266 DEBUG (MainThread) [custom_components.irrigation_unlimited] CALL [2024-08-26 19:22:17] service: enable, controller: 1, zone: 3, sequence: 0, data: {}
2024-08-26 19:22:17.267 DEBUG (MainThread) [custom_components.irrigation_unlimited] REGISTER [2024-08-26 19:22:17] controller: 1, zone: 4, sequence: 0, entity: binary_sensor.irrigation_unlimited_c1_z4
2024-08-26 19:22:17.267 DEBUG (MainThread) [custom_components.irrigation_unlimited] CALL [2024-08-26 19:22:17] service: enable, controller: 1, zone: 4, sequence: 0, data: {}
2024-08-26 19:22:17.267 DEBUG (MainThread) [custom_components.irrigation_unlimited] REGISTER [2024-08-26 19:22:17] controller: 1, zone: 5, sequence: 0, entity: binary_sensor.irrigation_unlimited_c1_z5
2024-08-26 19:22:17.267 DEBUG (MainThread) [custom_components.irrigation_unlimited] CALL [2024-08-26 19:22:17] service: enable, controller: 1, zone: 5, sequence: 0, data: {}
2024-08-26 19:22:17.267 DEBUG (MainThread) [custom_components.irrigation_unlimited] REGISTER [2024-08-26 19:22:17] controller: 1, zone: 6, sequence: 0, entity: binary_sensor.irrigation_unlimited_c1_z6
2024-08-26 19:22:17.267 DEBUG (MainThread) [custom_components.irrigation_unlimited] CALL [2024-08-26 19:22:17] service: enable, controller: 1, zone: 6, sequence: 0, data: {}
2024-08-26 19:22:17.268 DEBUG (MainThread) [custom_components.irrigation_unlimited] REGISTER [2024-08-26 19:22:17] controller: 1, zone: 7, sequence: 0, entity: binary_sensor.irrigation_unlimited_c1_z7
2024-08-26 19:22:17.268 DEBUG (MainThread) [custom_components.irrigation_unlimited] CALL [2024-08-26 19:22:17] service: enable, controller: 1, zone: 7, sequence: 0, data: {}
2024-08-26 19:22:17.268 DEBUG (MainThread) [custom_components.irrigation_unlimited] REGISTER [2024-08-26 19:22:17] controller: 1, zone: 0, sequence: 1, entity: binary_sensor.irrigation_unlimited_c1_s1
2024-08-26 19:22:17.268 DEBUG (MainThread) [custom_components.irrigation_unlimited] CALL [2024-08-26 19:22:17] service: enable, controller: 1, zone: 0, sequence: 0, data: {}
2024-08-26 19:22:52.270 DEBUG (MainThread) [custom_components.irrigation_unlimited] INITIALISED
2024-08-26 19:22:52.270 WARNING (MainThread) [custom_components.irrigation_unlimited] SYNCHRONISATION [2024-08-26 19:22:52] Switch does not match current state: expected: off, found: on, switch: switch.bhyve_c1_z1
2024-08-26 19:24:12.848 INFO (MainThread) [custom_components.irrigation_unlimited] CALL [2024-08-26 19:24:12] service: manual_run, controller: 1, zone: 0, sequence: 1, data: {"entity_id": ["binary_sensor.irrigation_unlimited_c1_s1"], "time": "25 days, 0:00:00"}
2024-08-26 19:24:13.002 INFO (MainThread) [custom_components.irrigation_unlimited] EVENT [2024-08-26 19:24:13] controller: 1, zone: 0, state: 1
2024-08-26 19:24:13.003 INFO (MainThread) [custom_components.irrigation_unlimited] EVENT [2024-08-26 19:24:13] controller: 1, zone: 1, state: 1, data: 1.0.1.1.1

bhyve Logs:

2024-08-26 19:22:11.787 INFO (MainThread) [homeassistant.setup] Setting up bhyve
2024-08-26 19:22:11.787 INFO (MainThread) [homeassistant.setup] Setup of domain bhyve took 0.00 seconds
2024-08-26 19:22:12.544 DEBUG (MainThread) [custom_components.bhyve.pybhyve.client] Logged in
2024-08-26 19:22:13.118 INFO (MainThread) [custom_components.bhyve.pybhyve.websocket] Authenticating websocket
2024-08-26 19:22:13.119 INFO (MainThread) [custom_components.bhyve.pybhyve.websocket] Websocket connected
2024-08-26 19:22:17.925 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up bhyve.binary_sensor
2024-08-26 19:22:17.925 INFO (MainThread) [homeassistant.components.sensor] Setting up bhyve.sensor
2024-08-26 19:22:17.925 INFO (MainThread) [custom_components.bhyve.sensor] Creating state sensor: Garage Hose Tap state
2024-08-26 19:22:17.925 DEBUG (MainThread) [custom_components.bhyve.sensor] State sensor Garage Hose Tap state setup: State: off | Available: True
2024-08-26 19:22:17.925 INFO (MainThread) [custom_components.bhyve.sensor] Creating history sensor: Front Yard - Driveway North zone history
2024-08-26 19:22:17.925 INFO (MainThread) [custom_components.bhyve.sensor] Creating history sensor: Front Yard - Sidewalk North zone history
2024-08-26 19:22:17.925 INFO (MainThread) [custom_components.bhyve.sensor] Creating history sensor: Side Yard West zone history
2024-08-26 19:22:17.925 INFO (MainThread) [custom_components.bhyve.sensor] Creating history sensor: Unused zone history
2024-08-26 19:22:17.925 INFO (MainThread) [custom_components.bhyve.sensor] Creating battery sensor: Garage Hose Tap battery level
2024-08-26 19:22:17.925 DEBUG (MainThread) [custom_components.bhyve.sensor] Garage Hose Tap battery: {'percent': 86, 'mv': 2920}
2024-08-26 19:22:17.925 INFO (MainThread) [custom_components.bhyve.sensor] Creating state sensor: Front Porch Hose Tap state
2024-08-26 19:22:17.926 DEBUG (MainThread) [custom_components.bhyve.sensor] State sensor Front Porch Hose Tap state setup: State: auto | Available: True
2024-08-26 19:22:17.926 INFO (MainThread) [custom_components.bhyve.sensor] Creating history sensor: Front Yard - Road North zone history
2024-08-26 19:22:17.926 INFO (MainThread) [custom_components.bhyve.sensor] Creating history sensor: Front Yard - Utility Bed East zone history
2024-08-26 19:22:17.926 INFO (MainThread) [custom_components.bhyve.sensor] Creating history sensor: Front Yard - Sidewalk East zone history
2024-08-26 19:22:17.926 INFO (MainThread) [custom_components.bhyve.sensor] Creating history sensor: Side Yard - East zone history
2024-08-26 19:22:17.926 INFO (MainThread) [custom_components.bhyve.sensor] Creating battery sensor: Front Porch Hose Tap battery level
2024-08-26 19:22:17.926 DEBUG (MainThread) [custom_components.bhyve.sensor] Front Porch Hose Tap battery: {'percent': 100, 'mv': 3000}
2024-08-26 19:22:17.928 INFO (MainThread) [homeassistant.components.switch] Setting up bhyve.switch
2024-08-26 19:22:17.928 INFO (MainThread) [custom_components.bhyve.switch] Creating switch: Garage Hose Tap rain delay
2024-08-26 19:22:17.929 INFO (MainThread) [custom_components.bhyve.switch] Creating switch: Front Yard - Driveway North zone
2024-08-26 19:22:17.929 INFO (MainThread) [custom_components.bhyve.switch] Front Yard - Driveway North zone watering_status: {'program': None, 'current_station': 1, 'started_watering_station_at': '2024-08-26T22:54:40.000Z', 'rain_sensor_hold': False}
2024-08-26 19:22:17.929 INFO (MainThread) [custom_components.bhyve.switch] Creating switch: Front Yard - Sidewalk North zone
2024-08-26 19:22:17.929 INFO (MainThread) [custom_components.bhyve.switch] Front Yard - Sidewalk North zone watering_status: {'program': None, 'current_station': 1, 'started_watering_station_at': '2024-08-26T22:54:40.000Z', 'rain_sensor_hold': False}
2024-08-26 19:22:17.929 INFO (MainThread) [custom_components.bhyve.switch] Creating switch: Side Yard West zone
2024-08-26 19:22:17.929 INFO (MainThread) [custom_components.bhyve.switch] Side Yard West zone watering_status: {'program': None, 'current_station': 1, 'started_watering_station_at': '2024-08-26T22:54:40.000Z', 'rain_sensor_hold': False}
2024-08-26 19:22:17.929 INFO (MainThread) [custom_components.bhyve.switch] Creating switch: Unused zone
2024-08-26 19:22:17.929 INFO (MainThread) [custom_components.bhyve.switch] Unused zone watering_status: {'program': None, 'current_station': 1, 'started_watering_station_at': '2024-08-26T22:54:40.000Z', 'rain_sensor_hold': False}
2024-08-26 19:22:17.929 INFO (MainThread) [custom_components.bhyve.switch] Creating switch: Front Porch Hose Tap rain delay
2024-08-26 19:22:17.929 INFO (MainThread) [custom_components.bhyve.switch] Creating switch: Front Yard - Road North zone
2024-08-26 19:22:17.929 INFO (MainThread) [custom_components.bhyve.switch] Front Yard - Road North zone watering_status: {'clear_on_idle': True}
2024-08-26 19:22:17.929 INFO (MainThread) [custom_components.bhyve.switch] Creating switch: Front Yard - Utility Bed East zone
2024-08-26 19:22:17.929 INFO (MainThread) [custom_components.bhyve.switch] Front Yard - Utility Bed East zone watering_status: {'clear_on_idle': True}
2024-08-26 19:22:17.929 INFO (MainThread) [custom_components.bhyve.switch] Creating switch: Front Yard - Sidewalk East zone
2024-08-26 19:22:17.929 INFO (MainThread) [custom_components.bhyve.switch] Front Yard - Sidewalk East zone watering_status: {'clear_on_idle': True}
2024-08-26 19:22:17.929 INFO (MainThread) [custom_components.bhyve.switch] Creating switch: Side Yard - East zone
2024-08-26 19:22:17.929 INFO (MainThread) [custom_components.bhyve.switch] Side Yard - East zone watering_status: {'clear_on_idle': True}
2024-08-26 19:22:52.270 WARNING (MainThread) [custom_components.irrigation_unlimited] SYNCHRONISATION [2024-08-26 19:22:52] Switch does not match current state: expected: off, found: on, switch: switch.bhyve_c1_z1
2024-08-26 19:22:52.277 INFO (MainThread) [custom_components.bhyve.switch] Starting watering
2024-08-26 19:24:13.009 INFO (MainThread) [custom_components.bhyve.switch] Starting watering
rgc99 commented 2 weeks ago

Use an automation that tracks the zone sensor. Something like the following (this has not been tested!).

automation:
  - alias: 'Zone 1 bhyve'
    description: Turn on bhyve valve
    trigger:
      - platform: state
          entity_id:
            - binary_sensor.irrigation_unlimited_c1_z1
          from: "off"
          to: "on" 
    condition: []
    action:
      - service: |-
        action: bhyve.start_watering
        data:
          entity_id: switch.bhyve_c2_z1
          minutes: "{{ as_timedelta(state_attr('binary_sensor.irrigation_unlimited_c1_z1', 'current_duration')).total_seconds / 60 }}"
    mode: single