Add flipr battery level sensor (#81389)

* Addition of battery level sensor. Correction of pylint errors

* Review improvement for typing

* Review improvement for typing

* Correction following review
This commit is contained in:
cnico 2022-11-16 09:42:31 +01:00 committed by GitHub
parent 532c6b74d4
commit c7dfd6b15a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 33 additions and 12 deletions

View file

@ -8,7 +8,7 @@ from homeassistant.components.sensor import (
SensorStateClass,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ELECTRIC_POTENTIAL_MILLIVOLT, TEMP_CELSIUS
from homeassistant.const import ELECTRIC_POTENTIAL_MILLIVOLT, PERCENTAGE, TEMP_CELSIUS
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -48,6 +48,13 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
icon="mdi:pool",
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
key="battery",
name="Battery Level",
native_unit_of_measurement=PERCENTAGE,
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.BATTERY,
),
)
@ -67,6 +74,6 @@ class FliprSensor(FliprEntity, SensorEntity):
"""Sensor representing FliprSensor data."""
@property
def native_value(self):
def native_value(self) -> str:
"""State of the sensor."""
return self.coordinator.data[self.entity_description.key]