Water valve automation running but not turning off and on

This automation is not turning the water valve for some reason. Seems to go through the traces fine. Is there something i overlooked? There’s a state condition that makes sure the entity is ‘available’ as it goes offline sometimes for a few minutes. Other then that no complexities. It just turns it off, waits for 5 minutes and then turns it back on. Or is supposed to.

- id: '1638184094903'
  alias: Water Mains Weekly Test
  description: Turn Water Valve on and off
  trigger:
  - platform: time
    at: 07:00
  condition:
  - condition: time
    weekday:
    - sat
  - condition: state
    entity_id: switch.wifi_valve_socket_1
    state: 'on'
  action:
  - service: notify.alexa_media_everywhere
    data:
      message: Starting weekly main water valve test
      data:
        type: announce
        method: all
  - type: turn_off
    device_id: a7ade350169e5cf59fcce970a2d7bd28
    entity_id: switch.wifi_valve_socket_1
    domain: switch
  - delay:
      hours: 0
      minutes: 5
      seconds: 0
      milliseconds: 0
  - condition: state
    entity_id: switch.wifi_valve_socket_1
    state: 'on'
  - type: turn_on
    device_id: a7ade350169e5cf59fcce970a2d7bd28
    entity_id: switch.wifi_valve_socket_1
    domain: switch
  - service: notify.alexa_media_everywhere
    data:
      message: Weekly main water valve test complete
      data:
        type: announce
        method: all

Seems this is more of a tuya integration problem…if i click on the device it’s there but it says last updated 17 hours ago and it’s still online. That’s suspicious on it’s own as it regularly goes offline every 5 hours or so for minutes.

And if i flip the switch in lovelace it bounces back immediately. Maybe i’ll try and reload tuya.

Update* and…that seemed to have fixed the problem. I guess i might have to reload or check when the integration was last loaded to make it more resilient. Don’t know if that’s a possibility.

Which steps are executed and which not? What does the automation debugger say?
I’m a bit confused why you don’t make a service call for the actions. I’ve never seen this syntax before.
The condition in the action block can’t render true because you turned off the switch before.

Hi there,
Good point on the condition. I should change that to whatever state it’s in when i turn it off but still is online. I’ll have to check.

How would a service call look like (i’m still new to Home Assistant).

Thanks, much obliged.

action:
  - service: switch.turn_on
    target:
      entity_id: switch.xyz

@FPro Hi Florian, apologies for my late reply. Could you expand on why my syntax is uncommon and why the service call is better ? You say you’ve never seen that syntax but i’m just turning the device on right? Not sure what’s wrong about that.

Thanks!

Ignore my comment. Your syntax is fine.
I’ve simply never worked with devices. I like the concept of entities and service calls simply better because you can do anything with it and it’s cleaner. With devices you are limited and I don’t want to work with different concepts at the same time.

1 Like

Makes sense, thanks.

I am having a similar issue with a water valve (this one) and the lovelace switch not having any effect on the device. Only the physical button on the device itself triggers on/off. How did you solve it?