What I am trying to do is turn on lights on door open. That is clear.
But I don’t want to turn them on if door sensor was already triggered within last 30 mins ?
Is there a simple way to implement this ?
Using for in trigger would check that it is open for 30 min.
And using for and checking for closed time in condition wouldn’t work, since doors are already open ?
Also I couldn’t find a way to say home temperature in automation:
- id: someone-came-home-after-empty
alias: "Welcome home, everything on"
trigger:
- platform: state
entity_id: binary_sensor.door_window_sensor_158d0002436463
from: 'off'
to: 'on'
action:
- service: tts.google_say
entity_id: media_player.home
data_template:
message: >
Welcome Home
Home temperature is {{states('sensor.temperature_158d000234d46c')}}
cache: false
If I remmember it correctly, it says state unknown or something like that.
I like to use “hidden” input_boolean switches to start /end automations
You could use 2, the first input_boolean1 would be turned on when the automation first starts (i.e. someone comes home)
Have a second automation which checks if the input_boolean1 has been on for 30 minutes, which then turns on another input_boolean2. This input_boolean2 would being used as a condition in your automation.
Of course you need to have your automation reset both input_booleans to their initial state.
For your secon question, you should try {{states.sensor.temperature_158d000234d46c.state}} instead of {{states(‘sensor.temperature_158d000234d46c’)}}
Hi, thanks, that’s the only option I am thinking about, but isn’t there is a cleaner way ? sounds like a feature request, which would be super useful for a lot of stuff when you don’t want to repeat something more than you need to.
The states function will return ‘unknown’ if the entity_id doesn’t exist. Are you sure there isn’t a typo? BTW, if you change it to states.sensor.temperature_158d000234d46c.state, and it is a typo, that will cause an error. I always recommend using the states function when possible for this and other reasons.
The easiest way to prevent an automation from triggering again for a period of time after it triggers is to add a condition based on its last_triggered attribute. E.g.:
condition:
condition: template
value_template: >
{% set last_triggered = as_timestamp(
state_attr('automation.welcome_home__everything_on', 'last_triggered')) %}
{{ last_triggered is none or (as_timestamp(now()) - last_triggered) > 30*60 }}
You may need to adjust the entity_id for the automation - it’s based on the alias and I may have incorrectly guessed how your alias would be converted to an entity_id.