#SamFox Start a thread and post some

1 messages · Page 1 of 1 (latest)

nimble forge
#

I'm realizing that template light is really what I want. I am not only using it in auto entities, it's just one place that I know I will need it. If I want this customization and I want it to be part of the entity itself wherever the entity is used the best idea I can find is template light. I know about button cards, etc. But those type of ideas present the ntity in a customized way. What I am trying to do is have the entity itslef be different. This is really only possible by creating a new entity, unfortunately.

remote solar
#

I don't see that as being a bad thing. All's it is doing is changing the switch entity to a light entity. I'm assuming it should act like a regular light at that point (in terms of light on/off, color, and temp states) and the icon assigned within the entity.

#

All these icons are set within the YAML for each custom:button-card. In each entity, however, they all just have lightbulb icons.

nimble forge
#

not bad at all. Just some more work to make each template.

remote solar
#

Changing the icon for the entity did change it in the auto-entity/custom:button-card. (Living Room 1)

remote solar
# nimble forge not bad at all. Just some more work to make each template.

The custom:button-cards are "templatable" so each button is only 4 lines (when calling the template).yaml - type: custom:button-card template: generic_custom_button entity: light.living_room1 icon: mdi:lamp - type: custom:button-card template: generic_custom_button entity: light.living_room2 icon: mdi:lamp

nimble forge
#

I want an 'on' icon and an 'off' icon.

remote solar
#

Example for custom:button-card.yaml icon: | [[[ if (states['input_boolean.tester'].state == "on") return 'phu:ikea-blind-closed'; if (states['input_boolean.tester'].state == "off") return 'phu:ikea-blind-open'; ]]]

nimble forge
#

but then if I cannot put it in a auto entities card that shows all lights that are on

remote solar
#

No, that code is for the custom:button-card. Again, the auto-entities cards are not designed for what you're trying to get it to do from within the card. For that, you may need to create a templated entity.

nimble forge
#

I did it. I made a template to build the templates for each of my switches/lights. I can fine tune each one manually. Now I have all these customized template lights in one yaml file so I can tweak them as needed in oone spot.

#

heres what I used:

light:
    {%set ns = namespace(list=[])%}
    {%- for entity in integration_entities('zwave_js') -%}
      {%- set state_obj = (expand(entity) | first | default(none)) -%}
      {%- if state_obj and state_obj.domain in ['light','switch'] -%}
    {%- set ns.list = ns.list+[entity] -%}
{%-set name = state_attr(entity, 'friendly_name') -%}
{%-set name_key = entity.split('.')[1]+'_template' -%}
{%-set entityid = entity %}
  - platform: template
    lights:
      {{name_key}}:
        friendly_name: "{{name}}"
        value_template: >- {% raw %}
          {% if is_state('{% endraw %}{{entityid}}{% raw %}', 'on') %}
              on
          {% else %}
            off
          {% endif %}
        icon_template: >-
          {% if is_state('{% endraw %}{{entityid}}{% raw %}', 'on') %}
              mdi:lightbulb-on-outline
          {% else %}
              mdi:lightbulb-outline
          {% endif %} {% endraw %}
        turn_on:
          service: homeassistant.turn_on
          target:
            entity_id: {{entityid}}
        turn_off:
          service: homeassistant.turn_off
          target:
            entity_id: {{entityid}}
    {%- endif %}
    {%-endfor%}