Home Assistant - Using Input Number to trigger automations
Emiliano Guerzoni
Project Manager / Technical Manager renewables/energy efficiency projects | Demand Manager digital energy domain at algoWatt
Hi everyone,
In this article we have seen how to define a value using the Input Number integration.
Today we'll see how to use Input Number as dynamic values to trigger automations.
Scenario
You want to get notified when the battery of your smartphone reaches a value you can dynamically set / modify as you need via the Home Assistant user interface.
Software configuration
领英推荐
Home Assistant code (yaml) / procedure
This is the piece of code you have to write as?Automation:
alias: >
? Smartphone - Send an Android notification if the battery level overcomes the threshold (min/max) set as Input Number helpers
description: >-
? Send an Android notification if the battery level overcomes the threshold (min/max) set as Input Number helpers
trigger:
? - platform: template
? ? value_template: >
? ? ? {{ states('sensor.yoursmartphone_battery_level')|float? >
? ? ? states('input_number.SmartphoneBatteryThresholdMax')|float }}
? - platform: template
? ? value_template: >
? ? ? {{ states('sensor.yoursmartphone_battery_level')|float? <
? ? ? states('input_number.SmartphoneBatteryThresholdMin')|float }}
condition: []
action:
? - service: notify.mobile_app_yoursmartphone
? ? data:
? ? ? message: >-
? ? ? ? The battery level is at?
? ? ? ? {{states("sensor.yoursmartphone_battery_level") }}%. Shut-off charging or give your phone a recharge.
mode: single
-
Some specifics about the code / procedure above
Thank you for reading. ?? I hope you have enjoyed this article.
I'm available for any feedback so, feel free to contact me or share your thoughts in the comments section below.
Your feedbacks will be appreciated!
Meanwhile,?if you liked this article share it or?subscribe?to my newsletter?about?Home Assistant?to read previous episodes and still up to date on latest news.
Director and lead consultant at Pomacon AS
10 个月Been searching for a while to solve this problem and this did just that, thanks!