mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 01:08:12 +00:00
Migrate Goalzero to new entity naming style (#75358)
This commit is contained in:
parent
ca5065a627
commit
6fdb414b58
@ -26,7 +26,7 @@ BINARY_SENSOR_TYPES: tuple[BinarySensorEntityDescription, ...] = (
|
||||
),
|
||||
BinarySensorEntityDescription(
|
||||
key="app_online",
|
||||
name="App Online",
|
||||
name="App online",
|
||||
device_class=BinarySensorDeviceClass.CONNECTIVITY,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
@ -37,7 +37,7 @@ BINARY_SENSOR_TYPES: tuple[BinarySensorEntityDescription, ...] = (
|
||||
),
|
||||
BinarySensorEntityDescription(
|
||||
key="inputDetected",
|
||||
name="Input Detected",
|
||||
name="Input detected",
|
||||
device_class=BinarySensorDeviceClass.POWER,
|
||||
),
|
||||
)
|
||||
|
@ -15,6 +15,7 @@ class GoalZeroEntity(CoordinatorEntity[GoalZeroDataUpdateCoordinator]):
|
||||
"""Representation of a Goal Zero Yeti entity."""
|
||||
|
||||
_attr_attribution = ATTRIBUTION
|
||||
_attr_has_entity_name = True
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
@ -24,9 +25,6 @@ class GoalZeroEntity(CoordinatorEntity[GoalZeroDataUpdateCoordinator]):
|
||||
"""Initialize a Goal Zero Yeti entity."""
|
||||
super().__init__(coordinator)
|
||||
self.entity_description = description
|
||||
self._attr_name = (
|
||||
f"{coordinator.config_entry.data[CONF_NAME]} {description.name}"
|
||||
)
|
||||
self._attr_unique_id = f"{coordinator.config_entry.entry_id}/{description.key}"
|
||||
|
||||
@property
|
||||
@ -37,7 +35,7 @@ class GoalZeroEntity(CoordinatorEntity[GoalZeroDataUpdateCoordinator]):
|
||||
identifiers={(DOMAIN, self.coordinator.config_entry.entry_id)},
|
||||
manufacturer=MANUFACTURER,
|
||||
model=self._api.sysdata[ATTR_MODEL],
|
||||
name=self.coordinator.config_entry.data[CONF_NAME],
|
||||
name=self.coordinator.config_entry.data[CONF_NAME].capitalize(),
|
||||
sw_version=self._api.data["firmwareVersion"],
|
||||
)
|
||||
|
||||
|
@ -32,14 +32,14 @@ from .entity import GoalZeroEntity
|
||||
SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
||||
SensorEntityDescription(
|
||||
key="wattsIn",
|
||||
name="Watts In",
|
||||
name="Watts in",
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="ampsIn",
|
||||
name="Amps In",
|
||||
name="Amps in",
|
||||
device_class=SensorDeviceClass.CURRENT,
|
||||
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
@ -47,14 +47,14 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="wattsOut",
|
||||
name="Watts Out",
|
||||
name="Watts out",
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="ampsOut",
|
||||
name="Amps Out",
|
||||
name="Amps out",
|
||||
device_class=SensorDeviceClass.CURRENT,
|
||||
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
@ -62,7 +62,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="whOut",
|
||||
name="WH Out",
|
||||
name="Wh out",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
@ -70,7 +70,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="whStored",
|
||||
name="WH Stored",
|
||||
name="Wh stored",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
@ -84,13 +84,13 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="socPercent",
|
||||
name="State of Charge Percent",
|
||||
name="State of charge percent",
|
||||
device_class=SensorDeviceClass.BATTERY,
|
||||
native_unit_of_measurement=PERCENTAGE,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="timeToEmptyFull",
|
||||
name="Time to Empty/Full",
|
||||
name="Time to empty/full",
|
||||
device_class=TIME_MINUTES,
|
||||
native_unit_of_measurement=TIME_MINUTES,
|
||||
),
|
||||
@ -103,7 +103,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="wifiStrength",
|
||||
name="Wifi Strength",
|
||||
name="Wi-Fi strength",
|
||||
device_class=SensorDeviceClass.SIGNAL_STRENGTH,
|
||||
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS,
|
||||
entity_registry_enabled_default=False,
|
||||
@ -111,7 +111,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="timestamp",
|
||||
name="Total Run Time",
|
||||
name="Total run time",
|
||||
native_unit_of_measurement=TIME_SECONDS,
|
||||
entity_registry_enabled_default=False,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
@ -124,7 +124,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="ipAddr",
|
||||
name="IP Address",
|
||||
name="IP address",
|
||||
entity_registry_enabled_default=False,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
|
@ -14,15 +14,15 @@ from .entity import GoalZeroEntity
|
||||
SWITCH_TYPES: tuple[SwitchEntityDescription, ...] = (
|
||||
SwitchEntityDescription(
|
||||
key="v12PortStatus",
|
||||
name="12V Port Status",
|
||||
name="12V port status",
|
||||
),
|
||||
SwitchEntityDescription(
|
||||
key="usbPortStatus",
|
||||
name="USB Port Status",
|
||||
name="USB port status",
|
||||
),
|
||||
SwitchEntityDescription(
|
||||
key="acPortStatus",
|
||||
name="AC Port Status",
|
||||
name="AC port status",
|
||||
),
|
||||
)
|
||||
|
||||
|
@ -85,7 +85,7 @@ async def test_sensors(
|
||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.TEMPERATURE
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == TEMP_CELSIUS
|
||||
assert state.attributes.get(ATTR_STATE_CLASS) is None
|
||||
state = hass.states.get(f"sensor.{DEFAULT_NAME}_wifi_strength")
|
||||
state = hass.states.get(f"sensor.{DEFAULT_NAME}_wi_fi_strength")
|
||||
assert state.state == "-62"
|
||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.SIGNAL_STRENGTH
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == SIGNAL_STRENGTH_DECIBELS
|
||||
|
Loading…
x
Reference in New Issue
Block a user