mbootsman
(Marcel Bootsman)
September 20, 2024, 11:22am
1
Hi,
I want to use a custom template to trigger when the current time equals the time of the sensor. I am not sure what the format of this sensor is, so I need to echo the output to check it so I know what date format should be used to compare it with the current time.
How can I echo the sensor.energyzero_today_energy_lowest_price_time
?
Custom template code:
{{states('sensor.energyzero_today_energy_lowest_price_time') == now().strftime("%H:%M")}}
petro
(Petro)
September 20, 2024, 11:28am
2
What is the output of this sensor?
If it’s a datetime sensor, you simple use a time trigger. No template needed.
- platform: time
at: sensor.energyzero_today_energy_lowest_price_time
mbootsman
(Marcel Bootsman)
September 20, 2024, 11:31am
3
Thanks @petro , the sensor returns ‘2024-09-20T11:00:00+00:00’, just checked in the template editor.
petro
(Petro)
September 20, 2024, 11:31am
4
Yep, then all you need is the trigger I provided above. You have to use yaml mode in the UI to use it.
mbootsman
(Marcel Bootsman)
September 20, 2024, 11:35am
5
Oh yes, I created this:
alias: Turn plug on at lowest energy cost time
description: ""
trigger:
- platform: time
at: sensor.energyzero_today_energy_lowest_price_time
condition: []
action:
- type: turn_on
device_id: d9454ac7daf6b8b05f7642b9127c841b
entity_id: 379687fb3908dd19ad6b15836652b905
domain: switch
- action: notify.mobile_app_cph2663
metadata: {}
data:
message: Lowesrt energy cost - Plug turned on
mode: single