My "restart cam when becoming unavailable" automation does not work...help

Hello all…

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?!

alias: Switch_Restart_BackyardCam
description: ""
triggers:
  - entity_id:
      - camera.backyard_cam
    for:
      hours: 0
      minutes: 0
      seconds: 30
    trigger: state
    attribute: Unavailable
conditions: []
actions:
  - type: turn_off
    device_id: 16ca6cd625032cf41316c62764c5bb16
    entity_id: 5c3122452470b3d17e59fa16b3dcf889
    domain: switch
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - type: turn_on
    device_id: 16ca6cd625032cf41316c62764c5bb16
    entity_id: 5c3122452470b3d17e59fa16b3dcf889
    domain: switch
mode: single

Just checking:
Are you sure it’s an attribute that shows the camera unavailable and not the state itself?
And is it ‘Unavailable’ or ‘nnavailable’?

Ohhhh, that question might have solved my gordig knot.
It is a state…just checked…
And it is lower case unavailable

Glad to see that the stae makes more sense than my typing :confused:

Did you get it to work?

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.

Thx alot

Two options, I guess:

  1. 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

  2. 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.

Just did the rom part and will keep you posted…just not sure when it is going to happen next…or even why it does it…but already