It seems to be working fine now.
Thank you all for your help.
It seems to be working fine now.
Thank you all for your help.
It seems like an MQTT button would be the way to go for that. Or one of those z-wave remote controls. I don’t know if an automation can control another automation though.
Thanks, been a while since I looked at this.
I have some Xiaomi Buttons so I may make them switch on a script that stops the alarm… adds a 10mins delay… then starts the alarm sound again. Should be quite easy actually. I haven’t used my alarm since because I couldn’t find a simple solution at the time. Thanks for reminding me! I’ll add this to the list of things to do.
What I would really love is to continue using my sleep cycle app and integrate it into Emulated Hue. The app can turn on/turn off a Hue bulb when the alarm is set/goes off. But I haven’t found a way of making that work with emulated Hue.
Can anyone help me?
I have this automation:
- alias: 'Ochtend Verwarming'
trigger:
platform: state
entity_id: input_number.morningheatinghour, input_number.morningheating_min, input_number.morningheatingduration
action:
- service: homeassistant.turn_on
data:
entity_id:
- automation.morningheating_on
- service: homeassistant.turn_on
data:
entity_id:
- automation.morningheating_off
- alias: 'morningheating_on'
initial_state: True
trigger:
- platform: time
minutes: '/5'
seconds: 14
condition:
condition: and
conditions:
- condition: template
value_template: '{{ (now().strftime("%s") | int | timestamp_custom("%H:%M")) == states.sensor.morningheating_time.state }}'
- condition: state
entity_id: input_boolean.morningheatingstatus
state: 'on'
action:
service: scene.turn_on
entity_id: scene.Ochtend_Prog_aan
- alias: 'morningheating_off'
initial_state: True
trigger:
- platform: time
minutes: '/5'
seconds: 14
condition:
condition: and
conditions:
- condition: template
value_template: '{{ ((now().strftime("%s") | int - (states("input_number.morningheatingduration") | int) * 60) | timestamp_custom("%H:%M")) == states.sensor.morningheating_time.state }}'
- condition: state
entity_id: input_boolean.morningheatingstatus
state: 'on'
action:
service: scene.turn_on
entity_id: scene.Ochtend_Prog_uit
Second automation doesn’t trigger.
How to solve?
I’m not quite sure what you are trying to accomplish here. What is your goal with this automation? Turning on an automation doesn’t mean it gets triggered, you are aware of that?.
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 :))
Hi @PuckStar,
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?
action:
service: scene.turn_on
entity_id: scene.Ochtend_Prog_uit
delay: 00:10:00
service: scene.turn_off
entity_id: scene.Ochtend_Prog_uit
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:
- condition: template
value_template: '{{ (as_timestamp(states.automation.ochtend_verwarming.attributes.last_triggered + input_datetime.time_to_heat) - as_timestamp(states.automation.ochtend_verwarming.attributes.last_triggered) > 0}}'
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
hello guys i use the alarm clock.
when i restart my pi i lost all values of my Sliders.
how can i do?
Have a look here…
Something goes wrong with the statement half hour before but I’m not sure what I’m doing wrong.
Any thoughts?
- alias: 'Half uur voor de wekker CV aan'
initial_state: 'on'
hide_entity: True
trigger:
platform: template
value_template: '{{ ((now().strftime("%s") | int + 1800 ) | timestamp_custom("%H:%M")) == states.sensor.alarm_clock_time_long.state }}'
condition:
condition: or
conditions:
- condition: and
conditions:
- condition: state
entity_id: input_boolean.alarmstatus
state: 'on'
- condition: state
entity_id: input_boolean.alarmweekday
state: 'on'
- condition: and
conditions:
- condition: state
entity_id: input_boolean.alarmstatus
state: 'on'
- condition: state
entity_id: input_boolean.alarmweekday
state: 'off'
action:
- service: scene.turn_on
entity_id: scene.toon_comfort
@keithh666 i tried it but not works.
I would like to use mqtt.
I use this:
alias: ‘test’
trigger:
platform: template
value_template: '{{ states.sensor.time.state == states.sensor.alarm_time.state }}
action:
service: notify.notify
data_template:
message: ‘teste’
How can transform that ,on mqtt?
I dont want lost my sliders values when i restart.
@masterkenobi can u help too?
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.
@keithh666 i am using this alarm https://github.com/master-kenobi/ha-alarmclock
Can put here that changes ? I dont have skills to create that you told me. If you can help was great.
An alarm clock that plays a radio station in the morning?
What would be the best code
can you post your code, thanks
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…
- alias: 'Set Alarmtime Hours from MQTT'
trigger:
- platform: mqtt
topic: cmnd/MQTTSliderSaveHrs
action:
- service: input_number.set_value
data_template:
entity_id: input_number.alarmtimehrs
value: '{{ trigger.payload}}'
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.
input_slider
has changed to input_number
in version 0.55. I have updated the code in my github to reflect that.
Don’t worry. The value will not lost after restart.