After creating a fresh os install, installing new version of HA 2022.8.6 and restoring my backup across, it was found that i needed to update “float” to “float(0)” to allow for this to be rendered properly. This was the only change so far.
id: mobile1heateron
alias: mobile1 heater on when below min input
trigger:
I have since found that the automation does not fire when turning the automation “on” & the triggers are already “true”.
The triggers shown are intialized in the logs, the triggers themselves would be starting off as “True” where the actual room temp is below input.
I’ve found that if the trigger goes from ‘True’ to ‘False’ & back to ‘True’ again, it will fire for the first time.
This was not an issue on the old version, and worked straight from the start - If the trigger=true it would run immediately.
I’ve also noticed odd behaviour in the “dev tool” > “template” for math operations. If I enter in:
The expected value for the last line wouldve been ‘18.9’. I dont think this would be related since my triggers are based on greater/less than, but I felt should be pointed out anyways as a potential bug?
Template triggers work by evaluating a when any of the recognized entities change state. The trigger will fire if the state change caused the template to render ‘true’ when it was previously ‘false’.
The evaluation of the template must change from “false” to “true” for the trigger to fire.
Thanks for the help.
The want for heating is mostly at whim and not always based off presence or timings, nor even pure temperature. Reasons such as wanting to save electricity for example, not necessarily just being in the room.
Having said that, the linked doc seems to be providing a workaround for this by using a true state duration to enforce the trigger:
Use of the for option will not survive Home Assistant restart or the reload of automations. During restart or reload, automations that were awaiting for the trigger to pass, are reset
I do still find it odd that the same automations worked in previous version of home assistant.
In each of the automations, yet still the trigger for heater is not firing.
Interestingly I have a basically the exact same syntax but for a humidifier which is firing if trigger=true on initial without requiring any trigger template result changing between true/false:
id: mobile1humidifieron
alias: mobile1 humidifier on when below min input
trigger:
Is there any common knowledge or best practices that might help? Do you always need to restart Home Assistant when defining a new automation? I’ve tried everything, but I still can’t get this to work. Any idea why?
alias: Turn on switch when sensor is larger than 500
description: Turn on the switch if the sensor value exceeds 500
triggers:
- value_template: "{{ (states('sensor.ams_ec5d_p') | float(0)) >= ( 500 | float(0)) }}"
trigger: template
conditions: []
actions:
- type: toggle
device_id: bdb56bab5f9ef9d9e0d4210ec044185f
entity_id: 10aa6676e1da35cc7b7327853c5c5938
domain: switch
- action: notify.notify
metadata: {}
data:
message: >-
The sensor value is {{ (states('sensor.ams_ec5d_p') | float(0)) }} and
has exceeded 500.
- delay:
hours: 0
minutes: 1
seconds: 0
milliseconds: 0
mode: single
When I force-run the automation, I receive the message ‘The sensor value is 901.8 and has exceeded 500.’ This confirms that the sensor works and returns different values above 500, which should result in the automation running almost every minute.
Sorry; Background: the value during the last couple of hours will exceed 500 and now its 900.0 and since I have a delay which I right now see is not included in the core. let me edit.
So, Trigger is an event. And most likely my automation already set this to true and will not fire again until tomorrow? It saves that event even if I restart the automation?
Triggers “listen” for events. A Template trigger “listens” for the event of the rendered value of the template changing from false to true.
The automation does not “set anything to true” or “save that event”. If the template already renders true when reloading the automation or restarting HA, the trigger will not fire until it renders false then true.
If you need the automation to run on restart, you can in use the Home Assistant Trigger with event set to start. If you really want it to run every minute you can use a Time Pattern trigger. Time Pattern triggers are rarely necessary and not the recommended pattern for most automations in HA.