Skip to content
This repository has been archived by the owner on Nov 7, 2024. It is now read-only.

[Feature]: group entities to one device including additional sensors #130

Open
akatsuki-meigetsu opened this issue Jun 27, 2024 · 14 comments
Labels
enhancement New feature or request

Comments

@akatsuki-meigetsu
Copy link

Domain

No response

What is actually missing?

sensor is important in IoT, if matterbridge support sensor, we can use it to create more various automations in different platforms.

@t0bst4r
Copy link
Owner

t0bst4r commented Jun 28, 2024

@bassrock already started working on it (#118) for binary sensors.

what exactly are you missing? What kind of sensors? What values do they have? Can you provide their attributes?

@akatsuki-meigetsu
Copy link
Author

Like air quality sensor, temperature sensor, humidity sensor, I noticed Matterbridge could support this type sensor, thus hoping matterbridge-home-assistant plugin supporting them.

@t0bst4r
Copy link
Owner

t0bst4r commented Jun 30, 2024

@akatsuki-meigetsu
Basic support for binary sensors (occupancy, doors, contact sensors) was added by @bassrock in #118
We just merged it and it'll be released as 1.4.0 in some minutes.

@bassrock Let's proceed the sensor discussion over here.
The main problem is, that home assistant provides each entity on its own. At the moment we have no clue, if multiple entities are related to each other.
Actually... how does it work with apple homekit or alexa integrations?

@bassrock
Copy link
Contributor

@t0bst4r The homekit and alexa integrations use the device registry to grab all linked sensors/entities as needed for things like Battery state https://github.com/home-assistant/core/blob/dev/homeassistant/components/homekit/__init__.py#L1152

As far as I can tell, it looks like the homeassistant js websocket library doesn't support grabbing device ids or linked devices

@t0bst4r
Copy link
Owner

t0bst4r commented Jun 30, 2024

Okay, i am also using the device registry. So we could group entities by their related device and build matter-devices from those groups. But that's definetly a larger change 😁

@bassrock
Copy link
Contributor

Oh i totally missed that you are pulling that info! So probably in the bootup where things are ignored there needs to be a "linking" of sorts based on device id. Then the matter devices could get more hardware info, battery state, energy usage etc!

@akatsuki-meigetsu
Copy link
Author

I tested 1.5.0 version, however, it crushed on docker type Matterbridge(1.3.7), seemed caused by light.

@t0bst4r
Copy link
Owner

t0bst4r commented Jun 30, 2024

Just released a bug fix. Please test with 1.5.1

@akatsuki-meigetsu
Copy link
Author

now working successfully, thanks !

@t0bst4r
Copy link
Owner

t0bst4r commented Jul 2, 2024

Oh i totally missed that you are pulling that info! So probably in the bootup where things are ignored there needs to be a "linking" of sorts based on device id. Then the matter devices could get more hardware info, battery state, energy usage etc!

I just saw the deviceId in the data I get - so it would be possible. BUT how would we decide what kind of device (DeviceTypeDefinition) we have, when having a device with different entities? I don’t see a device type from home assistant…

Example 1: smart plug

  • switch.my_plug_power
  • lock.my_plug_button_lock
  • light.my_plug_indicator

Example 2: security camera

  • switch.my_camera_privacy
  • light.my_camera_night_light
  • switch.my_camera_night_vision
  • and like 15 more entities

and let’s not even think about media players.

i don’t think we can make it with patterns like „if it has those 5 entities“.
I would not parse entity_ids or especially not the friendly names. I would also try to keep this away from the user configuration…

This definitely needs further investigations.

@t0bst4r t0bst4r changed the title Feature request: sensor and binary_sensor Feature request: group entities to one device including additional sensors Jul 2, 2024
@t0bst4r t0bst4r changed the title Feature request: group entities to one device including additional sensors [ Feature ] group entities to one device including additional sensors Jul 2, 2024
@t0bst4r t0bst4r changed the title [ Feature ] group entities to one device including additional sensors [Feature]: group entities to one device including additional sensors Jul 2, 2024
@bassrock
Copy link
Contributor

bassrock commented Jul 2, 2024

Yea. In my experience you pick a base one, and add aspects/or other things together and matter or homekit will auto join it all. But it def needs testing

@t0bst4r
Copy link
Owner

t0bst4r commented Jul 3, 2024

Yea. In my experience you pick a base one, and add aspects/or other things together and matter or homekit will auto join it all. But it def needs testing

Yes, but how do we detect which is the base one?

@bassrock
Copy link
Contributor

bassrock commented Jul 3, 2024

I think thats done by looking at the primary identifiers field https://developers.home-assistant.io/docs/device_registry_index#categorizing-to-device-info

Looks like the HomeKit integration assumes the entities the user allowlists is the main one, and then they grab all the linked ones https://github.com/home-assistant/core/blob/dev/homeassistant/components/homekit/__init__.py#L1089

@t0bst4r
Copy link
Owner

t0bst4r commented Jul 3, 2024

i just noticed that i confused device registry and entity registry 🙃
so as of now, i am not querying those, but could also be an option to add it.

i am still not 100% sure about this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants