Add model_id to device info (#2251)

This commit is contained in:
Joost Lekkerkerker 2024-07-16 15:13:21 +02:00 committed by GitHub
parent 20c58b1128
commit 9f616cd5d7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 33 additions and 20 deletions

View File

@ -0,0 +1,10 @@
---
author: Joost Lekkerkerker
authorURL: https://github.com/joostlek
authorImageURL: https://avatars.githubusercontent.com/u/7083755?v=4
title: "model_id added to DeviceInfo"
---
Starting from 2024.8, you can now add a model identifier to the `DeviceInfo` class. This identifier can be used to identify the device model in integrations and the frontend.
For example, the Philips Hue ambiance spot was previously listed as "Hue ambiance spot (LTG002)". This can now be split up, where the `model` is "Hue ambiance spot" and the `model_id` is "LTG002".

View File

@ -23,27 +23,28 @@ Although not currently available, we could consider offering an option to users
## Device properties
| Attribute | Description |
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| area_id | The Area which the device is placed in. |
| config_entries | Config entries that are linked to this device. |
| configuration_url | A URL on which the device or service can be configured, linking to paths inside the Home Assistant UI can be done by using `homeassistant://<path>`. |
| Attribute | Description |
|----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| area_id | The Area which the device is placed in. |
| config_entries | Config entries that are linked to this device. |
| configuration_url | A URL on which the device or service can be configured, linking to paths inside the Home Assistant UI can be done by using `homeassistant://<path>`. |
| connections | A set of tuples of `(connection_type, connection identifier)`. Connection types are defined in the device registry module. Each item in the set uniquely defines a device entry, meaning another device can't have the same connection. |
| default_manufacturer | The manufacturer of the device, will be overridden if `manufacturer` is set. Useful for example for an integration showing all devices on the network. |
| default_model | The model of the device, will be overridden if `model` is set. Useful for example for an integration showing all devices on the network. |
| default_name | Default name of this device, will be overridden if `name` is set. Useful for example for an integration showing all devices on the network. |
| entry_type | The type of entry. Possible values are `None` and `DeviceEntryType` enum members (only `service`). |
| hw_version | The hardware version of the device. |
| id | Unique ID of device (generated by Home Assistant) |
| default_manufacturer | The manufacturer of the device, will be overridden if `manufacturer` is set. Useful for example for an integration showing all devices on the network. |
| default_model | The model of the device, will be overridden if `model` is set. Useful for example for an integration showing all devices on the network. |
| default_name | Default name of this device, will be overridden if `name` is set. Useful for example for an integration showing all devices on the network. |
| entry_type | The type of entry. Possible values are `None` and `DeviceEntryType` enum members (only `service`). |
| hw_version | The hardware version of the device. |
| id | Unique ID of device (generated by Home Assistant) |
| identifiers | Set of `(DOMAIN, identifier)` tuples. Identifiers identify the device in the outside world. An example is a serial number. Each item in the set uniquely defines a device entry, meaning another device can't have the same identifier. |
| name | Name of this device |
| name_by_user | The user configured name of the device. |
| manufacturer | The manufacturer of the device. |
| model | The model of the device. |
| serial_number | The serial number of the device. Unlike a serial number in the `identifiers` set, this does not need to be unique. |
| suggested_area | The suggested name for the area where the device is located. |
| sw_version | The firmware version of the device. |
| via_device | Identifier of a device that routes messages between this device and Home Assistant. Examples of such devices are hubs, or parent devices of a sub-device. This is used to show device topology in Home Assistant. |
| name | Name of this device |
| name_by_user | The user configured name of the device. |
| manufacturer | The manufacturer of the device. |
| model | The model name of the device. |
| model_id | The model identifier of the device. |
| serial_number | The serial number of the device. Unlike a serial number in the `identifiers` set, this does not need to be unique. |
| suggested_area | The suggested name for the area where the device is located. |
| sw_version | The firmware version of the device. |
| via_device | Identifier of a device that routes messages between this device and Home Assistant. Examples of such devices are hubs, or parent devices of a sub-device. This is used to show device topology in Home Assistant. |
## Defining devices
@ -68,6 +69,7 @@ class HueLight(LightEntity):
name=self.name,
manufacturer=self.light.manufacturername,
model=self.light.productname,
model_id=self.light.modelid,
sw_version=self.light.swversion,
via_device=(hue.DOMAIN, self.api.bridgeid),
)
@ -92,7 +94,8 @@ device_registry.async_get_or_create(
manufacturer="Signify",
suggested_area="Kitchen",
name=config.name,
model=config.modelid,
model=config.modelname,
model_id=config.modelid,
sw_version=config.swversion,
hw_version=config.hwversion,
)