mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Add entity translations to Aurora ABB PowerOne (#95132)
This commit is contained in:
parent
98cc45ec10
commit
73bc5a4e8f
@ -34,7 +34,7 @@ SENSOR_TYPES = [
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
name="Power Output",
|
||||
translation_key="power_output",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="temp",
|
||||
@ -42,14 +42,13 @@ SENSOR_TYPES = [
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
name="Temperature",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="totalenergy",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
name="Total Energy",
|
||||
translation_key="total_energy",
|
||||
),
|
||||
]
|
||||
|
||||
@ -75,6 +74,8 @@ async def async_setup_entry(
|
||||
class AuroraSensor(AuroraEntity, SensorEntity):
|
||||
"""Representation of a Sensor on a Aurora ABB PowerOne Solar inverter."""
|
||||
|
||||
_attr_has_entity_name = True
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
client: AuroraSerialClient,
|
||||
|
@ -18,5 +18,15 @@
|
||||
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]",
|
||||
"no_serial_ports": "No com ports found. Need a valid RS485 device to communicate."
|
||||
}
|
||||
},
|
||||
"entity": {
|
||||
"sensor": {
|
||||
"power_output": {
|
||||
"name": "Power Output"
|
||||
},
|
||||
"total_energy": {
|
||||
"name": "Total Energy"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -82,15 +82,15 @@ async def test_sensors(hass: HomeAssistant) -> None:
|
||||
await hass.config_entries.async_setup(mock_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
power = hass.states.get("sensor.power_output")
|
||||
power = hass.states.get("sensor.mydevicename_power_output")
|
||||
assert power
|
||||
assert power.state == "45.7"
|
||||
|
||||
temperature = hass.states.get("sensor.temperature")
|
||||
temperature = hass.states.get("sensor.mydevicename_temperature")
|
||||
assert temperature
|
||||
assert temperature.state == "9.9"
|
||||
|
||||
energy = hass.states.get("sensor.total_energy")
|
||||
energy = hass.states.get("sensor.mydevicename_total_energy")
|
||||
assert energy
|
||||
assert energy.state == "12.35"
|
||||
|
||||
@ -120,7 +120,7 @@ async def test_sensor_dark(hass: HomeAssistant) -> None:
|
||||
await hass.config_entries.async_setup(mock_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
power = hass.states.get("sensor.power_output")
|
||||
power = hass.states.get("sensor.mydevicename_power_output")
|
||||
assert power is not None
|
||||
assert power.state == "45.7"
|
||||
|
||||
@ -131,7 +131,7 @@ async def test_sensor_dark(hass: HomeAssistant) -> None:
|
||||
):
|
||||
async_fire_time_changed(hass, utcnow + timedelta(seconds=60))
|
||||
await hass.async_block_till_done()
|
||||
power = hass.states.get("sensor.power_output")
|
||||
power = hass.states.get("sensor.mydevicename_power_output")
|
||||
assert power.state == "unknown"
|
||||
# sun rose again
|
||||
with patch("aurorapy.client.AuroraSerialClient.connect", return_value=None), patch(
|
||||
@ -139,7 +139,7 @@ async def test_sensor_dark(hass: HomeAssistant) -> None:
|
||||
):
|
||||
async_fire_time_changed(hass, utcnow + timedelta(seconds=60))
|
||||
await hass.async_block_till_done()
|
||||
power = hass.states.get("sensor.power_output")
|
||||
power = hass.states.get("sensor.mydevicename_power_output")
|
||||
assert power is not None
|
||||
assert power.state == "45.7"
|
||||
# sunset
|
||||
@ -149,7 +149,7 @@ async def test_sensor_dark(hass: HomeAssistant) -> None:
|
||||
):
|
||||
async_fire_time_changed(hass, utcnow + timedelta(seconds=60))
|
||||
await hass.async_block_till_done()
|
||||
power = hass.states.get("sensor.power_output")
|
||||
power = hass.states.get("sensor.mydevicename_power_output")
|
||||
assert power.state == "unknown" # should this be 'available'?
|
||||
|
||||
|
||||
@ -164,5 +164,5 @@ async def test_sensor_unknown_error(hass: HomeAssistant) -> None:
|
||||
mock_entry.add_to_hass(hass)
|
||||
await hass.config_entries.async_setup(mock_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
power = hass.states.get("sensor.power_output")
|
||||
power = hass.states.get("sensor.mydevicename_power_output")
|
||||
assert power is None
|
||||
|
Loading…
x
Reference in New Issue
Block a user