mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 14:27:07 +00:00
Set battery device class in Logi Circle (#98774)
This commit is contained in:
parent
365dc47740
commit
baf32658e5
@ -4,7 +4,11 @@ from __future__ import annotations
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.components.sensor import SensorEntity, SensorEntityDescription
|
||||
from homeassistant.components.sensor import (
|
||||
SensorDeviceClass,
|
||||
SensorEntity,
|
||||
SensorEntityDescription,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
ATTR_BATTERY_CHARGING,
|
||||
@ -17,7 +21,6 @@ from homeassistant.const import (
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.device_registry import DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.icon import icon_for_battery_level
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
from homeassistant.util.dt import as_local
|
||||
|
||||
@ -29,9 +32,8 @@ _LOGGER = logging.getLogger(__name__)
|
||||
SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
||||
SensorEntityDescription(
|
||||
key="battery_level",
|
||||
name="Battery",
|
||||
native_unit_of_measurement=PERCENTAGE,
|
||||
icon="mdi:battery-50",
|
||||
device_class=SensorDeviceClass.BATTERY,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="last_activity_time",
|
||||
@ -135,10 +137,6 @@ class LogiSensor(SensorEntity):
|
||||
def icon(self):
|
||||
"""Icon to use in the frontend, if any."""
|
||||
sensor_type = self.entity_description.key
|
||||
if sensor_type == "battery_level" and self._attr_native_value is not None:
|
||||
return icon_for_battery_level(
|
||||
battery_level=int(self._attr_native_value), charging=False
|
||||
)
|
||||
if sensor_type == "recording_mode" and self._attr_native_value is not None:
|
||||
return "mdi:eye" if self._attr_native_value == STATE_ON else "mdi:eye-off"
|
||||
if sensor_type == "streaming_mode" and self._attr_native_value is not None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user