Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 22 additions & 15 deletions homeassistant/components/samsungtv/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,15 @@
SamsungTVWSBridge,
)
from homeassistant.config_entries import SOURCE_REAUTH, ConfigEntry
from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME, STATE_OFF, STATE_ON
from homeassistant.const import (
ATTR_CONNECTIONS,
ATTR_IDENTIFIERS,
CONF_HOST,
CONF_MAC,
CONF_NAME,
STATE_OFF,
STATE_ON,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_component
import homeassistant.helpers.config_validation as cv
Expand Down Expand Up @@ -115,6 +123,19 @@ def __init__(
self._bridge = bridge
self._auth_failed = False
self._bridge.register_reauth_callback(self.access_denied)
self._attr_device_info = DeviceInfo(
Comment thread
tkdrob marked this conversation as resolved.
Outdated
name=self.name,
manufacturer=self._manufacturer,
model=self._model,
)
if self._mac:
self._attr_device_info[ATTR_CONNECTIONS] = {
(CONNECTION_NETWORK_MAC, self._mac)
}
if config_entry.unique_id:
self._attr_device_info[ATTR_IDENTIFIERS] = {
(DOMAIN, config_entry.unique_id)
}

def access_denied(self) -> None:
"""Access denied callback."""
Expand Down Expand Up @@ -180,20 +201,6 @@ def available(self) -> bool:
or self._power_off_in_progress()
)

@property
def device_info(self) -> DeviceInfo | None:
"""Return device specific attributes."""
info: DeviceInfo = {
"name": self.name,
"manufacturer": self._manufacturer,
"model": self._model,
}
if self.unique_id:
info["identifiers"] = {(DOMAIN, self.unique_id)}
if self._mac:
info["connections"] = {(CONNECTION_NETWORK_MAC, self._mac)}
return info

@property
def is_volume_muted(self) -> bool:
"""Boolean if volume is currently muted."""
Expand Down
33 changes: 15 additions & 18 deletions homeassistant/components/screenlogic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers import device_registry as dr
from homeassistant.helpers.debounce import Debouncer
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.typing import ConfigType
from homeassistant.helpers.update_coordinator import (
CoordinatorEntity,
Expand Down Expand Up @@ -183,6 +184,20 @@ def __init__(self, coordinator, data_key, enabled=True):
super().__init__(coordinator)
self._data_key = data_key
self._enabled_default = enabled
controller_type = self.config_data["controller_type"]
hardware_type = self.config_data["hardware_type"]
try:
equipment_model = EQUIPMENT.CONTROLLER_HARDWARE[controller_type][
hardware_type
]
except KeyError:
equipment_model = f"Unknown Model C:{controller_type} H:{hardware_type}"
self._attr_device_info = DeviceInfo(
Comment thread
tkdrob marked this conversation as resolved.
Outdated
connections={(dr.CONNECTION_NETWORK_MAC, self.mac)},
manufacturer="Pentair",
model=equipment_model,
name=self.gateway_name,
)

@property
def entity_registry_enabled_default(self):
Expand Down Expand Up @@ -214,24 +229,6 @@ def gateway_name(self):
"""Return the configured name of the gateway."""
return self.gateway.name

@property
def device_info(self):
"""Return device information for the controller."""
controller_type = self.config_data["controller_type"]
hardware_type = self.config_data["hardware_type"]
try:
equipment_model = EQUIPMENT.CONTROLLER_HARDWARE[controller_type][
hardware_type
]
except KeyError:
equipment_model = f"Unknown Model C:{controller_type} H:{hardware_type}"
return {
"connections": {(dr.CONNECTION_NETWORK_MAC, self.mac)},
"name": self.gateway_name,
"manufacturer": "Pentair",
"model": equipment_model,
}


class ScreenLogicCircuitEntity(ScreenlogicEntity):
"""ScreenLogic circuit entity."""
Expand Down
14 changes: 7 additions & 7 deletions homeassistant/components/sharkiq/vacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,15 @@ def model(self) -> str:
@property
def device_info(self) -> DeviceInfo:
"""Device info dictionary."""
return {
"identifiers": {(DOMAIN, self.serial_number)},
"name": self.name,
"manufacturer": SHARK,
"model": self.model,
"sw_version": self.sharkiq.get_property_value(
return DeviceInfo(
identifiers={(DOMAIN, self.serial_number)},
manufacturer=SHARK,
model=self.model,
name=self.name,
sw_version=self.sharkiq.get_property_value(
Properties.ROBOT_FIRMWARE_VERSION
),
}
)

@property
def supported_features(self) -> int:
Expand Down
26 changes: 9 additions & 17 deletions homeassistant/components/shelly/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,9 @@ def __init__(self, wrapper: BlockDeviceWrapper, block: Block) -> None:
self.wrapper = wrapper
self.block = block
self._name = get_block_entity_name(wrapper.device, block)
self._attr_device_info = DeviceInfo(
connections={(device_registry.CONNECTION_NETWORK_MAC, wrapper.mac)}
)

@property
def name(self) -> str:
Expand All @@ -293,13 +296,6 @@ def should_poll(self) -> bool:
"""If device should be polled."""
return False

@property
def device_info(self) -> DeviceInfo:
"""Device info."""
return {
"connections": {(device_registry.CONNECTION_NETWORK_MAC, self.wrapper.mac)}
}

@property
def available(self) -> bool:
"""Available."""
Expand Down Expand Up @@ -348,9 +344,9 @@ def __init__(self, wrapper: RpcDeviceWrapper, key: str) -> None:
self.wrapper = wrapper
self.key = key
self._attr_should_poll = False
self._attr_device_info = {
"connections": {(device_registry.CONNECTION_NETWORK_MAC, wrapper.mac)}
}
self._attr_device_info = DeviceInfo(
connections={(device_registry.CONNECTION_NETWORK_MAC, wrapper.mac)}
)
self._attr_unique_id = f"{wrapper.mac}-{key}"
self._attr_name = get_rpc_entity_name(wrapper.device, key)

Expand Down Expand Up @@ -494,19 +490,15 @@ def __init__(
self.description = description
self._name = get_block_entity_name(wrapper.device, None, self.description.name)
self._last_value = None
self._attr_device_info = DeviceInfo(
connections={(device_registry.CONNECTION_NETWORK_MAC, wrapper.mac)}
)

@property
def name(self) -> str:
"""Name of sensor."""
return self._name

@property
def device_info(self) -> DeviceInfo:
"""Device info."""
return {
"connections": {(device_registry.CONNECTION_NETWORK_MAC, self.wrapper.mac)}
}

@property
def entity_registry_enabled_default(self) -> bool:
"""Return if it should be enabled by default."""
Expand Down
16 changes: 8 additions & 8 deletions homeassistant/components/sma/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,18 +200,18 @@ def unique_id(self) -> str:
)

@property
def device_info(self) -> DeviceInfo:
def device_info(self) -> DeviceInfo | None:
"""Return the device information."""
if not self._device_info:
return None

return {
"identifiers": {(DOMAIN, self._config_entry_unique_id)},
"name": self._device_info["name"],
"manufacturer": self._device_info["manufacturer"],
"model": self._device_info["type"],
"sw_version": self._device_info["sw_version"],
}
return DeviceInfo(
identifiers={(DOMAIN, self._config_entry_unique_id)},
manufacturer=self._device_info["manufacturer"],
model=self._device_info["type"],
name=self._device_info["name"],
sw_version=self._device_info["sw_version"],
)

@property
def entity_registry_enabled_default(self) -> bool:
Expand Down
33 changes: 17 additions & 16 deletions homeassistant/components/smappee/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
DEVICE_CLASS_PRESENCE,
BinarySensorEntity,
)
from homeassistant.helpers.entity import DeviceInfo

from .const import DOMAIN

Expand Down Expand Up @@ -71,15 +72,15 @@ def unique_id(
)

@property
def device_info(self):
def device_info(self) -> DeviceInfo:
"""Return the device info for this binary sensor."""
return {
"identifiers": {(DOMAIN, self._service_location.device_serial_number)},
"name": self._service_location.service_location_name,
"manufacturer": "Smappee",
"model": self._service_location.device_model,
"sw_version": self._service_location.firmware_version,
}
return DeviceInfo(
identifiers={(DOMAIN, self._service_location.device_serial_number)},
manufacturer="Smappee",
model=self._service_location.device_model,
name=self._service_location.service_location_name,
sw_version=self._service_location.firmware_version,
)

async def async_update(self):
"""Get the latest data from Smappee and update the state."""
Expand Down Expand Up @@ -154,15 +155,15 @@ def unique_id(
)

@property
def device_info(self):
def device_info(self) -> DeviceInfo:
"""Return the device info for this binary sensor."""
return {
"identifiers": {(DOMAIN, self._service_location.device_serial_number)},
"name": self._service_location.service_location_name,
"manufacturer": "Smappee",
"model": self._service_location.device_model,
"sw_version": self._service_location.firmware_version,
}
return DeviceInfo(
identifiers={(DOMAIN, self._service_location.device_serial_number)},
manufacturer="Smappee",
model=self._service_location.device_model,
name=self._service_location.service_location_name,
sw_version=self._service_location.firmware_version,
)

async def async_update(self):
"""Get the latest data from Smappee and update the state."""
Expand Down
17 changes: 9 additions & 8 deletions homeassistant/components/smappee/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
ENERGY_WATT_HOUR,
POWER_WATT,
)
from homeassistant.helpers.entity import DeviceInfo

from .const import DOMAIN

Expand Down Expand Up @@ -372,15 +373,15 @@ def unique_id(self):
)

