hi,
I launched a smartphone charging warning automation but with the condition: not at night
how to restart this automation when the condition is met (day)???
Thanks
hi,
I launched a smartphone charging warning automation but with the condition: not at night
how to restart this automation when the condition is met (day)???
Thanks
Add a trigger for day?
or add a choice and move the condition(s) there
add a trigger for day ?? i think it s not the solution
in my automation:
trigger:
battery < 15 %
condition: state
entity_id: binary_sensor.journee
state: āonā
action:
notify
if battery < 15 % and the condition is off ā no action
after night, i would like to restart automation ā¦
If you want to restart the automation, you need to trigger it, no other way to start an automation.
Can you show your automation comprehensive ? Please use proper formatting
alias: Recharge batterie smartphone Se20 FE (jacques)
description: ""
trigger:
- platform: template
value_template: >-
{{ (states.sensor.sm_g780g_battery_level.state | int) <
(states.input_number.battery_minimum.state | int) }}
condition:
- condition: state
entity_id: binary_sensor.journee
state: "on"
- condition: state
entity_id: input_boolean.house_vacation_mode
state: "off"
- condition: state
entity_id: person.carlier
state: home
enabled: false
action:
- variables:
stop_time: "{{ now() + timedelta(minutes=10) }}"
enabled: false
- service: counter.reset
data: {}
target:
entity_id: counter.my_custom_counter
- repeat:
until:
- condition: or
conditions:
- condition: state
entity_id: sensor.sm_g780g_battery_state
state: charging
- condition: numeric_state
entity_id: counter.my_custom_counter
above: 2
sequence:
- service: notify.mobile_app_sm_g780g
data:
message: TTS
data:
tts_text: >-
Jacques Il est temps de recharger la batterie de ton smartphone
le niveau actuel est a
{{states('sensor.sm_g780g_battery_level')}} pourcent.
media_stream: alarm_stream_max
visibility: public
- service: notify.alexa_media
data:
message: >-
Jacques Il est temps de recharger la batterie de ton smartphone
le niveau actuel est a
{{states('sensor.sm_g780g_battery_level')}} pourcent.
title: recharge batterie
target: media_player.echo_dot_carlier
data:
type: tts
enabled: true
- service: tts.google_translate_say
data:
entity_id: media_player.google_media_player
language: fr
message: >-
Jacques il est temps de recharger la batterie de ton smartphone
le niveau actuel est a
{{states('sensor.sm_g780g_battery_level')}} pourcent.
- service: counter.increment
data: {}
target:
entity_id: counter.my_custom_counter
- delay:
hours: 0
minutes: 5
seconds: 0
milliseconds: 0
mode: restart
if trigger appears at nignt ā no action
i want to restart after night
Then donāt make it trigger at nightā¦
{ (states.sensor.sm_g780g_battery_level.state | int) < (states.input_number.battery_minimum.state | int) and ( now() > today_at("07:00") and now() < today_at("23:00") ) }}
This will only trigger between 07:00 and 23:00
If the battery percentage < x% (trigger) arrives at night, the automation will not be activated due to the condition.
but I want the automation to restart when the condition is activated, i.e. the next day
and it becomes 07:00 it will trigger
Or maybe:
{ (states.sensor.sm_g780g_battery_level.state | int) < (states.input_number.battery_minimum.state | int) and ( states.binary_sensor.journee.state == "on" ) }}
(if binary_sensor.journee.state represents your day time state)
this will trigger when
states.sensor.sm_g780g_battery_level.state < x
and
states.binary_sensor.journee.state becomes āonā
(in which case you should drop the binary_sensor.journee condition )
I thought this:
2 triggers
1. {{ (states.sensor.sm_g780g_battery_level.state | int) <
(states.input_number.battery_minimum.state | int) }}
2. entity_id: binary_sensor.day
state: āonā
do the 2 triggers have to be carried out or one of the 2??
THANKS
if either trigger becomes active it will trigger
Shouldnāt both be active? (condition:and)
trigger on both (which makes it trigger when either one happens.) - this is how you catch the event when night timeās over.
condition on both (which makes it execute only if both are true)
alias: Recharge batterie smartphone Se20 FE (jacques)
description: ""
trigger:
- platform: template
value_template: >-
{{ (states.sensor.sm_g780g_battery_level.state | int) <
(states.input_number.battery_minimum.state | int) }}
- platform: state
entity_id:
- binary_sensor.nighttime
to: "off"
condition:
- condition: state
entity_id: binary_sensor.nighttime
state: "off"
- condition: template
value_template: >-
{{ (states.sensor.sm_g780g_battery_level.state | int) <
(states.input_number.battery_minimum.state | int) }}
....
since it needs to be used twice, iād create a binary_sensor of your templateā¦ call it binary_sensor.needs_charge or something like that.
okā¦
thanks but one more question
Are triggers in automation always of the AND type???
no, thatās why i said '(which makes it trigger when either one happens.) ā
triggers are by default āorā
conditions are by default āandā
ok many thanks
I thought that the triggers were always AND, so it is enough for one trigger to be effective for the automation to start
very strange when i ask CHATGPT: (gemini)
my question:
" in home assistant , Are triggers in automation always of the AND type"
No, triggers in Home Assistant automations are not always of the AND type. Home Assistant offers two main ways to define triggers for automations:
Hereās a breakdown of how to distinguish between them:
AND Triggers:
`YAMLtrigger:
This automation will only activate if the front door is open AND the sun has set.
OR Triggers:
`YAMLtrigger:
This automation will activate if the temperature is greater than 25Ā°C OR the back door is open.
In summary:
Still I guess this is easier:
alias: Recharge batterie smartphone Se20 FE (jacques)
description: ""
trigger:
- platform: template
value_template: >-
{{ ((states.sensor.sm_g780g_battery_level.state | int) <
(states.input_number.battery_minimum.state | int)) and
(states.binary_sensor.journee.state == "on" ) and
(states.input_boolean.house_vacation_mode.state == "off" ) }}
condition:
- condition: state
entity_id: person.carlier
state: home
enabled: false
action:
- variables:
stop_time: "{{ now() + timedelta(minutes=10) }}"
enabled: false
- service: counter.reset
data: {}
target:
entity_id: counter.my_custom_counter
- repeat:
until:
- condition: or
conditions:
- condition: state
entity_id: sensor.sm_g780g_battery_state
state: charging
- condition: numeric_state
entity_id: counter.my_custom_counter
above: 2
sequence:
- service: notify.mobile_app_sm_g780g
data:
message: TTS
data:
tts_text: >-
Jacques Il est temps de recharger la batterie de ton smartphone
le niveau actuel est a
{{states('sensor.sm_g780g_battery_level')}} pourcent.
media_stream: alarm_stream_max
visibility: public
- service: notify.alexa_media
data:
message: >-
Jacques Il est temps de recharger la batterie de ton smartphone
le niveau actuel est a
{{states('sensor.sm_g780g_battery_level')}} pourcent.
title: recharge batterie
target: media_player.echo_dot_carlier
data:
type: tts
enabled: true
- service: tts.google_translate_say
data:
entity_id: media_player.google_media_player
language: fr
message: >-
Jacques il est temps de recharger la batterie de ton smartphone
le niveau actuel est a
{{states('sensor.sm_g780g_battery_level')}} pourcent.
- service: counter.increment
data: {}
target:
entity_id: counter.my_custom_counter
- delay:
hours: 0
minutes: 5
seconds: 0
milliseconds: 0
mode: restart
Note you can even move the vacation and person home condition to the template.
I left the person condition out, as I noted it is disabled
yes very interesting thanks
Thatās because ChatGPTās answers are nonsense. Triggers are instantaneous events like āthe door opensā not states like āthe door is openā.
To get the behaviour you might be thinking of as āANDā triggers, you trigger off each thing, and check for both things in the condition:
Trigger (event):
Condition (state):
That will only get to the action if both things (low battery level and daytime) are true, and that will happen at the moment the second thing becomes true.
chatgptā nonsense: