Closed n00bster-za closed 2 years ago
This is what I'm using currently. It's a bit messy at the moment. Will move the logic into the integration at some point so that I don't need the template conditions.
type: entities
entities:
- type: custom:template-entity-row
icon: mdi:lightning-bolt-outline
name: Status
state: '{{states(''sensor.load_shedding_milnerton'')}}'
active: '{{ not is_state(''sensor.load_shedding_milnerton'', ''No Load Shedding'') }}'
- type: custom:template-entity-row
icon: mdi:timer-outline
name: Milnerton
state: >-
{{ state_attr('sensor.load_shedding_milnerton', 'next_start') |
as_timestamp | timestamp_custom("%H:%M") }} - {{
state_attr('sensor.load_shedding_milnerton', 'next_end' ) | as_timestamp |
timestamp_custom("%H:%M") }}
secondary: >-
{% if state_attr('sensor.load_shedding_milnerton', 'next_start') != None
%}
{% set next_start = state_attr("sensor.load_shedding_milnerton", "next_start") | as_datetime - now().strftime("%Y-%m-%d %H:%M%z") | as_datetime %}
{% set next_end = state_attr("sensor.load_shedding_milnerton", "next_end") | as_datetime - now().strftime("%Y-%m-%d %H:%M%z") | as_datetime %}
{% if next_start.total_seconds() > 0 %}Starts in {{ next_start.total_seconds() | timestamp_custom("%Hh%M", False) }}{% else %}Ends in {{ next_end.total_seconds() | timestamp_custom("%Hh%M", False) }}{% endif %}
{% else %}{% endif %}
condition: '{{ not is_state(''sensor.load_shedding_milnerton'', ''No Load Shedding'') }}'
entity: sensor.load_shedding_milnerton
Cleaned up the interface. Will be available in next release.
I have no experience in coding but is there a way to clean up the "next time" date/time
Don't want to see the time zone. Maybe have the date and time stacked on top of each other or separated a bit somehow.
Also once load shedding is suspended the timers are still there. No way to make them empty if there is no load shedding stage.
Also I have added the automation if the stage changes but it does not notify if it's suspended.