@property
def device_info(self):
def device_info(self) -> DeviceInfo:
"""Return the device info for this sensor."""
return {
"identifiers": {(DOMAIN, self._service_location.device_serial_number)},
"name": self._service_location.service_location_name,
"manufacturer": "Smappee",
"model": self._service_location.device_model,
"sw_version": self._service_location.firmware_version,
}
return DeviceInfo(
identifiers={(DOMAIN, self._service_location.device_serial_number)},
manufacturer="Smappee",
model=self._service_location.device_model,
name=self._service_location.service_location_name,
sw_version=self._service_location.firmware_version,
)

async def async_update(self):
"""Get the latest data from Smappee and update the state."""
Expand Down
17 changes: 9 additions & 8 deletions homeassistant/components/smappee/switch.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Support for interacting with Smappee Comport Plugs, Switches and Output Modules."""
from homeassistant.components.switch import SwitchEntity
from homeassistant.helpers.entity import DeviceInfo

from .const import DOMAIN

Expand Down Expand Up @@ -148,15 +149,15 @@ def unique_id(
)

@property
def device_info(self):
def device_info(self) -> DeviceInfo:
"""Return the device info for this switch."""
return {
"identifiers": {(DOMAIN, self._service_location.device_serial_number)},
"name": self._service_location.service_location_name,
"manufacturer": "Smappee",
"model": self._service_location.device_model,
"sw_version": self._service_location.firmware_version,
}
return DeviceInfo(
identifiers={(DOMAIN, self._service_location.device_serial_number)},
name=self._service_location.service_location_name,
manufacturer="Smappee",
model=self._service_location.device_model,
sw_version=self._service_location.firmware_version,
)

async def async_update(self):
"""Get the latest data from Smappee and update the state."""
Expand Down
18 changes: 7 additions & 11 deletions homeassistant/components/smartthings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
async_dispatcher_connect,
async_dispatcher_send,
)
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.entity import DeviceInfo, Entity
from homeassistant.helpers.event import async_track_time_interval
from homeassistant.helpers.typing import ConfigType

Expand Down Expand Up @@ -409,6 +409,12 @@ def __init__(self, device: DeviceEntity) -> None:
"""Initialize the instance."""
self._device = device
self._dispatcher_remove = None
self._attr_device_info = DeviceInfo(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a functional change, things like name won't update anymore. Was this intentional?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have smartthings and my testing confirms integration is functional as before except for the obvious, no name updates.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But that is intentional?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, @andrewsayre as the codeowner of the smartthings integration, do you agree?

identifiers={(DOMAIN, device.device_id)},
manufacturer="Unavailable",
model=device.device_type_name,
name=device.label,
)

async def async_added_to_hass(self):
"""Device added to hass."""
Expand All @@ -427,16 +433,6 @@ async def async_will_remove_from_hass(self) -> None:
if self._dispatcher_remove:
self._dispatcher_remove()

@property
def device_info(self):
"""Get attributes about the device."""
return {
"identifiers": {(DOMAIN, self._device.device_id)},
"name": self._device.label,
"model": self._device.device_type_name,
"manufacturer": "Unavailable",
}

@property
def name(self) -> str:
"""Return the name of the device."""
Expand Down
Loading