mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +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,
|
device_class=SensorDeviceClass.POWER,
|
||||||
native_unit_of_measurement=UnitOfPower.WATT,
|
native_unit_of_measurement=UnitOfPower.WATT,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
name="Power Output",
|
translation_key="power_output",
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="temp",
|
key="temp",
|
||||||
@ -42,14 +42,13 @@ SENSOR_TYPES = [
|
|||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
name="Temperature",
|
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="totalenergy",
|
key="totalenergy",
|
||||||
device_class=SensorDeviceClass.ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
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):
|
class AuroraSensor(AuroraEntity, SensorEntity):
|
||||||
"""Representation of a Sensor on a Aurora ABB PowerOne Solar inverter."""
|
"""Representation of a Sensor on a Aurora ABB PowerOne Solar inverter."""
|
||||||
|
|
||||||
|
_attr_has_entity_name = True
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
client: AuroraSerialClient,
|
client: AuroraSerialClient,
|
||||||
|
@ -18,5 +18,15 @@
|
|||||||
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]",
|
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]",
|
||||||
"no_serial_ports": "No com ports found. Need a valid RS485 device to communicate."
|
"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.config_entries.async_setup(mock_entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
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
|
||||||
assert power.state == "45.7"
|
assert power.state == "45.7"
|
||||||
|
|
||||||
temperature = hass.states.get("sensor.temperature")
|
temperature = hass.states.get("sensor.mydevicename_temperature")
|
||||||
assert temperature
|
assert temperature
|
||||||
assert temperature.state == "9.9"
|
assert temperature.state == "9.9"
|
||||||
|
|
||||||
energy = hass.states.get("sensor.total_energy")
|
energy = hass.states.get("sensor.mydevicename_total_energy")
|
||||||
assert energy
|
assert energy
|
||||||
assert energy.state == "12.35"
|
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.config_entries.async_setup(mock_entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
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 is not None
|
||||||
assert power.state == "45.7"
|
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))
|
async_fire_time_changed(hass, utcnow + timedelta(seconds=60))
|
||||||
await hass.async_block_till_done()
|
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"
|
assert power.state == "unknown"
|
||||||
# sun rose again
|
# sun rose again
|
||||||
with patch("aurorapy.client.AuroraSerialClient.connect", return_value=None), patch(
|
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))
|
async_fire_time_changed(hass, utcnow + timedelta(seconds=60))
|
||||||
await hass.async_block_till_done()
|
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 is not None
|
||||||
assert power.state == "45.7"
|
assert power.state == "45.7"
|
||||||
# sunset
|
# sunset
|
||||||
@ -149,7 +149,7 @@ async def test_sensor_dark(hass: HomeAssistant) -> None:
|
|||||||
):
|
):
|
||||||
async_fire_time_changed(hass, utcnow + timedelta(seconds=60))
|
async_fire_time_changed(hass, utcnow + timedelta(seconds=60))
|
||||||
await hass.async_block_till_done()
|
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'?
|
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)
|
mock_entry.add_to_hass(hass)
|
||||||
await hass.config_entries.async_setup(mock_entry.entry_id)
|
await hass.config_entries.async_setup(mock_entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
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
|
assert power is None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user