Hello! I am trying to set up a sensor or something of that sort that will show the time a device/entity turned off and on. I have found some help and it worked for a little bit but I am not sure why everything is not working. Basically, I have setup a dashboard for my fish tanks. I want to see what time the device turned off and what time it turned on.
This is what I have in my sensors.yaml
- platform: history_stats
name: Blackwater Air Pump On
entity_id: switch.blackwater_air_pump
state: 'on'
type: time
end: "{{ now().replace(hour=0, minute=0, second=0) }}"
duration:
hours: 24
- platform: history_stats
name: Blackwater Air Pump Off
entity_id: switch.blackwater_air_pump
state: 'off'
type: time
end: "{{ now().replace(hour=0, minute=0, second=0) }}"
duration:
hours: 24
This is what I had in my templates.yaml (not sure where this should actually go)
- trigger:
- platform: state
entity_id: switch.blackwater_air_pump
to: 'on'
- sensor:
- name: Blackwater Air Pump On
state: "{{ now().timestamp() | timestamp_custom('%I:%M %p %a') }} "
- trigger:
- platform: state
entity_id: switch.blackwater_air_pump
to: 'off'
- sensor:
- name: Blackwater Air Pump Off
state: "{{ now().timestamp() | timestamp_custom('%I:%M %p %a') }} "
Full disclosure I am not very good at this coding business. I have come really far but still this stuff gets me lost. Any help appreciated or if there is a less bulky way that would also be great! thanks!
1 post - 1 participant