Skip to content

Commit

Permalink
Fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardtfn committed Jan 14, 2024
1 parent 45a56a4 commit b3543af
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions nspanel_blueprint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7360,14 +7360,17 @@ action:
{% elif entity_state in ["pending", "arming"] %}{{ all_icons["shield-outline"] }}
{% else %}{{ all_icons["shield-alert-outline"] }}
{% endif %}
{% elif entity_domain in ["binary_sensor", "cover", "sensor", "switch"] %}
{% elif
entity_domain in ["binary_sensor", "cover", "sensor", "switch"] and
entity_device_class is defined and entity_device_class is string and entity_device_class | length > 0 and
entity_state is defined and entity_state is string and entity_state | length > 0 %}
{% set entity_device_class_icon = entity_device_class + "-" + entity_state %}
{% set entity_device_class_icon = device_class_icons.[entity_domain][entity_cover_icon] if entity_device_class_icon in device_class_icons[entity_domain] else icon_domain %}
{% set entity_device_class_icon = device_class_icons[entity_domain][entity_cover_icon] if entity_device_class_icon in device_class_icons[entity_domain] else icon_domain %}
{{ all_icons[entity_device_class_icon] if entity_device_class_icon in all_icons else icon_domain }}
{% else %}
{{
all_icons[entity_icon.split(":")[1]] | default(icon_domain)
if entity_id_is_valid and entity_icon is string and entity_icon.split(":") | count == 2
all_icons[entity_icon.split(":")[1]]
if entity_id_is_valid and entity_icon is string and entity_icon.split(":") | count == 2 and entity_icon.split(":")[1] in all_icons
else icon_domain
}}
{% endif %}
Expand Down

4 comments on commit b3543af

@illuzn
Copy link
Contributor

@illuzn illuzn commented on b3543af Jan 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@edwardtfn This refactor makes sense but I think sensor needs to be handled separately. For sensors there is no "state" which changes the sensor icon. So it's just a simple lookup, e.g. my humidity sensor is of device_class moisture and should just return mdi:water-percent irrespective of what the state is. The logic for binary_sensor, cover and switch is sound because these icons change based upon state (in HA as well).

@edwardtfn
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My fault. 😬
I haven't seen your code was doing sensor in a different way. I will fix that.

Thanks again!

@edwardtfn
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this will solve that: b46ab6a

I will test more later.

@edwardtfn
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks nice...
🙂

Please sign in to comment.