I’m trying to set up an automation which turn off my aircon at a time set using input_datetime.
I’ve copied the automation from others found on this forum, and I can’t see any reason it wouldn’t work.
I played around in the template editor and realised that for some reason the value_template line is calculating the input_datetime timestamp into the wrong time. i.e 01:43 is showing as 12:43, 15:03 shows as 02:05. Basically converts it to 13hrs before it should be.
If anyone knows why this is happening or how to fix it, I’d really appreciate the help.
Current Time: {{ states(‘sensor.time’)}} (Correct)
Input_datetime set to: {{states.input_datetime.aircon_set_time.state}} (Correct)
Timestamp attribute: {{states.input_datetime.aircon_set_time.attributes.timestamp}} (Correct)
Timestamp custom for comparing to current time: {{(states.input_datetime.aircon_set_time.attributes.timestamp | int | timestamp_custom(’%H:%M’, True))}} (False)
input_datetime:
aircon_set_time:
name: Aircon Time
has_time: true
automation:
- alias: Aircon Off at Set Time
trigger:
- platform: template
value_template: "{{ states('sensor.time') == (states.input_datetime.aircon_set_time.attributes.timestamp | int | timestamp_custom('%H:%M', True)) }}"
condition:
- condition: and
conditions:
- condition: state
entity_id: input_select.aircon_timer
state: 'Aircon Off'
- condition: state
entity_id: input_boolean.aircon_set_time
state: 'on'
action:
- service: switch.turn_off
entity_id: switch.aircon