I have an EZVIZ camera, integration is set up. but the pir atribute is not working yet.
My outside light is triggered based on a door sensor at the back.
I can get the “Last alarm triggered:” value.
I want to turn off my light if the value from Last alarm triggered is unchanged for “5 seconds” as a mather of testing.
according the the home assistant docs. if you give no “from/to” value, but only a set time. this shoud check if the state doesn’t change for the 5 seconds and trigger.
i tried a real simple version of it. but get no reaction.
alias: test
description: ''
trigger:
- platform: state
entity_id: camera.husky_air_d53127471
attribute: Last alarm triggered
for: '00:00:05'
condition: []
action:
- type: turn_on
device_id: 5ef5140c47f89176e18a195fad4658ff
entity_id: light.licht_keukeneiland
domain: light
mode: single
Im probley missing something ?
sorry for my typo’s ! and thanks for being an amazing community.
happy to help. I feel its basically the same…right. If a state holds for 5sec, it means the there is no state change for 5s. Another method is to use a template to trigger the node but it again is basically the same thing.
In this case no, caus i want my lights to go out if there is no state change. Every motion makes a New last alarm. So still doesnt work for me. I did Lear something just not what i want.
Yes, turn on is easyer for me to see cause in testen light is always off. I just want the action to happen if state remains the same. So if no last alarm trigger has happend for 5 sec. The action ( on or off ) has to happen.
I really think you’ve got it, then. The idea of the for statement is to make sure the state stays locked in for xx seconds before executing the actions. If it does stay locked in, then it triggers. It seems like that’s what happened. For example:
State changes - internal 5 sec timer starts in HA (unfortunately I don’t know how to watch this)
State changes again after 4 sec - internal HA timer restarts at 5 sec and actions are not executed
This keeps happening until it does take 5 sec, then actions execute
I understand, but if i f i put the light off . And no state change the light stays off, nothing happens. If it changes the last state (because allarm trigger) and then there is no change for 5 sec it triggers. But i want it to trigger when nothing happens. If there is 0 activity and nothinging happens i want my action.
Sorry fory english but its hard to explain.
In theory it shoud trigger every x seconde because nothing happens. But only triggers when it gets detection.
Based on this, you want it to trigger when nothing happens. That’s not really the way triggers work - some event has to trigger it. You could always add a time trigger to trigger every XX minutes/hours/seconds. We tend to use that as a last resort because triggers should be based on something happening (alarm activated, light turned on, etc). (@123 has an excellent philosophy on that which makes sense to me). But I admit I have a few of them because I didn’t have any other well to trigger.
Is this the logic you are after?
Nothing has happened for a while - the light is on for some reason (?). Or maybe it’s off
The automation triggers every xx unit of time (minutes, hours, seconds) and if the alarm hasn’t triggered recently, then turn the light off.
@123 states it really well - to trigger, something has to change.
I thought (originally) you wanted to turn the light when the alarm triggers (assuming that is in a separate automation) and then this automation turns the light off if the alarm has been off for a period of time. But now I’m thinking I misunderstand your original request.
What other attributes does this camera have? Post a screenshot of its attributes.
If it has an attribute indicating the last time there was an alarm, is there an attribute that indicates the alarm’s current state (on/off)?
For example, if it has an attribute called alarm, that indicates on or off, you could do this to indicate when it’s been off for 5 seconds (equivalent to 5 seconds of last_alarm_triggered):
- platform: state
entity_id: camera.husky_air_d53127471
attribute: alarm
to: 'off'
for: '00:00:05'