Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Monitor only devices from a specific integration #16

Closed
Schnabulation opened this issue Jul 7, 2022 · 9 comments
Closed

Comments

@Schnabulation
Copy link

I was wondering if it is feasable to monitor only devices within a specific integration.
As I would like to only monitor my ZigBee devices that would be all devices from the "deCONZ" integration.
I don't know if this value is represented in the entities itself.

I know I would be able to add these devices to a group and then interate through this group but I actually would like to have all ZigBee devices automatically added to this sensor.

Thanks for your help!

@bcutter
Copy link

bcutter commented Jul 7, 2022

Basically this should be quite easy to implement, just a filter required.

But forget about ZigBee devices integrated using deCONZ.

deCONZ only reports devices as unavailable (e. g. battery dead) after 24 hours of missing status updates. See https://forum.phoscon.de/t/inacceptable-huge-default-sensor-unavailable-time-of-24-hours/1592.

That's complete crap and forces us to think about better monitoring approaches not based on the deCONZ integration itself. Like this idea:

#11

@Schnabulation
Copy link
Author

Could you maybe provide me with a filter for integration? Because the integration is not published as an attribute of the entity as far as I know. That‘s why I was asking here.

Regarding deCONZ: yes I know. But it‘s still better to have a notification after 24h than none at all.

@jazzyisj
Copy link
Owner

jazzyisj commented Jul 9, 2022

@bcutter

Basically this should be quite easy to implement, just a filter required.

I know you can filter/sort by integration in the front end, but I've never found a way to do this with a template. As far as I know there is no jinja filter or test for an entities parent integration. If you have the secret sauce for this please share!

@jazzyisj
Copy link
Owner

jazzyisj commented Jul 9, 2022

@Schnabulation If you look at the thread @bcutter posted I gave a couple of examples there of how to filter out entities for an integration. Easiest way - just add the integration's entities to your ignored entities group manually.

Wish I had a better answer.

@Schnabulation
Copy link
Author

If you have the secret sauce for this please share!

I was actually hoping you might.

But nevermind, seems like this is not possible with the current implementation of integrations. I'll close this ticket. Thanks again for your great work!

@bcutter
Copy link

bcutter commented Jul 14, 2022

@bcutter

Basically this should be quite easy to implement, just a filter required.

I know you can filter/sort by integration in the front end, but I've never found a way to do this with a template. As far as I know there is no jinja filter or test for an entities parent integration. If you have the secret sauce for this please share!

Well for another usecase I use e. g.:

{{ integration_entities('deconz') | list | length }}

(which gives the number of entities for the deCONZ integration)

That should be something to work with right?

@jazzyisj
Copy link
Owner

That should be something to work with right?

@bcutter Absolutely! Well I'll be damned. I have never seen that anywhere. It works perfectly. I'm going to add a little note in the README when I get a minute to document this.

Any chance you know where that is documented in the HA docs? I did a quick search on the forum and I can't even find anyone using this function on there.

@Schnabulation try this template out. Replace "alarmo" with the integration you want to monitor.

            {% set ignore_seconds = 60 %}
            {% set ignored = state_attr('group.ignored_unavailable_entities','entity_id') %}
            {% set ignore_ts = (now().timestamp() - ignore_seconds)|as_datetime %}
            {% set entities = expand(integration_entities('alarmo'))
                |rejectattr('last_changed','ge',ignore_ts)
                |selectattr('state','in',['unavailable','unknown']) %}
            {% if ignored != none %}
              {% set entities =  entities|rejectattr('entity_id','in',ignored) %}
            {% endif %}
            {{ entities|map(attribute='entity_id')|list }}

@bcutter
Copy link

bcutter commented Jul 14, 2022

Any chance you know where that is documented in the HA docs? I did a quick search on the forum and I can't even find anyone using this function on there.

No unfortunately I don't. I came across this at the beginning of this year during research for my statistics project (before that I had to use command line instead of template sensors to manually search in the entity / devices registry file).

I think someone on the forums or another HA community noted it - there are a few topics using this on the HA forum. But no official documentation (which is strange and makes me think "Well, maybe there are another great filters out there?" 🤷🏻‍♂️) 🫤

@Schnabulation
Copy link
Author

Hot damn you guys are awesome! I have adjusted the templated as you mentioned (replaced alarmo with deconz) and this works absolutely perfectly.

I have even tried to shutdown the deCONZ plugin and after the set 60 seconds all deCONZ entities have been displayed in the sensor.

Very nice work you guys!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants