puttyman / hass-amplifi

A home assistant integration for Ubiquiti Amplifi
27 stars 16 forks source link

Connected to device attribute #41

Closed hawksj closed 3 months ago

hawksj commented 8 months ago

Appends a "connected_to" attribute to the list of attributes for the device_tracker entity

The format of info-async.php is such that each connected device is listed beneath the MAC address of the AP is it connected to. We can simply return this as we do with other attributes. This can then be used in a markdown card with a configuration such as:

Mesh Point 1
{% for item in (states.device_tracker
|selectattr('entity_id', 'match', 'device_tracker.amplifi.*')
|selectattr('state', 'eq', 'home')
|map(attribute='entity_id')) %}
{% if (state_attr(item,'connected_to') == 'f0:9f:c2:xx:xx:xx') %}
* {{ item.replace('device_tracker.amplifi_','') }} 
{% endif %}
{% endfor %}

which gives you a result such as: image

This is already merged in my fork and operating in my HA instance: image

This provides a solution #29 by triggering an automation based on the attributes of a device_tracker identity updating to the MAC address of the mesh point

hawksj commented 8 months ago

Ah, I forgot that this branch was forked from my master which was already several commits ahead of the original repo... my bad.

It's up to codeowners whether you want to merge all changes or I can re-create the PR with only the new device attribute changes.

This means this PR is a duplicate of #38 and #39.

hawksj commented 3 months ago

I'm not comfortable merging this after messing up my branches. I will close this PR and sync my fork once #44 is merged and replicate the changes.