1 """Support for the Rainforest Eagle energy monitor."""
3 from __future__
import annotations
8 SensorEntityDescription,
19 from .const
import DOMAIN
20 from .coordinator
import EagleDataCoordinator
24 key=
"zigbee:InstantaneousDemand",
25 translation_key=
"power_demand",
26 native_unit_of_measurement=UnitOfPower.KILO_WATT,
27 device_class=SensorDeviceClass.POWER,
28 state_class=SensorStateClass.MEASUREMENT,
31 key=
"zigbee:CurrentSummationDelivered",
32 translation_key=
"total_energy_delivered",
33 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
34 device_class=SensorDeviceClass.ENERGY,
35 state_class=SensorStateClass.TOTAL_INCREASING,
38 key=
"zigbee:CurrentSummationReceived",
39 translation_key=
"total_energy_received",
40 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
41 device_class=SensorDeviceClass.ENERGY,
42 state_class=SensorStateClass.TOTAL_INCREASING,
48 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
50 """Set up a config entry."""
51 coordinator = hass.data[DOMAIN][entry.entry_id]
52 entities = [
EagleSensor(coordinator, description)
for description
in SENSORS]
54 if coordinator.data.get(
"zigbee:Price")
not in (
None,
"invalid"):
60 translation_key=
"meter_price",
61 native_unit_of_measurement=f
"{coordinator.data['zigbee:PriceCurrency']}/{UnitOfEnergy.KILO_WATT_HOUR}",
62 state_class=SensorStateClass.MEASUREMENT,
71 """Implementation of the Rainforest Eagle sensor."""
73 _attr_has_entity_name =
True
75 def __init__(self, coordinator, entity_description):
76 """Initialize the sensor."""
79 self.
_attr_unique_id_attr_unique_id = f
"{coordinator.cloud_id}-${coordinator.hardware_address}-{entity_description.key}"
81 identifiers={(DOMAIN, coordinator.cloud_id)},
82 manufacturer=
"Rainforest Automation",
83 model=coordinator.model,
84 name=coordinator.model,
89 """Return if entity is available."""
90 return super().available
and self.coordinator.is_connected
94 """Return native value of the sensor."""
StateType native_value(self)
def __init__(self, coordinator, entity_description)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)