mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 17:27:10 +00:00
Add entity translations to Rainforest eagle (#96031)
* Add entity translations to Rainforest eagle * Add entity translations to Rainforest Eagle
This commit is contained in:
parent
efcaad1179
commit
fe44827e3c
@ -21,22 +21,21 @@ from .data import EagleDataCoordinator
|
|||||||
SENSORS = (
|
SENSORS = (
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="zigbee:InstantaneousDemand",
|
key="zigbee:InstantaneousDemand",
|
||||||
# We can drop the "Eagle-200" part of the name in HA 2021.12
|
translation_key="power_demand",
|
||||||
name="Eagle-200 Meter Power Demand",
|
|
||||||
native_unit_of_measurement=UnitOfPower.KILO_WATT,
|
native_unit_of_measurement=UnitOfPower.KILO_WATT,
|
||||||
device_class=SensorDeviceClass.POWER,
|
device_class=SensorDeviceClass.POWER,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="zigbee:CurrentSummationDelivered",
|
key="zigbee:CurrentSummationDelivered",
|
||||||
name="Eagle-200 Total Meter Energy Delivered",
|
translation_key="total_energy_delivered",
|
||||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||||
device_class=SensorDeviceClass.ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="zigbee:CurrentSummationReceived",
|
key="zigbee:CurrentSummationReceived",
|
||||||
name="Eagle-200 Total Meter Energy Received",
|
translation_key="total_energy_received",
|
||||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||||
device_class=SensorDeviceClass.ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
@ -57,7 +56,7 @@ async def async_setup_entry(
|
|||||||
coordinator,
|
coordinator,
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="zigbee:Price",
|
key="zigbee:Price",
|
||||||
name="Meter Price",
|
translation_key="meter_price",
|
||||||
native_unit_of_measurement=f"{coordinator.data['zigbee:PriceCurrency']}/{UnitOfEnergy.KILO_WATT_HOUR}",
|
native_unit_of_measurement=f"{coordinator.data['zigbee:PriceCurrency']}/{UnitOfEnergy.KILO_WATT_HOUR}",
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
@ -70,6 +69,8 @@ async def async_setup_entry(
|
|||||||
class EagleSensor(CoordinatorEntity[EagleDataCoordinator], SensorEntity):
|
class EagleSensor(CoordinatorEntity[EagleDataCoordinator], SensorEntity):
|
||||||
"""Implementation of the Rainforest Eagle sensor."""
|
"""Implementation of the Rainforest Eagle sensor."""
|
||||||
|
|
||||||
|
_attr_has_entity_name = True
|
||||||
|
|
||||||
def __init__(self, coordinator, entity_description):
|
def __init__(self, coordinator, entity_description):
|
||||||
"""Initialize the sensor."""
|
"""Initialize the sensor."""
|
||||||
super().__init__(coordinator)
|
super().__init__(coordinator)
|
||||||
|
@ -17,5 +17,21 @@
|
|||||||
"abort": {
|
"abort": {
|
||||||
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]"
|
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"entity": {
|
||||||
|
"sensor": {
|
||||||
|
"power_demand": {
|
||||||
|
"name": "Meter power demand"
|
||||||
|
},
|
||||||
|
"total_energy_delivered": {
|
||||||
|
"name": "Total meter energy delivered"
|
||||||
|
},
|
||||||
|
"total_energy_received": {
|
||||||
|
"name": "Total meter energy received"
|
||||||
|
},
|
||||||
|
"meter_price": {
|
||||||
|
"name": "Meter price"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ async def test_sensors_200(hass: HomeAssistant, setup_rainforest_200) -> None:
|
|||||||
|
|
||||||
assert len(hass.states.async_all()) == 4
|
assert len(hass.states.async_all()) == 4
|
||||||
|
|
||||||
price = hass.states.get("sensor.meter_price")
|
price = hass.states.get("sensor.eagle_200_meter_price")
|
||||||
assert price is not None
|
assert price is not None
|
||||||
assert price.state == "0.053990"
|
assert price.state == "0.053990"
|
||||||
assert price.attributes["unit_of_measurement"] == "USD/kWh"
|
assert price.attributes["unit_of_measurement"] == "USD/kWh"
|
||||||
@ -42,17 +42,17 @@ async def test_sensors_100(hass: HomeAssistant, setup_rainforest_100) -> None:
|
|||||||
"""Test the sensors."""
|
"""Test the sensors."""
|
||||||
assert len(hass.states.async_all()) == 3
|
assert len(hass.states.async_all()) == 3
|
||||||
|
|
||||||
demand = hass.states.get("sensor.eagle_200_meter_power_demand")
|
demand = hass.states.get("sensor.eagle_100_meter_power_demand")
|
||||||
assert demand is not None
|
assert demand is not None
|
||||||
assert demand.state == "1.152000"
|
assert demand.state == "1.152000"
|
||||||
assert demand.attributes["unit_of_measurement"] == "kW"
|
assert demand.attributes["unit_of_measurement"] == "kW"
|
||||||
|
|
||||||
delivered = hass.states.get("sensor.eagle_200_total_meter_energy_delivered")
|
delivered = hass.states.get("sensor.eagle_100_total_meter_energy_delivered")
|
||||||
assert delivered is not None
|
assert delivered is not None
|
||||||
assert delivered.state == "45251.285000"
|
assert delivered.state == "45251.285000"
|
||||||
assert delivered.attributes["unit_of_measurement"] == "kWh"
|
assert delivered.attributes["unit_of_measurement"] == "kWh"
|
||||||
|
|
||||||
received = hass.states.get("sensor.eagle_200_total_meter_energy_received")
|
received = hass.states.get("sensor.eagle_100_total_meter_energy_received")
|
||||||
assert received is not None
|
assert received is not None
|
||||||
assert received.state == "232.232000"
|
assert received.state == "232.232000"
|
||||||
assert received.attributes["unit_of_measurement"] == "kWh"
|
assert received.attributes["unit_of_measurement"] == "kWh"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user