Use new enums in fjaraskupan (#61438)

Co-authored-by: epenet <epenet@users.noreply.github.com>
pull/61450/head
epenet 2021-12-10 14:53:58 +01:00 committed by GitHub
parent eb27da3cd4
commit f1979f8b68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 16 deletions

View File

@ -7,7 +7,7 @@ from dataclasses import dataclass
from fjaraskupan import Device, State from fjaraskupan import Device, State
from homeassistant.components.binary_sensor import ( from homeassistant.components.binary_sensor import (
DEVICE_CLASS_PROBLEM, BinarySensorDeviceClass,
BinarySensorEntity, BinarySensorEntity,
BinarySensorEntityDescription, BinarySensorEntityDescription,
) )
@ -34,13 +34,13 @@ SENSORS = (
EntityDescription( EntityDescription(
key="grease-filter", key="grease-filter",
name="Grease Filter", name="Grease Filter",
device_class=DEVICE_CLASS_PROBLEM, device_class=BinarySensorDeviceClass.PROBLEM,
is_on=lambda state: state.grease_filter_full, is_on=lambda state: state.grease_filter_full,
), ),
EntityDescription( EntityDescription(
key="carbon-filter", key="carbon-filter",
name="Carbon Filter", name="Carbon Filter",
device_class=DEVICE_CLASS_PROBLEM, device_class=BinarySensorDeviceClass.PROBLEM,
is_on=lambda state: state.carbon_filter_full, is_on=lambda state: state.carbon_filter_full,
), ),
) )

View File

@ -5,9 +5,9 @@ from fjaraskupan import Device, State
from homeassistant.components.number import NumberEntity from homeassistant.components.number import NumberEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ENTITY_CATEGORY_CONFIG, TIME_MINUTES from homeassistant.const import TIME_MINUTES
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import DeviceInfo, Entity from homeassistant.helpers.entity import DeviceInfo, Entity, EntityCategory
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.update_coordinator import ( from homeassistant.helpers.update_coordinator import (
CoordinatorEntity, CoordinatorEntity,
@ -40,7 +40,7 @@ class PeriodicVentingTime(CoordinatorEntity[State], NumberEntity):
_attr_max_value: float = 59 _attr_max_value: float = 59
_attr_min_value: float = 0 _attr_min_value: float = 0
_attr_step: float = 1 _attr_step: float = 1
_attr_entity_category = ENTITY_CATEGORY_CONFIG _attr_entity_category = EntityCategory.CONFIG
_attr_unit_of_measurement = TIME_MINUTES _attr_unit_of_measurement = TIME_MINUTES
def __init__( def __init__(

View File

@ -4,17 +4,14 @@ from __future__ import annotations
from fjaraskupan import Device, State from fjaraskupan import Device, State
from homeassistant.components.sensor import ( from homeassistant.components.sensor import (
DEVICE_CLASS_SIGNAL_STRENGTH, SensorDeviceClass,
STATE_CLASS_MEASUREMENT,
SensorEntity, SensorEntity,
SensorStateClass,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import SIGNAL_STRENGTH_DECIBELS_MILLIWATT
ENTITY_CATEGORY_DIAGNOSTIC,
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
)
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import DeviceInfo, Entity from homeassistant.helpers.entity import DeviceInfo, Entity, EntityCategory
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import StateType from homeassistant.helpers.typing import StateType
from homeassistant.helpers.update_coordinator import ( from homeassistant.helpers.update_coordinator import (
@ -56,11 +53,11 @@ class RssiSensor(CoordinatorEntity[State], SensorEntity):
self._attr_unique_id = f"{device.address}-signal-strength" self._attr_unique_id = f"{device.address}-signal-strength"
self._attr_device_info = device_info self._attr_device_info = device_info
self._attr_name = f"{device_info['name']} Signal Strength" self._attr_name = f"{device_info['name']} Signal Strength"
self._attr_device_class = DEVICE_CLASS_SIGNAL_STRENGTH self._attr_device_class = SensorDeviceClass.SIGNAL_STRENGTH
self._attr_state_class = STATE_CLASS_MEASUREMENT self._attr_state_class = SensorStateClass.MEASUREMENT
self._attr_native_unit_of_measurement = SIGNAL_STRENGTH_DECIBELS_MILLIWATT self._attr_native_unit_of_measurement = SIGNAL_STRENGTH_DECIBELS_MILLIWATT
self._attr_entity_registry_enabled_default = False self._attr_entity_registry_enabled_default = False
self._attr_entity_category = ENTITY_CATEGORY_DIAGNOSTIC self._attr_entity_category = EntityCategory.DIAGNOSTIC
@property @property
def native_value(self) -> StateType: def native_value(self) -> StateType: