Resend Service Call after Action Completion Check

Hi all, I just need a point in the right direction please. I’ve made some smart radiator valves (sRVs) using an esp-12 that are integrated into hass.io as a cover component. I have them automated based on the temperature of sensors situated around the house. However, they don’t always receive the service call to open/close from hass.

My sketch causes the sRV to broadcast it’s state every 20 seconds, so it should be possible to check if an action has been carried out. I’m guessing the action to open/close the valve should be carried out by a script that sends the relevant service call, delays, checks the state is as expected and, if not, calls the service again and repeats until the condition is met.

I’m just struggling to see how this ‘repeat until true’ could be implemented. The ideal would be to use Quality of Service 2 but as far as I can tell is not possible with esp-12.

Any pointers would be fantastic.
Merry Christmas all

Are you sleeping for a long time? I use esp chips and mqtt (for various things) and they always respond, but I don’t put them to sleep for more than a second. Mine also only report at connection and state changes to keep network traffic to a minimum.

However, to implement something like what you asked for in HA I would create a 2 step process.

1st, create a binary input that represents the desired state and use it everywhere you were previously using a sRVs.

2nd, create an automation that tries to make sure that the binary input and sRVs match. So trigger on binary input change and sRVs update received and then send the command if it needs to be updated.

Thanks for the response nordlead2005 I don’t have the esp’s sleep at all, they’re plugged in to the mains via USB port.

You’re spot on! I need a secondary part of the Action that sets a binary input to the desired state, after a bit of a delay. That can trigger a different automation that checks if the desired and current states are the same and, if not, triggers the first automation again.

Top man, I don’t know why that wouldn’t spring to mind but I knew it was worth asking the community!!

I just realized I should have said delay, since sleep is different for esp. I don’t sleep mine either because that turns off the wifi and my boards are plugged into mains anyways. However I’ve found that a long delay causes my boards to fail to respond when I try to do OTA updates.

I’m considering using one of the esp’s as a wifi extender. That might solve my problem as well but I’m going to try your idea first. It’s been such a long time since I first did my automations, it’s like returning to a file that someone else wrote!

Do you think it’s the Input Boolean component I need?

Thanks

Yes, that is the one I meant when i said binary input. I may have first responded at 5am so I wasn’t fully awake…

Haha!! I started looking at this at 6am after my son woke me up at 4:30am :joy:

I’m impressed we managed to string our sentences together, so thank you very much for your help, it’s greatly appreciated!

I’ve stumbled across something here, so I thought I’d post in case someone comes across this topic. I discovered that you can use conditions as part of actions. Therefore, I should be able to check the state of my sRVs and if they’re not correct I can trigger the automation again. Hope this works!!

- id: sRV_l_high
  alias: Living Room sRV High/Close
  trigger:
    - platform: state
      entity_id: sensor.lr_state
      from: 'normal'
      to: 'high'
  action:
    - service: cover.close_cover
      entity_id: cover.srv_l
    - delay: 00:00:30
    - condition: state
      entity_id: cover.srv_l
      state: open
    - service: automation.trigger
      entity_id: automation.sRV_l_high
1 Like

Edited code above and it seems to be working. Time will tell!!