Hi there, not sure if has been asked before, and I’ve been reading alot of the other examples. I’m just a rookie, only started to implement Home Assistant with my MQTT and Arduinos recently.
I’m currently controlling my Heating/Boiler with this and what I would like to achieve would be, to have a slider to pick the time the boiler will run then switched on.
Everything is working, except the fact that by some reason the automation is not triggering the switch that will create the delay and then turn off the boiler.
The switch does work if I turn it on manually. I’ve read a lot of other examples and can’t seem to find whats wrong
Any help/hint will be greatly appreciated.
Automations
alias: Run Boiler for X time...
trigger:
platform: state
entity_id: switch.timed_boiler
to: 'on'
action:
- service: script.turn_on
entity_id: script.boiler_time
Scripts
boiler_timer:
alias: "Boiler Timer"
sequence:
- service: notify.notify
data:
message: 'Turned on the timer'
- delay: '00:{{ states.input_number.boiler_run_time.state | int }}:00'
- service: homeassistant.turn_off
data:
entity_id: switch.timed_boiler
Slider:
input_number:
boiler_run_time:
name: Boiler Time
initial: 60
min: 1
max: 120
step: 1
Switch:
- platform: command_line
switches:
timed_boiler:
command_on: "/usr/bin/curl -X GET http://192.168.193.101/?button1on"
command_off: "/usr/bin/curl -X GET http://192.168.193.101/?button1off"
command_state: "/usr/bin/curl -X GET http://192.168.193.101/?button1status"
value_template: >-
{%- if value_json["response"]["values"][0] == 1 -%}
{{ true }}
{%- else -%}
{{ false }}
{%- endif -%}
friendly_name: Timed Boiler
And then a simple automation to turn off the device once the state of the slider is 0.
In that way even if restarting you can keep the timer active and you can see how much time is still on the timer.
If you use an initial value it will override the value that was last set before a restart.
If you set an initial_value it will always use that value when HA starts, hence the name.
If you don’t set an initial_value it will either show the last set value before a restart, or it will be unknown - the latter could happen for two reasons:
it’s the first time you start HA with this automation at all
or
the value that was supposed to be stored has been deleted, e.g. by deleting the complete database, or another error (I restart HA from the command line of my Pi with sudo systemctl restart home-assistant@homeassistant and I have managed to do this a second time while the system had no fully started up the first time, deleting all my input_whatever values).