esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
291 stars 34 forks source link

ESPHome Sprinkler Controller, activating Main switch when no valves enabled causes valves to enable (unexpected behavior) #5892

Open staffy opened 3 weeks ago

staffy commented 3 weeks ago

The problem

As stated in title, when no valves/zones are enabled (presumably because the user does not want them to activate for some reason) and the main switch is activated (which could be caused by for example an automation running once per day or so), then all valves are enabled and a full irrigation cycle is run, which is unexpected. If one or more valves are enabled, then only these valves are activated as expected.

The expected behavior with no valves enabled would be to immediately finish the cycle with no valves activated and no configuration changes.

Which version of ESPHome has the issue?

2024.5.4

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

No response

What platform are you using?

ESP32

Board

4 relay board

Component causing the issue

Sprinkler

Example YAML snippet

switch:
  - platform: gpio
    pin: GPIO32
    id: valve_1
    internal: true
  - platform: gpio
    pin: GPIO33
    id: valve_2
    internal: true
#  - platform: gpio
#    pin: GPIO25
#    id: valve_3
#    internal: true
#  - platform: gpio
#    pin: GPIO26
#    id: valve_4
#    internal: true

sprinkler:
  - id: sprinkler_controller
    main_switch: "Bevattning Huvudswitch"
    auto_advance_switch: "Bevattning Auto Advance"
    valve_overlap: 1s
    valves:
      - valve_switch: "Bevattning Hörnet"
        enable_switch: "Bevattning Hörnet aktiv"
        run_duration_number:
          name: "Hörnet Körtid"
          unit_of_measurement: min
          initial_value: 10
        valve_switch_id: valve_1

      - valve_switch: "Bevattning Altan"
        enable_switch: "Bevattning Altan aktiv"
        run_duration_number:
          name: "Altan Körtid"
          unit_of_measurement: min
          initial_value: 10
        valve_switch_id: valve_2

Anything in the logs that might be useful for us?

[20:50:54][I][app:100]: ESPHome version 2024.5.4 compiled on Jun  9 2024, 20:17:35
[20:50:54][I][app:102]: Project esphome.web version 1.0
[20:50:54][C][status_led:019]: Status LED:
[20:50:54][C][status_led:020]:   Pin: GPIO23
[20:50:54][C][wifi:580]: WiFi:
[20:50:54][C][wifi:408]:   Local MAC: xxx
[20:50:54][C][wifi:413]:   SSID: [redacted]
[20:50:54][C][wifi:416]:   IP Address: xxx
[20:50:54][C][wifi:420]:   BSSID: [redacted]
[20:50:54][C][wifi:421]:   Hostname: 'esphome-web-ff737c'
[20:50:54][C][wifi:423]:   Signal strength: -74 dB ▂▄▆█
[20:50:54][C][wifi:427]:   Channel: 11
[20:50:54][C][wifi:428]:   Subnet: 255.255.255.0
[20:50:54][C][wifi:429]:   Gateway: 192.168.1.1
[20:50:54][C][wifi:430]:   DNS1: 192.168.1.1
[20:50:54][C][wifi:431]:   DNS2: 0.0.0.0
[20:51:00][C][sprinkler:068]: Sprinkler Switch 'Bevattning Hörnet'
[20:51:03][D][switch:016]: 'Bevattning Hörnet aktiv' Turning OFF.
[20:51:03][D][switch:055]: 'Bevattning Hörnet aktiv': Sending state OFF
[20:51:04][D][switch:016]: 'Bevattning Altan aktiv' Turning OFF.
[20:51:04][D][switch:055]: 'Bevattning Altan aktiv': Sending state OFF
[20:51:09][D][esp32.preferences:114]: Saving 2 preferences to flash...
[20:51:09][D][esp32.preferences:143]: Saving 2 preferences to flash: 0 cached, 2 written, 0 failed
[20:51:16][D][sensor:094]: 'WiFi RSSI': Sending state -75.00000 dBm with 0 decimals of accuracy
[20:51:24][D][switch:012]: 'Bevattning Huvudswitch' Turning ON.
[20:51:24][D][switch:012]: 'Bevattning Auto Advance' Turning ON.
[20:51:24][D][switch:055]: 'Bevattning Auto Advance': Sending state ON
[20:51:24][D][switch:012]: 'Bevattning Hörnet aktiv' Turning ON.
[20:51:24][D][switch:055]: 'Bevattning Hörnet aktiv': Sending state ON
[20:51:24][D][switch:012]: 'Bevattning Altan aktiv' Turning ON.
[20:51:24][D][switch:055]: 'Bevattning Altan aktiv': Sending state ON
[20:51:24][D][sprinkler:1427]: CYCLE is starting valve 0 for 60 seconds, cycle 1 of 1
[20:51:24][D][switch:012]: 'valve_1' Turning ON.
[20:51:24][D][switch:055]: 'valve_1': Sending state ON
[20:51:24][D][switch:055]: 'Bevattning Huvudswitch': Sending state ON
[20:51:24][W][component:237]: Component api took a long time for an operation (65 ms).
[20:51:24][W][component:238]: Components should block for at most 30 ms.
[20:51:24][D][switch:055]: 'Bevattning Hörnet': Sending state ON
[20:52:09][D][esp32.preferences:114]: Saving 3 preferences to flash...
[20:52:09][D][esp32.preferences:143]: Saving 3 preferences to flash: 0 cached, 3 written, 0 failed
[20:52:16][D][sensor:094]: 'WiFi RSSI': Sending state -73.00000 dBm with 0 decimals of accuracy
[20:52:23][D][sprinkler:1296]: Marking valve 0 complete
[20:52:23][D][sprinkler:1427]: CYCLE is starting valve 1 for 60 seconds, cycle 1 of 1
[20:52:23][D][switch:012]: 'valve_2' Turning ON.
[20:52:23][D][switch:055]: 'valve_2': Sending state ON
[20:52:23][D][switch:055]: 'Bevattning Altan': Sending state ON
[20:52:24][D][switch:016]: 'valve_1' Turning OFF.
[20:52:24][D][switch:055]: 'valve_1': Sending state OFF
[20:52:24][D][switch:055]: 'Bevattning Hörnet': Sending state OFF
[20:53:16][D][sensor:094]: 'WiFi RSSI': Sending state -74.00000 dBm with 0 decimals of accuracy
[20:53:22][D][sprinkler:1296]: Marking valve 1 complete
[20:53:23][D][switch:016]: 'valve_2' Turning OFF.
[20:53:23][D][switch:055]: 'valve_2': Sending state OFF
[20:53:23][D][switch:055]: 'Bevattning Altan': Sending state OFF
[20:53:24][D][sprinkler:1449]: All valves stopped, including pumps
[20:53:24][D][switch:055]: 'Bevattning Huvudswitch': Sending state OFF
[20:54:16][D][sensor:094]: 'WiFi RSSI': Sending state -72.00000 dBm with 0 decimals of accuracy
[20:55:16][D][sensor:094]: 'WiFi RSSI': Sending state -75.00000 dBm with 0 decimals of accuracy

Additional information

No response

kbx81 commented 3 weeks ago

This is not unexpected behavior as it is clearly stated in the documentation.

staffy commented 3 weeks ago

Very clearly stated, thanks for pointing that out! But it still seems strange to me, I cannot see a reason why anyone would want that behavior?

kbx81 commented 3 weeks ago

Consider this situation:

No zones are enabled. A user wishes to run a cycle of the system. The user walks up to the hardware and presses a button to start the system. Nothing happens. User is confused and assumes something is broken. (Chaos ensues...)

Note that this scenario plays out exactly the same way if you're using a switch or button on a dashboard to activate the system.

Part of the motivation for the behavior was to minimize situations where the controller just does nothing. It's not obvious why the controller won't start unless you happen to be watching the device's logs as you're interacting with it. This behavior is quite confusing to an end-user who just wants to switch on their sprinklers (and who knows nothing about how to troubleshoot hardware...or at least isn't thinking about it at the time).

I understand what you're trying to do, but--trust me--if it worked the way you're suggesting/expecting, you will end up wasting a bunch of time one day by confusing yourself. Ask me how I know. 😅 You will spend a lot less time tweaking your automation to cope with this behavior than you will waste trying to figure out why your controller won't turn on when you try to use it one day and forget that no zones are enabled. 😇