How can I get some information from a switch entity?

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
  - 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

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

Do I need to pick a Unit or a State Class?

Then use that in the UI.

how exactly do I use them?

No unit or stateclass.

You just use the new entity in the UI in your entities card.

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) }}

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…