Use better names for zwave_js platforms that are self describing (#46083)
* use better names for platforms that are self describing * add missing light change * fix tests * only use value_name in sensors and binary_sensors
This commit is contained in:
parent
ee98ea89dd
commit
af4e6f856f
9 changed files with 50 additions and 22 deletions
|
@ -257,6 +257,16 @@ async def async_setup_entry(
|
|||
class ZWaveBooleanBinarySensor(ZWaveBaseEntity, BinarySensorEntity):
|
||||
"""Representation of a Z-Wave binary_sensor."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
config_entry: ConfigEntry,
|
||||
client: ZwaveClient,
|
||||
info: ZwaveDiscoveryInfo,
|
||||
) -> None:
|
||||
"""Initialize a ZWaveBooleanBinarySensor entity."""
|
||||
super().__init__(config_entry, client, info)
|
||||
self._name = self.generate_name(include_value_name=True)
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool:
|
||||
"""Return if the sensor is on or off."""
|
||||
|
@ -294,8 +304,9 @@ class ZWaveNotificationBinarySensor(ZWaveBaseEntity, BinarySensorEntity):
|
|||
super().__init__(config_entry, client, info)
|
||||
self.state_key = state_key
|
||||
self._name = self.generate_name(
|
||||
self.info.primary_value.property_name,
|
||||
[self.info.primary_value.metadata.states[self.state_key]],
|
||||
include_value_name=True,
|
||||
alternate_value_name=self.info.primary_value.property_name,
|
||||
additional_info=[self.info.primary_value.metadata.states[self.state_key]],
|
||||
)
|
||||
# check if we have a custom mapping for this value
|
||||
self._mapping_info = self._get_sensor_mapping()
|
||||
|
@ -347,6 +358,7 @@ class ZWavePropertyBinarySensor(ZWaveBaseEntity, BinarySensorEntity):
|
|||
super().__init__(config_entry, client, info)
|
||||
# check if we have a custom mapping for this value
|
||||
self._mapping_info = self._get_sensor_mapping()
|
||||
self._name = self.generate_name(include_value_name=True)
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool:
|
||||
|
|
|
@ -64,20 +64,22 @@ class ZWaveBaseEntity(Entity):
|
|||
|
||||
def generate_name(
|
||||
self,
|
||||
include_value_name: bool = False,
|
||||
alternate_value_name: Optional[str] = None,
|
||||
additional_info: Optional[List[str]] = None,
|
||||
) -> str:
|
||||
"""Generate entity name."""
|
||||
if additional_info is None:
|
||||
additional_info = []
|
||||
node_name = self.info.node.name or self.info.node.device_config.description
|
||||
name: str = self.info.node.name or self.info.node.device_config.description
|
||||
if include_value_name:
|
||||
value_name = (
|
||||
alternate_value_name
|
||||
or self.info.primary_value.metadata.label
|
||||
or self.info.primary_value.property_key_name
|
||||
or self.info.primary_value.property_name
|
||||
)
|
||||
name = f"{node_name}: {value_name}"
|
||||
name = f"{name}: {value_name}"
|
||||
for item in additional_info:
|
||||
if item:
|
||||
name += f" - {item}"
|
||||
|
|
|
@ -64,6 +64,16 @@ async def async_setup_entry(
|
|||
class ZwaveSensorBase(ZWaveBaseEntity):
|
||||
"""Basic Representation of a Z-Wave sensor."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
config_entry: ConfigEntry,
|
||||
client: ZwaveClient,
|
||||
info: ZwaveDiscoveryInfo,
|
||||
) -> None:
|
||||
"""Initialize a ZWaveSensorBase entity."""
|
||||
super().__init__(config_entry, client, info)
|
||||
self._name = self.generate_name(include_value_name=True)
|
||||
|
||||
@property
|
||||
def device_class(self) -> Optional[str]:
|
||||
"""Return the device class of the sensor."""
|
||||
|
@ -132,7 +142,10 @@ class ZWaveNumericSensor(ZwaveSensorBase):
|
|||
"""Initialize a ZWaveNumericSensor entity."""
|
||||
super().__init__(config_entry, client, info)
|
||||
if self.info.primary_value.command_class == CommandClass.BASIC:
|
||||
self._name = self.generate_name(self.info.primary_value.command_class_name)
|
||||
self._name = self.generate_name(
|
||||
include_value_name=True,
|
||||
alternate_value_name=self.info.primary_value.command_class_name,
|
||||
)
|
||||
|
||||
@property
|
||||
def state(self) -> float:
|
||||
|
@ -166,8 +179,9 @@ class ZWaveListSensor(ZwaveSensorBase):
|
|||
"""Initialize a ZWaveListSensor entity."""
|
||||
super().__init__(config_entry, client, info)
|
||||
self._name = self.generate_name(
|
||||
self.info.primary_value.property_name,
|
||||
[self.info.primary_value.property_key_name],
|
||||
include_value_name=True,
|
||||
alternate_value_name=self.info.primary_value.property_name,
|
||||
additional_info=[self.info.primary_value.property_key_name],
|
||||
)
|
||||
|
||||
@property
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
AIR_TEMPERATURE_SENSOR = "sensor.multisensor_6_air_temperature"
|
||||
ENERGY_SENSOR = "sensor.smart_plug_with_two_usb_ports_value_electric_consumed_2"
|
||||
POWER_SENSOR = "sensor.smart_plug_with_two_usb_ports_value_electric_consumed"
|
||||
SWITCH_ENTITY = "switch.smart_plug_with_two_usb_ports_current_value"
|
||||
SWITCH_ENTITY = "switch.smart_plug_with_two_usb_ports"
|
||||
LOW_BATTERY_BINARY_SENSOR = "binary_sensor.multisensor_6_low_battery_level"
|
||||
ENABLED_LEGACY_BINARY_SENSOR = "binary_sensor.z_wave_door_window_sensor_any"
|
||||
DISABLED_LEGACY_BINARY_SENSOR = "binary_sensor.multisensor_6_any"
|
||||
|
|
|
@ -25,9 +25,9 @@ from homeassistant.components.climate.const import (
|
|||
)
|
||||
from homeassistant.const import ATTR_ENTITY_ID, ATTR_TEMPERATURE
|
||||
|
||||
CLIMATE_RADIO_THERMOSTAT_ENTITY = "climate.z_wave_thermostat_thermostat_mode"
|
||||
CLIMATE_DANFOSS_LC13_ENTITY = "climate.living_connect_z_thermostat_heating"
|
||||
CLIMATE_FLOOR_THERMOSTAT_ENTITY = "climate.floor_thermostat_thermostat_mode"
|
||||
CLIMATE_RADIO_THERMOSTAT_ENTITY = "climate.z_wave_thermostat"
|
||||
CLIMATE_DANFOSS_LC13_ENTITY = "climate.living_connect_z_thermostat"
|
||||
CLIMATE_FLOOR_THERMOSTAT_ENTITY = "climate.floor_thermostat"
|
||||
|
||||
|
||||
async def test_thermostat_v2(
|
||||
|
|
|
@ -3,7 +3,7 @@ from zwave_js_server.event import Event
|
|||
|
||||
from homeassistant.components.cover import ATTR_CURRENT_POSITION
|
||||
|
||||
WINDOW_COVER_ENTITY = "cover.zws_12_current_value"
|
||||
WINDOW_COVER_ENTITY = "cover.zws_12"
|
||||
|
||||
|
||||
async def test_cover(hass, client, chain_actuator_zws12, integration):
|
||||
|
|
|
@ -4,7 +4,7 @@ from zwave_js_server.event import Event
|
|||
|
||||
from homeassistant.components.fan import ATTR_SPEED, SPEED_MEDIUM
|
||||
|
||||
FAN_ENTITY = "fan.in_wall_smart_fan_control_current_value"
|
||||
FAN_ENTITY = "fan.in_wall_smart_fan_control"
|
||||
|
||||
|
||||
async def test_fan(hass, client, in_wall_smart_fan_control, integration):
|
||||
|
|
|
@ -12,8 +12,8 @@ from homeassistant.components.light import (
|
|||
)
|
||||
from homeassistant.const import ATTR_SUPPORTED_FEATURES, STATE_OFF, STATE_ON
|
||||
|
||||
BULB_6_MULTI_COLOR_LIGHT_ENTITY = "light.bulb_6_multi_color_current_value"
|
||||
EATON_RF9640_ENTITY = "light.allloaddimmer_current_value"
|
||||
BULB_6_MULTI_COLOR_LIGHT_ENTITY = "light.bulb_6_multi_color"
|
||||
EATON_RF9640_ENTITY = "light.allloaddimmer"
|
||||
|
||||
|
||||
async def test_light(hass, client, bulb_6_multi_color, integration):
|
||||
|
|
|
@ -14,7 +14,7 @@ from homeassistant.components.zwave_js.lock import (
|
|||
)
|
||||
from homeassistant.const import ATTR_ENTITY_ID, STATE_LOCKED, STATE_UNLOCKED
|
||||
|
||||
SCHLAGE_BE469_LOCK_ENTITY = "lock.touchscreen_deadbolt_current_lock_mode"
|
||||
SCHLAGE_BE469_LOCK_ENTITY = "lock.touchscreen_deadbolt"
|
||||
|
||||
|
||||
async def test_door_lock(hass, client, lock_schlage_be469, integration):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue