esphome / feature-requests

ESPHome Feature Request Tracker
https://esphome.io/
417 stars 26 forks source link

Idea for sprinkler application #1982

Open Hoaarst opened 1 year ago

Hoaarst commented 1 year ago

Describe the problem you have/What new integration you would like Dear Keith, dear all, I am using the sprinkler application which I like very much, good job :) I have just a minor wish for improvement. As far as I could find out the sprinkler application goes one valve after the other. My pump is strong enough to deal with more than one valve at the same time. So, it would be very good if I could group valves to be run as groups one after the other. For sure I could solve this on the hardware side if I put more than one valve on a relais but then I loose the oppotunity to open a single valve. Therefore I prefer a software solution.

Please describe your use case for this integration and alternatives you've tried: I tried several way to group valves but I have not been successful yet. If I was blind, only, please excuse myself. I am not too familiar in programming. Any help will be highly appreciated. Thanks.

Additional context

nagyrobi commented 1 year ago

You could create template switches to act as valve groups:

switch:
  - platform: template
    id: valve_group_1
    internal: true
    turn_on_action:
      - switch.turn_on: valve_01
      - switch.turn_on: valve_02 
    turn_off_action:
      - switch.turn_off: valve_01
      - switch.turn_off: valve_02 

Setting internal: true will not expose the group switch to Home Assistant but sprinkler component could still use by id, eg valve_switch_id: valve_group_1. You could though expose your valve_01, valve_02 switches and act on them manually, but pay attention to the warning. Some additional automations would be required to operate the pump outside sprinkler component, to handle the situation described in the warning.

Hoaarst commented 1 year ago

Hi nagyrobi,

Many thanks for the fast reply and support. I will check it out tomorrow :) Have good night. Kind regards

Hoaarst commented 1 year ago

Hi @nagyrobi,

I just have tried to implement this to my ESP. The switch on of both relais at the same time works fine. Anyhow they do not turn off again. Even after the full sprinkler cycle is finished they stay on. I looked for any typos but I could not find anything. Any ideas why it does not work?

Thank you.

kbx81 commented 1 year ago

I know of one other person that asked about this some time ago -- I'll give approximately the same response. 😄

As it exists now, the sprinkler component is specifically aimed at coordinating valves to ensure that only one is active at a time (within any given controller). Its software architecture directly reflects this. Allowing multiple valves to operate simultaneously would require a massive rearchitecting of the component and also (at least, in my opinion) completely defeats the purpose of the component -- I'm pretty confident right now that most folks who are using it are doing so to mitigate the complexity that's otherwise required to accomplish what it does.

If you wish to arbitrarily activate multiple valves simultaneously, you only need two things:

You'll add an on_turn_on trigger to the switch's config which will script.execute the script above; when the script completes, the switch is turned off. That's it! You really don't need the complexity of the sprinkler component if this is what you want.

szurr commented 1 year ago

Hi I was going to change my switch based controller to sprinkler but if I can't do multiple valve at same time.... That's sucks. I have pump and city water with different pressure so it is very convenient to have option for use couple valve on higher pressure and single for lover. So i suppose it is not a controller for all watering systems

kbx81 commented 1 year ago

I think what I'm trying to understand is...if you want to run multiple valves simultaneously, what value does the sprinkler component add? It is very easy to create a switch that turns off after a variable duration with just switch and script components alone. I could see the argument that it simplifies management of the switches somewhat...but...in light of what I described with the switch + script...barely.

Some other related questions I have about this:

nagyrobi commented 1 year ago

I think what he wants is just group the separate switches he wants to run in parrallel into one virtual switch, so from sprinkler perspective they just look as one zone.

But, when he wants some extra manual watering on the sub-zones, that can done separately.

kbx81 commented 1 year ago

Ah, in that case, yes, you should be able to create a template switch that encompasses both GPIO switches, then use the template switch as an additional "valve" in the sprinkler component configuration. You could still also configure each GPIO switch as an individual valve in the sprinkler component configuration, as well, if you like.

Maybe it would be worthwhile to add an example of this to the docs.

szurr commented 1 year ago

Ah, in that case, yes, you should be able to create a template switch that encompasses both GPIO switches, then use the template switch as an additional "valve" in the sprinkler component configuration. You could still also configure each GPIO switch as an individual valve in the sprinkler component configuration, as well, if you like.

Maybe it would be worthwhile to add an example of this to the docs.

That's what I was thinking about but haven't time to look into docs👍🏼

nagyrobi commented 1 year ago

Maybe it would be worthwhile to add an example of this to the docs.

https://github.com/esphome/feature-requests/issues/1982#issuecomment-1328113755

Hoaarst commented 1 year ago

I think what he wants is just group the separate switches he wants to run in parrallel into one virtual switch, so from sprinkler perspective they just look as one zone.

But, when he wants some extra manual watering on the sub-zones, that can done separately.

Yes, this is exactly what I am looking for. Many thanks at all of you for your support.

Ah, in that case, yes, you should be able to create a template switch that encompasses both GPIO switches, then use the template switch as an additional "valve" in the sprinkler component configuration. You could still also configure each GPIO switch as an individual valve in the sprinkler component configuration, as well, if you like. Maybe it would be worthwhile to add an example of this to the docs.

That's what I was thinking about but haven't time to look into docs👍🏼

That is what nagyrobi has porposed as well, as given at the beginning of this issue. When I was testing it, the template switch was switched on correctly but for any reason did not switch off again...

Hoaarst commented 1 year ago

Update: Please find the code as follows:

sprinkler:
  - id: Sprinkler
    main_switch: "Main switch"
    auto_advance_switch: "Automatic"
    valve_overlap: 1s
    valves:
      - valve_switch: "Relais1"
        enable_switch: "Enable R1"
        run_duration: 3s
        valve_switch_id: Relais1
      - valve_switch: "Relais2"
        enable_switch: "Enable R2"
        run_duration: 3s
        valve_switch_id: Relais2
      - valve_switch: "Relais3"
        enable_switch: "Enable R3"
        run_duration: 3s
        valve_switch_id: Relais3
      - valve_switch: "Relais4"
        enable_switch: "Enable R4"
        run_duration: 3s
        valve_switch_id: Relais4
      - valve_switch: "Zone_1"
        enable_switch: "Enable_Zone_1"
        run_duration: 3s
        valve_switch_id: Zone1
      - valve_switch: "Relais5"
        enable_switch: "Enable R5"
        run_duration: 3s
        valve_switch_id: Relais5
      - valve_switch: "Relais6"
        enable_switch: "Enable R6"
        run_duration: 3s
        valve_switch_id: Relais6
      - valve_switch: "Relais7"
        enable_switch: "Enable R7"
        run_duration: 3s
        valve_switch_id: Relais7
      - valve_switch: "Relais8"
        enable_switch: "Enable R8"
        run_duration: 3s
        valve_switch_id: Relais8

switch:
  - platform: gpio
    id: Relais1
    pin: 16
  - platform: gpio
    id: Relais2
    pin: 14
  - platform: gpio
    id: Relais3
    pin: 12
  - platform: gpio
    id: Relais4
    pin: 13
  - platform: gpio
    id: Relais5
    pin: 15
  - platform: gpio
    id: Relais6
    pin: 0
  - platform: gpio
    id: Relais7
    pin: 4
  - platform: gpio
    id: Relais8
    pin: 5
  - platform: template
    id: Zone1
    turn_on_action:
      - switch.turn_on: Relais1
      - switch.turn_on: Relais2 
    turn_off_action:
      - switch.turn_off: Relais1
      - switch.turn_off: Relais2

Behavoir: If I start the main switch out of Home Assistant the following happens:

relais 1 switches to on for 3 seconds After 2 seconds relais 2 switches to on for 3 seconds After 1 additional second relais 1 switches of again ... and so on for relais 3 and 4 --> fine so far After relais 4, relais 1 and 2 swich on at the same time --> one zone --> fine so far The relais 5 switches on but relais 1 and 2 do not switch off after 1 extra second relais 5 to 8 behave as expected. 1 second after relais 8 has switched off, relais 1 and 2 switch off as well

So for me it seems like for any reason the switch template gets the "off" command at the latest, only.

idontcare99999 commented 5 months ago

Same challenge here; the valve group turns on but does not turn off until the sprinkler program is complete.

In my case, I'd like to begin with a valve group of valves 1 & 2 to slowly prime the lines, then continue with only one followed by only two.