Hi Bob,
Yes I know turning on the automation doesn’t trigger it :).
What I’m trying to accomplish is that the first automation turns on the heating.
Then the second automation should trigger after the starting time + duration minutes occurs, and should turn off the heating.
I copied it from this thread (hmmm, maybe I should post my question there then :))
Unless I did not understand your request, if you simply want to turn your heating off x minutes after it’s been turned on, why not add a delay to your first automation then turn the heating off?
I want it to be variable and to be set through the UI. So 1 day I may want it to stay on 15minutes, the other day 60minutes.
Can I use input_numbers as the delay variable?
in that case I’d personally stick with 2 automations indeed.
The 2nd should run periodically (e.g. every 1 min) and have a condition to check against.
I’d say make sure you’re on you can use release 0.55 or later and use input_datetime in your condition. I would not use the == operator but the >= operator to make sure your automation still runs in the event where there is a delay.
I’d use something like this:
I’ve not tested the above code so can’t guarantee it’s error-free but should give you a starting point hopefully.
OR you could use an input_select with a list of times and use this instead of input_datetime.time_to_heat if your list of possible times is not infinite
I think if you were to create an MQTT switch that had as payload your slider state and set the state and command topics to the same, then set the retain switch to true, that would force the MQTT broker to resend the slider state back after a reset. You would have to setup an automation to send the state when it’s state changed.
from automation.yaml
Publish the alarm time hours when it has changed.
- alias: MQTT TimeSlider Hours
trigger:
- platform: state
entity_id: input_number.alarmtimehrs
action:
- service: mqtt.publish
data_template:
topic: "cmnd/MQTTSliderSaveHrs"
retain: true
payload_template: '{{states.input_number.alarmtime.state | int}}' <------ this may need to be changed or you may be able to use the new input.date_time - doing it this way you would need to do the same for the minutes
The following sets the Alarm time hours from the MQTT that is received when HA resets…
You will have to modify this to your own use case.
I don’t know why the other way (that I showed above) would not work except that you would need to change every use of input_slider to input_number in the yaml and the python code.
@masterkenobi i follow your alarm on github.
I use hass.io but when i restart home assistant i lost the values hour and minutos. The values not stored. I think the solution is what @keithh666 said.
@masterkenobi thanks mate.
now it Works, but with one BIG problem.
if you delete home-assistant.log and home-assistant_v2.db all the sliders values are deleted and not stored. @dale3h had the big solution for this, using MQTT.