Add IP address as an entity or as an attribute for Shelly Device

Thanks, this is working great for me!

I managed to use the construct device_attr('my_entity_id', 'configuration_url') successfully within auto-entities + template-entity-row to show the IP addresses of all my Shelly devices with very few lines of YAML. If you copy this, don’t forget to adapt the line - entity_id: /switch.mini/ to match the naming convention of your shellies:

type: custom:auto-entities
card:
  type: entities
  title: Shelly
  show_header_toggle: false
filter:
  include:
    - entity_id: /switch.mini/
      options:
        type: custom:template-entity-row
        toggle: true
        secondary: >-
          {{ device_attr('this.entity_id', 'configuration_url') |
          replace('http://','') | replace(':80','') }}

UPDATE:

Here is a new version that uses device_attr() not only to add the IP address as a secondary info, but also to find all my Shellies using a filter template with a for loop. The advantage of this version is that it does not rely on any special naming pattern in the entity_id like the version above does. Instead it uses a generic device_attr(e.entity_id, 'manufacturer') == "Shelly" to find all Shelly devices.

So this should basically work through copy&paste for everyone.

type: custom:auto-entities
card:
  type: entities
  title: Shelly
  show_header_toggle: false
sort:
  method: name
  ignore_case: true
filter:
  template: |
    [
      {% for e in states %}
        {% 
          if  device_attr(e.entity_id, 'manufacturer') == "Shelly" 
          and (
            "switch." in e.entity_id
            or "light." in e.entity_id
            or "cover." in e.entity_id
          )
        %}
          {
            "type": "custom:template-entity-row",
            "toggle": "true",
            "entity": "{{ e.entity_id }}",
            "secondary": 
              "{{ device_attr(e.entity_id, 'configuration_url') |
              replace('http://','') | replace(':80','') }}"
          },

        {% endif %}
      {% endfor %}
    ]

Hint:
All possible second arguments for device_attr() can be found here:

6 Likes