I have a somewhat flaky ip cam…that needs to be restarted once in a while…
So i thought i create an automation that checks if cam is having status “unavailable” and restarts it via “smart” outlet.
BUT…for some reason, my automation doesnt see the status or doesnt care…
Can anyone take a look and let me know what part i am missing?!
Unfortunately my changes to state did nothing
Is there a state check that does not require a change from something to something? Just if state is xyz than do bla bla?
Cause the code as it is rught now is looking a for a change from to unavailable, but the from stste can be a list of things and not just available.
Maybe using a ‘From’ definition in the trigger helps (e.g. from: idle or from: recording) to: unavailable helps - not sure, though, what the right status might be or if you’d need to use more than one trigger to capture all possibilities
Check with a time pattern trigger, if the state is unavailable every 5 or 10 minutes - and if the camera is unavailable run the switch off/switch on action.
I have a camera that falls off now & then and I just do a switch off/on routine every night at e.g. 3:33AM - this has worked well for me so far and keeps me from checking every 5min.
Ok, day two and several camera flaws and still not automation trigger…
awkward…found in yaml view that it had the unavailable in “” with a space behind it:
"unavailable " but no change since
Your trigger in the first post is all wrong. It is setup to monitor any changes to an attribute with name/key unavailable, rather than the state when its value changes to unavailable.
triggers:
- trigger: state
entity_id: camera.backyard_cam
to: unavailable
for:
seconds: 30
Yes. Time. Here is an automation that I have that turns off power to a heated doormat if there has been no snow falling for 30 minutes.
alias: Turn off switch when no snow is detected
description: The Zooz outdoor switch is controlling the heated snow mat on the deck.
triggers:
- minutes: /1
trigger: time_pattern
conditions:
- condition: template
value_template: |
{{ states('sensor.openweathermap_snow') | float < 0.9 and
(now() - states.sensor.openweathermap_snow.last_changed).total_seconds() > 1800 }}
actions:
- target:
entity_id: switch.zooz_outdoor_switch
action: switch.turn_off
data: {}
mode: single
The ‘SpaceOrNoSpace’ part was specifically put there to flush out any potential characters between the ‘state’ and the first ‘S’
Try to put the ‘unavailable’ or ‘recording’ - whatever current state it’s supposedly in - as a condition and then test it using the Automation GUI Test functionality to verify it’s picking up the correct string.
You’ll either get a green or an orange band at the top of the condition box.
Ohhh…i see what that does/did…
Change dit to that and all the sudden i am even able to select from the possible states…
Thx alot…that was the winning ticket…i hope…haven’t seen it working yet, but it looks promising