Use enums in rainforest_eagle (#62057)

This commit is contained in:
Robert Hillis 2021-12-16 16:38:26 -05:00 committed by GitHub
parent 0ee5691f77
commit 6f54636baf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,19 +2,14 @@
from __future__ import annotations from __future__ import annotations
from homeassistant.components.sensor import ( from homeassistant.components.sensor import (
DEVICE_CLASS_ENERGY, SensorDeviceClass,
STATE_CLASS_MEASUREMENT,
STATE_CLASS_TOTAL_INCREASING,
SensorEntity, SensorEntity,
SensorEntityDescription, SensorEntityDescription,
SensorStateClass,
StateType, StateType,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import ENERGY_KILO_WATT_HOUR, POWER_KILO_WATT
DEVICE_CLASS_POWER,
ENERGY_KILO_WATT_HOUR,
POWER_KILO_WATT,
)
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -29,22 +24,22 @@ SENSORS = (
# We can drop the "Eagle-200" part of the name in HA 2021.12 # We can drop the "Eagle-200" part of the name in HA 2021.12
name="Eagle-200 Meter Power Demand", name="Eagle-200 Meter Power Demand",
native_unit_of_measurement=POWER_KILO_WATT, native_unit_of_measurement=POWER_KILO_WATT,
device_class=DEVICE_CLASS_POWER, device_class=SensorDeviceClass.POWER,
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
SensorEntityDescription( SensorEntityDescription(
key="zigbee:CurrentSummationDelivered", key="zigbee:CurrentSummationDelivered",
name="Eagle-200 Total Meter Energy Delivered", name="Eagle-200 Total Meter Energy Delivered",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY, device_class=SensorDeviceClass.ENERGY,
state_class=STATE_CLASS_TOTAL_INCREASING, state_class=SensorStateClass.TOTAL_INCREASING,
), ),
SensorEntityDescription( SensorEntityDescription(
key="zigbee:CurrentSummationReceived", key="zigbee:CurrentSummationReceived",
name="Eagle-200 Total Meter Energy Received", name="Eagle-200 Total Meter Energy Received",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY, device_class=SensorDeviceClass.ENERGY,
state_class=STATE_CLASS_TOTAL_INCREASING, state_class=SensorStateClass.TOTAL_INCREASING,
), ),
) )
@ -64,7 +59,7 @@ async def async_setup_entry(
key="zigbee:Price", key="zigbee:Price",
name="Meter Price", name="Meter Price",
native_unit_of_measurement=f"{coordinator.data['zigbee:PriceCurrency']}/{ENERGY_KILO_WATT_HOUR}", native_unit_of_measurement=f"{coordinator.data['zigbee:PriceCurrency']}/{ENERGY_KILO_WATT_HOUR}",
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
) )
) )