reypm
June 11, 2024, 10:47am
1
I have a smart hose and am trying to configure a Lovelace card to display helpful information. This is all the information I can get from the sensor:
From there I would like to calculate the remaining irrigation time which if I am not mistaken is: current_time - started_watering_station_at.
I would also like to display the next watering time in a human-readable way, not like next_start_time: 2024-06-11T06:30:00-04:00
Can I get some help gathering this information from the entity and then adding it to my Lovelace configuration??
type: entities
entities:
- entity: switch.smart_hose_tap_timer_1_zone
- entity: switch.smart_hose_tap_timer_1_zone
name: Next 🕑
- entity: sensor.irrigation_zone1_remaining
name: Remaining ⏳
title: Zone 1 (Left Side of Home)
show_header_toggle: false
state_color: true
petro
(Petro)
June 11, 2024, 11:47am
2
you need to make a template sensor.
{{ state_attr('switch.smart_hose_tap_timer_1_zone', 'next_start_time') }}
choose timestamp as your sensor type, name it whatever. Then use that in the UI.
as for the ending time, do the same thing…
{% set start = state_attr('switch.smart_hose_tap_timer_1_zone', 'next_start_time') %}
{% set duration = state_attr('switch.smart_hose_tap_timer_1_zone', 'manual_preset_runtime') %}
{{ start + timedelta(seconds=duration) }}
Both will read as relative times. e.g. in 5 minutes
or 5 minutes ago
1 Like
reypm
June 11, 2024, 12:01pm
3
Do I need to pick a Unit or a State Class?
Then use that in the UI.
how exactly do I use them?
petro
(Petro)
June 11, 2024, 1:06pm
4
No unit or stateclass.
You just use the new entity in the UI in your entities card.
reypm
June 11, 2024, 2:08pm
5
yeah but … not sure how to use this on the entity, can you leave me some YAML example so I can learn?
{% set start = state_attr(‘switch.smart_hose_tap_timer_1_zone’, ‘next_start_time’) %}
{% set duration = state_attr(‘switch.smart_hose_tap_timer_1_zone’, ‘manual_preset_runtime’) %}
{{ start + timedelta(seconds=duration) }}
petro
(Petro)
June 11, 2024, 2:11pm
6
use a template entity… literally what you have above. Make the entity, then use that entity in your entities card. Just like how you selected the entties for this picture…