Skip to content

Commit

Permalink
Sun to trigger only when state changes
Browse files Browse the repository at this point in the history
Previously it was triggering with any change to any attribute, causing it to trigger every 4min with `elevation` attribute changing.

Solves #2387
  • Loading branch information
edwardtfn committed Nov 20, 2024
1 parent dff45c6 commit f946429
Showing 1 changed file with 10 additions and 23 deletions.
33 changes: 10 additions & 23 deletions nspanel_blueprint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3859,6 +3859,14 @@ trigger_variables:
group05: !input utilities_page01_group05_line_reference
group06: !input utilities_page01_group06_line_reference

sun_entity: !input sun_entity
sun_is_up: >
{{
is_state(sun_entity, "above_horizon")
if sun_entity is string and sun_entity.split("sun.") | count == 2 and has_value(sun_entity)
else true
}}

variables:
blueprint_version: 4.4.0.dev6
pages:
Expand Down Expand Up @@ -4584,8 +4592,8 @@ triggers:
event_data:
entity_id: !input weather_entity
- id: sun_state_change # Sun changed
trigger: state
entity_id: !input sun_entity
trigger: template
value_template: '{{ sun_is_up }}'

- triggers: # Others
- id: qrcode_changed # QR Code changed
Expand Down Expand Up @@ -4711,27 +4719,6 @@ actions:
else "%A, " ~ date_format_temp
}}

sun_entity_input: !input sun_entity
sun_entity: >
{{
sun_entity_input
if
sun_entity_input is string and
sun_entity_input.split("sun.") | count == 2
else
(
(states.sun | map(attribute="entity_id") | list | first)
if states.sun | selectattr("entity_id", "defined") | list | count > 0
else None
)
}}
sun_is_up: >
{{
is_state(sun_entity, "above_horizon")
if sun_entity is string and sun_entity.split("sun.") | count == 2 and has_value(sun_entity)
else true
}}

# yamllint disable rule:line-length rule:braces
device_class_icons:
cover: { "awning-closed": "window-closed", "awning-closing": "arrow-down-box", "awning-open": "window-open", "awning-opening": "arrow-up-box", "blind-closed": "blinds-horizontal-closed", "blind-closing": "arrow-down-box", "blind-open": "blinds-horizontal", "blind-opening": "arrow-up-box", "curtain-closed": "curtains-closed", "curtains-closing": "arrow-collapse-horizontal", "curtains-open": "curtains-open", "arrow-split-vertical": "curtains-open", "damper-closed": "circle-slice-8", "damper-closing": "circle", "damper-open": "circle", "damper-opening": "circle", "door-closed": "door-closed", "door-closing": "door-open", "door-open": "door-open", "door-opening": "door-open", "garage-closed": "garage", "garage-closing": "arrow-down-box", "garage-open": "garage-open", "garage-opening": "arrow-up-box", "gate-closed": "gate", "gate-closing": "gate-arrow-right", "gate-open": "gate-open", "gate-opening": "gate-arrow-left", "shade-closed": "roller-shade-closed", "shade-closing": "arrow-down-box", "shade-open": "roller-shade", "shade-opening": "arrow-up-box", "shutter-closed": "window-shutter", "shutter-closing": "arrow-down-box", "shutter-open": "window-shutter-open", "shutter-opening": "arrow-up-box", "window-closed": "window-closed", "window-closing": "arrow-down-box", "window-open": "window-open", "window-opening": "arrow-up-box" }
Expand Down

0 comments on commit f946429

Please sign in to comment.