def __init__( self, central_system: CentralSystem, cp_id: str, description: OcppSwitchDescription, ): """Instantiate instance of a ChargePointSwitch.""" self.cp_id = cp_id self.central_system = central_system self.entity_description = description self._state = self.entity_description.default_state self._attr_unique_id = ".".join( [SWITCH_DOMAIN, DOMAIN, self.cp_id, self.entity_description.key]) self._attr_name = ".".join([self.cp_id, self.entity_description.name]) self._attr_device_info = DeviceInfo( identifiers={(DOMAIN, self.cp_id)}, via_device=(DOMAIN, self.central_system.id), ) self.entity_id = (SWITCH_DOMAIN + "." + "_".join([self.cp_id, self.entity_description.key]))
def __init__( self, *, coordinator: DataUpdateCoordinator, description: RDWBinarySensorEntityDescription, ) -> None: """Initialize RDW binary sensor.""" super().__init__(coordinator=coordinator) self.entity_description = description self._attr_unique_id = f"{coordinator.data.license_plate}_{description.key}" self._attr_device_info = DeviceInfo( entry_type=DeviceEntryType.SERVICE, identifiers={(DOMAIN, coordinator.data.license_plate)}, manufacturer=coordinator.data.brand, name=f"{coordinator.data.brand}: {coordinator.data.license_plate}", model=coordinator.data.model, configuration_url= f"https://ovi.rdw.nl/default.aspx?kenteken={coordinator.data.license_plate}", )
def generate_device_info(self) -> DeviceInfo: """Return device registry information for this entity.""" # Some devices, such as the Smart Thermostat have several devices in one physical device, # with same device url, terminated by '#' and a number. # In this case, we use the base device url as the device identifier. if "#" in self.device_url and not self.device_url.endswith("#1"): # Only return the url of the base device, to inherit device name and model from parent device. return { "identifiers": {(DOMAIN, self.executor.base_device_url)}, } manufacturer = ( self.executor.select_attribute(OverkizAttribute.CORE_MANUFACTURER) or self.executor.select_state(OverkizState.CORE_MANUFACTURER_NAME) or self.coordinator.client.server.manufacturer) model = (self.executor.select_state( OverkizState.CORE_MODEL, OverkizState.CORE_PRODUCT_MODEL_NAME, OverkizState.IO_MODEL, ) or self.device.widget.value) suggested_area = (self.coordinator.areas[self.device.place_oid] if self.coordinator.areas and self.device.place_oid else None) return DeviceInfo( identifiers={(DOMAIN, self.executor.base_device_url)}, name=self.device.label, manufacturer=str(manufacturer), model=str(model), sw_version=cast( str, self.executor.select_attribute( OverkizAttribute.CORE_FIRMWARE_REVISION), ), hw_version=self.device.controllable_name, suggested_area=suggested_area, via_device=(DOMAIN, self.executor.get_gateway_id()), configuration_url=self.coordinator.client.server.configuration_url, )
class IRobotEntity(Entity): """Base class for iRobot Entities.""" def __init__(self, roomba, blid): """Initialize the iRobot handler.""" self.vacuum = roomba self._blid = blid self.vacuum_state = roomba_reported_state(roomba) self._name = self.vacuum_state.get("name") self._version = self.vacuum_state.get("softwareVer") self._sku = self.vacuum_state.get("sku") @property def should_poll(self): """Disable polling.""" return False @property def robot_unique_id(self): """Return the uniqueid of the vacuum cleaner.""" return f"roomba_{self._blid}" @property def unique_id(self): """Return the uniqueid of the vacuum cleaner.""" return self.robot_unique_id @property def device_info(self): """Return the device info of the vacuum cleaner.""" connections = None if mac_address := self.vacuum_state.get("hwPartsRev", {}).get( "wlan0HwAddr", self.vacuum_state.get("mac")): connections = {(dr.CONNECTION_NETWORK_MAC, mac_address)} return DeviceInfo( connections=connections, identifiers={(DOMAIN, self.robot_unique_id)}, manufacturer="iRobot", model=self._sku, name=str(self._name), sw_version=self._version, )
def __init__(self, coordinator, heater): """Initialize the thermostat.""" super().__init__(coordinator) self._available = False self._id = heater.device_id self._attr_unique_id = heater.device_id self._attr_name = heater.name self._attr_device_info = DeviceInfo( identifiers={(DOMAIN, heater.device_id)}, manufacturer=MANUFACTURER, model=f"generation {1 if heater.is_gen1 else 2}", name=self.name, ) if heater.is_gen1 or heater.is_gen3: self._attr_hvac_modes = [HVAC_MODE_HEAT] else: self._attr_hvac_modes = [HVAC_MODE_HEAT, HVAC_MODE_OFF] self._update_attr(heater)
def __init__( self, bridge: HueBridge, controller: BaseResourcesController, resource: CLIPResource, ) -> None: """Initialize a generic Hue resource entity.""" self.bridge = bridge self.controller = controller self.resource = resource self.device = controller.get_device(resource.id) self.logger = bridge.logger.getChild(resource.type.value) # Entity class attributes self._attr_unique_id = resource.id # device is precreated in main handler # this attaches the entity to the precreated device if self.device is not None: self._attr_device_info = DeviceInfo( identifiers={(DOMAIN, self.device.id)}, )
def __init__( self, name: str, unique_id: str, description: SensorEntityDescription, coordinator: DataUpdateCoordinator, ) -> None: """Initialize the sensor.""" self.entity_description = description self._coordinator = coordinator self._attr_name = f"{name} {description.name}" self._attr_unique_id = unique_id split_unique_id = unique_id.split("-") self._attr_device_info = DeviceInfo( entry_type=DeviceEntryType.SERVICE, identifiers={(DOMAIN, f"{split_unique_id[0]}-{split_unique_id[1]}") }, manufacturer=MANUFACTURER, name=DEFAULT_NAME, )
def device_info(self) -> DeviceInfo: """Return device information about this AdGuard Home instance.""" if self._entry.source == SOURCE_HASSIO: config_url = "homeassistant://hassio/ingress/a0d7b954_adguard" else: if self.adguard.tls: config_url = f"https://{self.adguard.host}:{self.adguard.port}" else: config_url = f"http://{self.adguard.host}:{self.adguard.port}" return DeviceInfo( entry_type=DeviceEntryType.SERVICE, identifiers={(DOMAIN, self.adguard.host, self.adguard.port, self.adguard.base_path) # type: ignore[arg-type] }, manufacturer="AdGuard Team", name="AdGuard Home", sw_version=self.hass.data[DOMAIN][self._entry.entry_id].get( DATA_ADGUARD_VERSION), configuration_url=config_url, )
async def _create_solar_net_device(self) -> DeviceInfo: """Create a device for the Fronius SolarNet system.""" solar_net_device: DeviceInfo = DeviceInfo( configuration_url=self.fronius.url, identifiers={(DOMAIN, self.solar_net_device_id)}, manufacturer="Fronius", name="SolarNet", ) if self.logger_coordinator: _logger_info = self.logger_coordinator.data[SOLAR_NET_ID_SYSTEM] solar_net_device[ATTR_MODEL] = _logger_info["product_type"][ "value"] solar_net_device[ATTR_SW_VERSION] = _logger_info[ "software_version"]["value"] device_registry = await dr.async_get_registry(self.hass) device_registry.async_get_or_create( config_entry_id=self.config_entry.entry_id, **solar_net_device, ) return solar_net_device
def __init__( self, *, coordinator: PureEnergieDataUpdateCoordinator, description: PureEnergieSensorEntityDescription, entry: ConfigEntry, ) -> None: """Initialize Pure Energie sensor.""" super().__init__(coordinator=coordinator) self.entity_id = f"{SENSOR_DOMAIN}.pem_{description.key}" self.entity_description = description self._attr_unique_id = f"{coordinator.data.device.n2g_id}_{description.key}" self._attr_device_info = DeviceInfo( identifiers={(DOMAIN, coordinator.data.device.n2g_id)}, configuration_url= f"http://{coordinator.config_entry.data[CONF_HOST]}", sw_version=coordinator.data.device.firmware, manufacturer=coordinator.data.device.manufacturer, model=coordinator.data.device.model, name=entry.title, )
def __init__( self, coordinator: DataUpdateCoordinator, device: str, device_group: str, friendly_name: str, sensor_id: str, ) -> None: """Create the sensor.""" super().__init__(coordinator) self._device = device self._device_group = device_group self._sensor_id = sensor_id self._attr_unique_id = f"{DOMAIN}_{device}_{sensor_id}" self._attr_device_info = DeviceInfo( identifiers={(DOMAIN, f"{device}_{device_group}")}, manufacturer="YouLess", model=self.coordinator.data.model, name=friendly_name, )
def __init__( self, hass: HomeAssistant, vehicle: RenaultVehicle, details: models.KamereonVehicleDetails, scan_interval: timedelta, ) -> None: """Initialise vehicle proxy.""" self.hass = hass self._vehicle = vehicle self._details = details self._device_info = DeviceInfo( identifiers={(DOMAIN, cast(str, details.vin))}, manufacturer=(details.get_brand_label() or "").capitalize(), model=(details.get_model_label() or "").capitalize(), name=details.registrationNumber or "", sw_version=details.get_model_code() or "", ) self.coordinators: dict[str, RenaultDataUpdateCoordinator] = {} self.hvac_target_temperature = 21 self._scan_interval = scan_interval
def __init__( self, glances_data, name, sensor_name_prefix, description: GlancesSensorEntityDescription, config_entry_id: str, ): """Initialize the sensor.""" self.glances_data = glances_data self._sensor_name_prefix = sensor_name_prefix self._state = None self.unsub_update = None self.entity_description = description self._attr_name = f"{name} {sensor_name_prefix} {description.name_suffix}" self._attr_device_info = DeviceInfo( identifiers={(DOMAIN, config_entry_id)}, manufacturer="Glances", name=name, )
def __init__(self, wiz_data: WizData, name: str) -> None: """Initialize a WiZ entity.""" super().__init__(wiz_data.coordinator) self._device = wiz_data.bulb bulb_type: BulbType = self._device.bulbtype self._attr_unique_id = self._device.mac self._attr_name = name self._attr_device_info = DeviceInfo( connections={(CONNECTION_NETWORK_MAC, self._device.mac)}, name=name, manufacturer="WiZ", sw_version=bulb_type.fw_version, ) if bulb_type.name is None: return hw_data = bulb_type.name.split("_") board = hw_data.pop(0) model = hw_data.pop(0) hw_version = f"{board} {hw_data[0]}" if hw_data else board self._attr_device_info[ATTR_HW_VERSION] = hw_version self._attr_device_info[ATTR_MODEL] = model
def __init__( self, coordinator: DataUpdateCoordinator, sensor_description: SensorEntityDescription, data: PyNUTData, unique_id: str, enabled_default: bool, ) -> None: """Initialize the sensor.""" super().__init__(coordinator) self.entity_description = sensor_description device_name = data.name.title() self._attr_entity_registry_enabled_default = enabled_default self._attr_name = f"{device_name} {sensor_description.name}" self._attr_unique_id = f"{unique_id}_{sensor_description.key}" self._attr_device_info = DeviceInfo( identifiers={(DOMAIN, unique_id)}, name=device_name, ) self._attr_device_info.update(data.device_info)
async def async_setup_entry( hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback ) -> None: """Add Brother entities from a config_entry.""" coordinator = hass.data[DOMAIN][DATA_CONFIG_ENTRY][entry.entry_id] sensors = [] device_info = DeviceInfo( configuration_url=f"http://{entry.data[CONF_HOST]}/", identifiers={(DOMAIN, coordinator.data.serial)}, manufacturer=ATTR_MANUFACTURER, model=coordinator.data.model, name=coordinator.data.model, sw_version=getattr(coordinator.data, "firmware", None), ) for description in SENSOR_TYPES: if description.key in coordinator.data: sensors.append(BrotherPrinterSensor(coordinator, description, device_info)) async_add_entities(sensors, False)
def __init__(self, hass, api_key, device, coordinator): """Initialize the Freedompro cover.""" super().__init__(coordinator) self._session = aiohttp_client.async_get_clientsession(hass) self._api_key = api_key self._attr_name = device["name"] self._attr_unique_id = device["uid"] self._attr_device_info = DeviceInfo( identifiers={ (DOMAIN, self.unique_id), }, manufacturer="Freedompro", model=device["type"], name=self.name, ) self._attr_current_cover_position = 0 self._attr_is_closed = True self._attr_supported_features = ( SUPPORT_CLOSE | SUPPORT_OPEN | SUPPORT_SET_POSITION ) self._attr_device_class = DEVICE_CLASS_MAP[device["type"]]
def __init__( self, coordinator: GitHubDataUpdateCoordinator, entity_description: GitHubSensorEntityDescription, ) -> None: """Initialize the sensor.""" super().__init__(coordinator=coordinator) self.entity_description = entity_description self._attr_name = ( f"{coordinator.data.get('full_name')} {entity_description.name}" ) self._attr_unique_id = f"{coordinator.data.get('id')}_{entity_description.key}" self._attr_device_info = DeviceInfo( identifiers={(DOMAIN, coordinator.repository)}, name=coordinator.data.get("full_name"), manufacturer="GitHub", configuration_url=f"https://github.com/{coordinator.repository}", entry_type=DeviceEntryType.SERVICE, )
def __init__( self, *, entry_id: str, coordinator: DataUpdateCoordinator, entity_description: ForecastSolarSensorEntityDescription, ) -> None: """Initialize Forecast.Solar sensor.""" super().__init__(coordinator=coordinator) self.entity_description = entity_description self.entity_id = f"{SENSOR_DOMAIN}.{entity_description.key}" self._attr_unique_id = f"{entry_id}_{entity_description.key}" self._attr_device_info = DeviceInfo( entry_type=DeviceEntryType.SERVICE, identifiers={(DOMAIN, entry_id)}, manufacturer="Forecast.Solar", model=coordinator.data.account_type.value, name="Solar Production Forecast", configuration_url="https://forecast.solar", )
def __init__( self, somfy_mylink, target_id, name="SomfyShade", reverse=False, device_class=CoverDeviceClass.WINDOW, ): """Initialize the cover.""" self.somfy_mylink = somfy_mylink self._target_id = target_id self._attr_unique_id = target_id self._attr_name = name self._reverse = reverse self._attr_is_closed = None self._attr_device_class = device_class self._attr_device_info = DeviceInfo( identifiers={(DOMAIN, self._target_id)}, manufacturer=MANUFACTURER, name=name, )
def __init__( self, coordinator: RiscoDataUpdateCoordinator, partition_id: int, code: str, options: dict[str, Any], ) -> None: """Init the partition.""" super().__init__( partition_id=partition_id, partition=coordinator.data.partitions[partition_id], coordinator=coordinator, code=code, options=options, ) self._attr_unique_id = f"{self._risco.site_uuid}_{partition_id}" self._attr_device_info = DeviceInfo( identifiers={(DOMAIN, self._attr_unique_id)}, name=f"Risco {self._risco.site_name} Partition {partition_id}", manufacturer="Risco", )
def __init__( self, name, unique_id, description: BinarySensorEntityDescription, coordinator: UkraineAlarmDataUpdateCoordinator, ) -> None: """Initialize the sensor.""" super().__init__(coordinator) self.entity_description = description self._attr_name = f"{name} {description.name}" self._attr_unique_id = f"{unique_id}-{description.key}".lower() self._attr_device_info = DeviceInfo( entry_type=DeviceEntryType.SERVICE, identifiers={(DOMAIN, unique_id)}, manufacturer=MANUFACTURER, name=name, configuration_url="https://siren.pp.ua/", )
def __init__( self, coordinator: DataUpdateCoordinator, entity_description: EntityDescription, ) -> None: """Initialize Watchman entity.""" super().__init__(coordinator) self.entity_description = entity_description # per sensor unique_id self._attr_unique_id = ( f"{coordinator.config_entry.entry_id}_{entity_description.key}") self._attr_device_info = DeviceInfo( identifiers={(DOMAIN, "watchman_unique_id")}, manufacturer="dummylabs", model="Watchman", name="Watchman", sw_version=VERSION, entry_type=DeviceEntryType.SERVICE, configuration_url="https://github.com/dummylabs/thewatchman", ) self._attr_extra_state_attributes = {}
def __init__( self, coordinator, flume_device, name, device_id, description: SensorEntityDescription, ): """Initialize the Flume sensor.""" super().__init__(coordinator) self.entity_description = description self._flume_device = flume_device self._attr_name = f"{name} {description.name}" self._attr_unique_id = f"{description.key}_{device_id}" self._attr_device_info = DeviceInfo( identifiers={(DOMAIN, device_id)}, manufacturer="Flume, Inc.", model="Flume Smart Water Monitor", name=self.name, )
def __init__(self, entity_description: DSMRSensorEntityDescription, entry: ConfigEntry) -> None: """Initialize entity.""" self.entity_description = entity_description self._entry = entry self.telegram: dict[str, DSMRObject] = {} device_serial = entry.data[CONF_SERIAL_ID] device_name = DEVICE_NAME_ELECTRICITY if entity_description.is_gas: device_serial = entry.data[CONF_SERIAL_ID_GAS] device_name = DEVICE_NAME_GAS if device_serial is None: device_serial = entry.entry_id self._attr_device_info = DeviceInfo( identifiers={(DOMAIN, device_serial)}, name=device_name, ) self._attr_unique_id = f"{device_serial}_{entity_description.name}".replace( " ", "_")
def device_info(self) -> DeviceInfo: """Return device information.""" device_info = DeviceInfo( identifiers={(DOMAIN, self._unique_id)}, manufacturer="LG", name=self._name, ) if self._client.system_info is None and self.state == STATE_OFF: return device_info maj_v = self._client.software_info.get("major_ver") min_v = self._client.software_info.get("minor_ver") if maj_v and min_v: device_info["sw_version"] = f"{maj_v}.{min_v}" model = self._client.system_info.get("modelName") if model: device_info["model"] = model return device_info
def __init__( self, coordinator: FroniusOhmpilotUpdateCoordinator, key: str, solar_net_id: str, ) -> None: """Set up an individual Fronius meter sensor.""" self._entity_id_prefix = f"ohmpilot_{solar_net_id}" super().__init__(coordinator, key, solar_net_id) device_data = self._device_data() self._attr_device_info = DeviceInfo( identifiers={(DOMAIN, device_data["serial"]["value"])}, manufacturer=device_data["manufacturer"]["value"], model= f"{device_data['model']['value']} {device_data['hardware']['value']}", name=device_data["model"]["value"], sw_version=device_data["software"]["value"], via_device=(DOMAIN, coordinator.solar_net.solar_net_device_id), ) self._attr_unique_id = f'{device_data["serial"]["value"]}-{key}'
def __init__(self, coordinator, entity_description, mill_device): """Initialize the sensor.""" super().__init__(coordinator) self._id = mill_device.device_id self.entity_description = entity_description self._available = False self._attr_name = f"{mill_device.name} {entity_description.name}" self._attr_unique_id = f"{mill_device.device_id}_{entity_description.key}" self._attr_device_info = DeviceInfo( identifiers={(DOMAIN, mill_device.device_id)}, name=self.name, manufacturer=MANUFACTURER, ) if isinstance(mill_device, mill.Heater): self._attr_device_info[ "model"] = f"Generation {mill_device.generation}" elif isinstance(mill_device, mill.Sensor): self._attr_device_info["model"] = "Mill Sense Air" self._update_attr(mill_device)
def __init__( self, coordinator: TVDataUpdateCoordinator, name: str, entry_id: str, entity_description: TrafikverketSensorEntityDescription, ) -> None: """Initialize the sensor.""" super().__init__(coordinator) self._attr_name = f"{name} {entity_description.name}" self._attr_unique_id = f"{entry_id}-{entity_description.key}" self.entity_description = entity_description self._attr_device_info = DeviceInfo( entry_type=DeviceEntryType.SERVICE, identifiers={(DOMAIN, entry_id)}, manufacturer="Trafikverket", model="v1.2", name=name, configuration_url="https://api.trafikinfo.trafikverket.se/", ) self._update_attr()
def device_info(self) -> DeviceInfo: """Return a device description for device registry.""" connections = None if self.device.info.mac: connections = {(CONNECTION_NETWORK_MAC, self.device.info.mac)} return DeviceInfo( connections=connections, identifiers={ # MAC address is not always available, and given the number # of non-conformant ONVIF devices we have historically supported, # we can not guarantee serial number either. Due to this, we have # adopted an either/or approach in the config entry setup, and can # guarantee that one or the other will be populated. # See: https://github.com/home-assistant/core/issues/35883 (DOMAIN, self.device.info.mac or self.device.info.serial_number) }, manufacturer=self.device.info.manufacturer, model=self.device.info.model, name=self.device.name, sw_version=self.device.info.fw_version, )