mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
Prefix sma sensor name (#65234)
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
This commit is contained in:
parent
27038fda27
commit
496583bca5
@ -84,7 +84,12 @@ class SMAsensor(CoordinatorEntity, SensorEntity):
|
||||
@property
|
||||
def name(self) -> str:
|
||||
"""Return the name of the sensor."""
|
||||
return self._sensor.name
|
||||
if self._attr_device_info is None or not (
|
||||
name_prefix := self._attr_device_info.get("name")
|
||||
):
|
||||
name_prefix = "SMA"
|
||||
|
||||
return f"{name_prefix} {self._sensor.name}"
|
||||
|
||||
@property
|
||||
def native_value(self) -> StateType:
|
||||
|
@ -4,6 +4,6 @@ from homeassistant.const import ATTR_UNIT_OF_MEASUREMENT, POWER_WATT
|
||||
|
||||
async def test_sensors(hass, init_integration):
|
||||
"""Test states of the sensors."""
|
||||
state = hass.states.get("sensor.grid_power")
|
||||
state = hass.states.get("sensor.sma_device_grid_power")
|
||||
assert state
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == POWER_WATT
|
||||
|
Loading…
x
Reference in New Issue
Block a user