Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
15 changes: 8 additions & 7 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 @@ -215,7 +216,7 @@ def gateway_name(self):
return self.gateway.name

@property
def device_info(self):
def device_info(self) -> DeviceInfo:
"""Return device information for the controller."""
controller_type = self.config_data["controller_type"]
hardware_type = self.config_data["hardware_type"]
Expand All @@ -225,12 +226,12 @@ def device_info(self):
]
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,
}
return DeviceInfo(
connections={(dr.CONNECTION_NETWORK_MAC, self.mac)},
manufacturer="Pentair",
model=equipment_model,
name=self.gateway_name,
)


class ScreenLogicCircuitEntity(ScreenlogicEntity):
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
14 changes: 5 additions & 9 deletions homeassistant/components/smarttub/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,17 @@ def __init__(
super().__init__(coordinator)
self.spa = spa
self._entity_name = entity_name
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, spa.id)},
manufacturer=spa.brand,
model=spa.model,
)

@property
def unique_id(self) -> str:
"""Return a unique id for the entity."""
return f"{self.spa.id}-{self._entity_name}"

@property
def device_info(self) -> DeviceInfo:
"""Return device info."""
return {
"identifiers": {(DOMAIN, self.spa.id)},
"manufacturer": self.spa.brand,
"model": self.spa.model,
}

@property
def name(self) -> str:
"""Return the name of the entity."""
Expand Down
9 changes: 5 additions & 4 deletions homeassistant/components/sms/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from homeassistant.components.sensor import SensorEntity, SensorEntityDescription
from homeassistant.const import DEVICE_CLASS_SIGNAL_STRENGTH, SIGNAL_STRENGTH_DECIBELS
from homeassistant.helpers.entity import DeviceInfo

from .const import DOMAIN, SMS_GATEWAY

Expand Down Expand Up @@ -39,10 +40,10 @@ class GSMSignalSensor(SensorEntity):

def __init__(self, hass, gateway, imei, description):
"""Initialize the GSM Signal sensor."""
self._attr_device_info = {
"identifiers": {(DOMAIN, str(imei))},
"name": "SMS Gateway",
}
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, str(imei))},
name="SMS Gateway",
)
self._attr_unique_id = str(imei)
self._hass = hass
self._gateway = gateway
Expand Down
12 changes: 6 additions & 6 deletions homeassistant/components/solarlog/sensor.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Platform for solarlog sensors."""
from homeassistant.components.sensor import SensorEntity
from homeassistant.helpers import update_coordinator
from homeassistant.helpers.entity import StateType
from homeassistant.helpers.entity import DeviceInfo, StateType

from . import SolarlogData
from .const import DOMAIN, SENSOR_TYPES, SolarLogSensorEntityDescription
Expand Down Expand Up @@ -30,11 +30,11 @@ def __init__(
self.entity_description = description
self._attr_name = f"{coordinator.name} {description.name}"
self._attr_unique_id = f"{coordinator.unique_id}_{description.key}"
self._attr_device_info = {
"identifiers": {(DOMAIN, coordinator.unique_id)},
"name": coordinator.name,
"manufacturer": "Solar-Log",
}
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, coordinator.unique_id)},
manufacturer="Solar-Log",
name=coordinator.name,
)

@property
def native_value(self) -> StateType:
Expand Down
Loading