I have tried your code It works fine. But i need some help with the implementation of the time to run before actual time to leave and the temp sensor condition.
I got output 15:17 for the first line, and 14:17 on the second one. So it seems that my time is 1hour off. But ‘date’ in cli gives the correct time (14:17).
I answer myself. My code work. But it seems that everything is use the correct time beside the sensors. They use utc-time. So my heater is start 1h earlier then I set. I can’t find a setting to change this. I use “Europe/Stockholm” as time_zone in configuration.yaml.
I have been trying to get this to work for a couple of days now, but I can’t get it going.
HASS gives me the following error Error loading /config/configuration.yaml: expected '<document start>', but found '<block mapping start>' in "/config/packages/motorv.yaml", line 99, column 1
I’m using Atom as my editor and it outputs the another error for line 98 end of the stream or a document separator is expected
I got it working and I also have to use utcnow to get it to turn on at the right time.
I do have another problem though, and that is that the automations turn off acording to the script, but they never turn on again. If I restart Home assistant or manually activates the automations it works again, but shouldn’t they get activated if I set a new departure time?
I have been trying to get this to work for a couple of nights now. I can see everything in the frontend but when I choose a time in the sliders the event wont fire at the time it should. Nothing happens. For example if the temperature outside is 3,5 the vent should fire 30 minutes before departure, right? I have it connected to a switch in the living room now just to try it out.
Automations.yaml:
#Kupevarmare
- alias: "heater ak minus 10"
initial_state: True
trigger:
- platform: time
minutes: '/5'
seconds: 2
condition:
condition: and
conditions:
- condition: numeric_state
entity_id: sensor.koket_utomhus_temperature
below: -10
- condition: template
value_template: '{{ ((now().strftime("%s") | int + 7200) | timestamp_custom("%H:%M")) == states.sensor.departuretime_ak.state }}'
action:
- service: script.turn_on
entity_id: script.heater_ak_on
- service: notify.se_ak_mv
data_template:
message: 'Motorvärmare AK (-10°) är på i 2h från {{now().strftime("%H:%M:%S")}} Temp ute: {{ states.sensor.netatmo_utomhus_norra_husgaveln_temperature.state}}°C'
- service: notify.ios_ak
data_template:
message: 'Motorvärmaren (-10°) är på i 2h från {{now().strftime("%H:%M:%S")}} Temp ute: {{ states.sensor.netatmo_utomhus_norra_husgaveln_temperature.state}}°C'
- service: homeassistant.turn_off
entity_id: automation.heater_ak_minus_10, automation.heater_ak_plus_1, automation.heater_ak_plus_5
- alias: "heater ak plus 1"
initial_state: True
trigger:
- platform: time
minutes: '/5'
seconds: 2
condition:
condition: and
conditions:
- condition: numeric_state
entity_id: sensor.koket_utomhus_temperature
below: 1.0
- condition: template
value_template: '{{ ((now().strftime("%s") | int + 3600) | timestamp_custom("%H:%M")) == states.sensor.departuretime_ak.state }}'
action:
- service: script.turn_on
entity_id: script.heater_ak_on
- service: notify.se_ak_mv
data_template:
message: 'Motorvärmare Ak (+1°) är på i 1h från {{now().strftime("%H:%M:%S")}} Temp ute: {{ states.sensor.netatmo_utomhus_norra_husgaveln_temperature.state}}°C'
- service: homeassistant.turn_off
entity_id: automation.heater_ak_plus_1, automation.heater_ak_plus_5, automation.heater_ak_minus_10
- alias: "heater ak plus 5"
initial_state: True
trigger:
- platform: time
minutes: '/5'
seconds: 2
condition:
condition: and
conditions:
- condition: numeric_state
entity_id: sensor.koket_utomhus_temperature
below: 5.0
- condition: template
value_template: '{{ ((now().strftime("%s") | int + 1800) | timestamp_custom("%H:%M")) == states.sensor.departuretime_ak.state }}'
action:
- service: script.turn_on
entity_id: script.heater_ak_on
- service: notify.se_ak_mv
data_template:
message: 'Motorvärmare AK (+5°) är på i 30 min från {{now().strftime("%H:%M:%S")}} Temp ute: {{ states.sensor.netatmo_utomhus_norra_husgaveln_temperature.state}}°C'
- service: notify.ios_ak
data_template:
message: 'Motorvärmaren (+5°) är på i 30 min från {{now().strftime("%H:%M:%S")}} Temp ute: {{ states.sensor.netatmo_utomhus_norra_husgaveln_temperature.state}}°C'
- service: homeassistant.turn_off
entity_id: automation.heater_ak_plus_5, automation.heater_ak_plus_1, automation.heater_ak_minus_10
- alias: "heater ak enabled"
trigger:
platform: state
entity_id: input_number.heater_ak_hour, input_number.heater_ak_minutes
action:
- service: homeassistant.turn_on
entity_id:
- automation.heater_ak_minus_10
- automation.heater_ak_plus_1
- automation.heater_ak_plus_5
- alias: "heater ak off"
initial_state: False
trigger:
- platform: time
minutes: '/5'
seconds: 2
condition:
- condition: template
value_template: '{{ now().hour == (states.input_number.heater_ak_hour.state | round(0)) and now().minute == (states.input_number.heater_ak_minutes.state | round(0) ) }}'
action:
- service: homeassistant.turn_off
entity_id: switch.papperslampan, automation.heater_ak_off
- service: notify.se_ak_mv
data_template:
message: 'Motorvärmare AK Stängs nu av {{now().strftime("%H:%M:%S")}} Temp ute: {{ states.sensor.netatmo_utomhus_norra_husgaveln_temperature.state}}°C'