I have the same basic automation going. Its trigged by my bedroom door opening with the condition that my phone is off the charger.
I use a helper. The automation toggles the helper on. Then I have a condition that will only allow the automation to run if the toggle is off.
I have a separate automation that turns that toggle back off at midnight, along with some others I only want to run once a day.
I am always the first out of bedā¦
I also have seperate automations that take place after our bedroom door has been opened for 15 minutes. Like the bedroom lights become active upon motion. I have a failsafe built in in case I forget to close the bedroom door all the way or if the sensor doesnt register the door closing. Wouldnāt want the lights to come on and wake up the wife.
description: ''
trigger:
- type: opened
platform: device
device_id: e71c134acb81c8be7a35797a38ab10dd
entity_id: binary_sensor.master_bedroom_door_home_security_intrusion
domain: binary_sensor
condition:
- type: is_not_plugged_in
condition: device
device_id: c3c350836d270a6ab7f59a03403e1d18
entity_id: binary_sensor.sm_g973u_is_charging
domain: binary_sensor
- condition: time
after: '03:00:00'
before: '08:00:00'
- condition: state
entity_id: input_boolean.wake_up_has_run
state: 'off'
action:
- device_id: 065681e3bdecd9525368eb4113591cce
domain: select
entity_id: select.harmony_hub_activities
type: select_option
option: Watch TV
- service: light.turn_on
data:
transition: 30
target:
entity_id:
- light.living_room_lamps_zha_group_0x0003
- type: turn_on
device_id: f407b33553078388d708da4afdd6c97b
entity_id: switch.kitchen_lights
domain: switch
- type: turn_on
device_id: 456a40fec7df0c228a9a583bad003788
entity_id: switch.hallway_lamps
domain: switch
- type: turn_on
device_id: 01a28cc6d329ae1a9160a02b69070c09
entity_id: switch.under_cabinet_lights_2
domain: switch
- service: scene.turn_on
target:
entity_id: scene.wake_up_off_on
metadata: {}
- delay:
hours: 0
minutes: 10
seconds: 0
milliseconds: 0
- choose:
- conditions:
- type: is_open
condition: device
device_id: e71c134acb81c8be7a35797a38ab10dd
entity_id: binary_sensor.master_bedroom_door_home_security_intrusion
domain: binary_sensor
sequence:
- service: notify.alexa_media_living_room_dot
data:
message: >-
Attention, the master bedroom door has been left open. Please
close it before the lights come on.
data:
type: announce
method: all
default: []
mode: single
I tried to adjust it to your liking. Iāve worked with it before. Thatās probably more than 30 versions.
Does it register for the first time > 21600 seconds? it does not respond yet ā¦
These code writes are currently incomprehensible to me ā¦ Iām used to: If () else etc ā¦
So I tested it. The first time it is turned on, it will sound after int> 60 seconds and then all the time. there is a ratio between time_pattern and int> 60
This will happen first and then time_pattern * int> 60
alias: Teplota bojler malo vody 02
description: ''
trigger:
- platform: time_pattern
seconds: /1
condition:
- condition: numeric_state
entity_id: sensor.bojler
below: '70'
- condition: template
value_template: >-
{{ (utcnow() | as_timestamp -
state_attr('automation.teplota_bojler_malo_vody_02', 'last_triggered') |
as_timestamp) | default(0) | int > 60 }}
action:
- service: tts.voicerss_say
data:
entity_id: media_player.obyvaci_pokoj_speaker
message: >-
Voda v bojleru mĆ” nedostateÄnou teplotu {{states('sensor.bojler')}}
stupÅÅÆ celsia. Å etÅete teplou vodou!!
mode: single
I would not consider the temperature of the boiler now, it is a condition that I test whether it will react or not, it works. The weird thing is that when time_pattern = / 1sec and int> 60, it reports for the first time right away and repeats after int> 60 sec. If I have an int> 120, it will report after 60 seconds and then report after another 60 seconds. Iāll test it again tomorrow ā¦ Iām confused
I am getting this error and the automation doesnāt work:
In āconditionā (item 2 of 2):
In ātemplateā condition: TypeError: ā<ā not supported between instances of āNoneTypeā and ādatetime.datetimeā
right sorry to cause the confusion but basically I have tried to use the same condition on another automation as well.
This is the automation:
- id: livingroom_blinds_open_in_the_morning
alias: Livingroom Blinds Open in the Morning
initial_state: 'on'
trigger:
- platform: state
entity_id: binary_sensor.livingroom_motion_detector
to: 'on'
condition:
- condition: time
after: '06:30:00'
before: '12:00:00'
- "{{ state_attr('automation.livingroom_blinds_open_in_the_morning', 'last_triggered') < today_at('06:30') }}"
action:
- service: cover.set_cover_position
data:
position: 100
target:
entity_id: cover.livingroom_blinds
Now this automation doesnāt work and throws the following error/warning:
2022-04-21 10:51:15 WARNING (MainThread) [homeassistant.components.automation] Error evaluating condition in 'Livingroom Blinds Open in the Morning':
In 'condition' (item 2 of 2):
In 'template' condition: TypeError: '<' not supported between instances of 'NoneType' and 'datetime.datetime'
In the template condition, if the automationās name is incorrect (in this case it appears to be correct) or the automation has never been triggered yet, the result of the state_attr() function will be none.
If you recall, I explained this in a previous post and described how a default filter can mitigate this situation.
so in the end I solved it completely differently. In configuration.yaml, a global boolean variable is defined. When the temperature drops once it reports. The transformation turns off. The boiler heats up above the set limit and the variable is switched on.
configuration.yaml
input_boolean:
notify_boiler:
name: NotifyBoiler
initial: ON
automation on only sound:
talias: Teplota bojler 68
description: ''
trigger:
- platform: time_pattern
minutes: /1
condition:
- condition: time
after: '08:00:00'
before: '22:00:00'
weekday:
- mon
- tue
- wed
- thu
- fri
- sat
- sun
- condition: state
entity_id: input_boolean.notify_boiler
state: 'on'
- condition: numeric_state
entity_id: sensor.bojler
below: '68'
action:
- service: tts.voicerss_say
data:
entity_id: media_player.obyvaci_pokoj_speaker
message: >-
Voda v bojleru mĆ” nedostateÄnou teplotu {{states('sensor.bojler')}}
stupÅÅÆ celsia. Å etÅete teplou vodou!!
- service: input_boolean.turn_off
target:
entity_id: input_boolean.notify_boiler
data: {}
mode: single
Why have you chosen to use Time Pattern Triggers when the automation can clearly be triggered exclusively when desired events occur (and not needlessly and repeatedly every X minutes)?
I actually do this by creating a input_boolean helper. It turns off at midnight and turns on with the specific automation that should only be run once. Then use input_booleanās state = off as a condition for it.