Giter Site home page Giter Site logo

Comments (5)

teskanoo avatar teskanoo commented on September 17, 2024

Power calc entities are added to existing devices
integration_entities('powercalc') will return all entities set up by powercalc
device_attr(entity, 'identifiers') will return a list of all identifiers related to the entity (this would be the identifier linked to the entity's original device)
to skip the identidiers belonging to the entities in the groups, you may have to try...

{% set pwr_entities=integration_entities('powercalc') %}
{%- for entity in pwr_entities %}
{%- set ids = device_attr(entity, 'identifiers') %}
{%- if ids is not none %}
    {{ entity }}
    {{ device_attr(entity, 'identifiers')  }}
{%- endif %}
{% endfor %}

You may also be able to expand the groups and iterate over the entities in that group
{%- set group_entities = entity |expand|map(attribute='entity_id') %}

from homeassistant-powercalc.

erkr avatar erkr commented on September 17, 2024

Hi @teskanoo
I really appreciate your quick reply 😊
I realize some extra background should have been helpfully.

I wrote a template to list unavailable devices. That became more complicated than I originally anticipated, two challenges, the first one I tackled, the second I'm looking into 😅

Basically a device is defined unavailable when all device related entities are unavailable, with some exceptions.

1: some devices have a status entity of device_class connectivity. That entity will remain available (in problem state).

2: Sorry for the long intro, but here I found out that some devices were extended with Powercalc entities. Those can remain available as well, depending the configuration for unavailable.

But I now understand you extent them on purpose. So maybe I have to rethink my approach.

Update: the real issue is that I don't now a decent way to list all integrations. So the approach starts with looking up the integrations for all entities (via the device attribute identifiers).

from homeassistant-powercalc.

erkr avatar erkr commented on September 17, 2024

As this seems a deliberate choice, with well thought reasons, you are free to close the issue 🤓

from homeassistant-powercalc.

bramstroker avatar bramstroker commented on September 17, 2024

Yes, Powercalc entities are connected to same device as the source entitity, and this is one of the key features of Powercalc.

You might want to retrieve all powercalc entities first in your template and assign those to a variable.
As @teskanoo mentioned: {% set pwr_entities=integration_entities('powercalc') %}
And then exclude these when determining availability for a device.

from homeassistant-powercalc.

erkr avatar erkr commented on September 17, 2024

As @teskanoo mentioned: {% set pwr_entities=integration_entities('powercalc') %}

And then exclude these when determining availability for a device.

Yes I have done that, my issue is solved😊 I close this issue now.
I just published the macro to share: https://community.home-assistant.io/t/a-sensor-to-list-unavailable-devices/684896/36

from homeassistant-powercalc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.