Convert rfxtrx to entity naming (#74720)
parent
8bf692d046
commit
3a5cca3ff2
|
@ -456,6 +456,9 @@ class RfxtrxEntity(RestoreEntity):
|
||||||
Contains the common logic for Rfxtrx lights and switches.
|
Contains the common logic for Rfxtrx lights and switches.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
_attr_assumed_state = True
|
||||||
|
_attr_has_entity_name = True
|
||||||
|
_attr_should_poll = False
|
||||||
_device: rfxtrxmod.RFXtrxDevice
|
_device: rfxtrxmod.RFXtrxDevice
|
||||||
_event: rfxtrxmod.RFXtrxEvent | None
|
_event: rfxtrxmod.RFXtrxEvent | None
|
||||||
|
|
||||||
|
@ -466,7 +469,6 @@ class RfxtrxEntity(RestoreEntity):
|
||||||
event: rfxtrxmod.RFXtrxEvent | None = None,
|
event: rfxtrxmod.RFXtrxEvent | None = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize the device."""
|
"""Initialize the device."""
|
||||||
self._name = f"{device.type_string} {device.id_string}"
|
|
||||||
self._device = device
|
self._device = device
|
||||||
self._event = event
|
self._event = event
|
||||||
self._device_id = device_id
|
self._device_id = device_id
|
||||||
|
@ -484,16 +486,6 @@ class RfxtrxEntity(RestoreEntity):
|
||||||
async_dispatcher_connect(self.hass, SIGNAL_EVENT, self._handle_event)
|
async_dispatcher_connect(self.hass, SIGNAL_EVENT, self._handle_event)
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
|
||||||
def should_poll(self):
|
|
||||||
"""No polling needed for a RFXtrx switch."""
|
|
||||||
return False
|
|
||||||
|
|
||||||
@property
|
|
||||||
def name(self):
|
|
||||||
"""Return the name of the device if any."""
|
|
||||||
return self._name
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def extra_state_attributes(self):
|
def extra_state_attributes(self):
|
||||||
"""Return the device state attributes."""
|
"""Return the device state attributes."""
|
||||||
|
@ -501,11 +493,6 @@ class RfxtrxEntity(RestoreEntity):
|
||||||
return None
|
return None
|
||||||
return {ATTR_EVENT: "".join(f"{x:02x}" for x in self._event.data)}
|
return {ATTR_EVENT: "".join(f"{x:02x}" for x in self._event.data)}
|
||||||
|
|
||||||
@property
|
|
||||||
def assumed_state(self):
|
|
||||||
"""Return true if unable to access real state of entity."""
|
|
||||||
return True
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
"""Return unique identifier of remote device."""
|
"""Return unique identifier of remote device."""
|
||||||
|
|
|
@ -63,12 +63,14 @@ class RfxtrxSensorEntityDescription(SensorEntityDescription):
|
||||||
SENSOR_TYPES = (
|
SENSOR_TYPES = (
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Barometer",
|
key="Barometer",
|
||||||
|
name="Barometer",
|
||||||
device_class=SensorDeviceClass.PRESSURE,
|
device_class=SensorDeviceClass.PRESSURE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=PRESSURE_HPA,
|
native_unit_of_measurement=PRESSURE_HPA,
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Battery numeric",
|
key="Battery numeric",
|
||||||
|
name="Battery",
|
||||||
device_class=SensorDeviceClass.BATTERY,
|
device_class=SensorDeviceClass.BATTERY,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
|
@ -77,42 +79,49 @@ SENSOR_TYPES = (
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Current",
|
key="Current",
|
||||||
|
name="Current",
|
||||||
device_class=SensorDeviceClass.CURRENT,
|
device_class=SensorDeviceClass.CURRENT,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Current Ch. 1",
|
key="Current Ch. 1",
|
||||||
|
name="Current Ch. 1",
|
||||||
device_class=SensorDeviceClass.CURRENT,
|
device_class=SensorDeviceClass.CURRENT,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Current Ch. 2",
|
key="Current Ch. 2",
|
||||||
|
name="Current Ch. 2",
|
||||||
device_class=SensorDeviceClass.CURRENT,
|
device_class=SensorDeviceClass.CURRENT,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Current Ch. 3",
|
key="Current Ch. 3",
|
||||||
|
name="Current Ch. 3",
|
||||||
device_class=SensorDeviceClass.CURRENT,
|
device_class=SensorDeviceClass.CURRENT,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Energy usage",
|
key="Energy usage",
|
||||||
|
name="Instantaneous power",
|
||||||
device_class=SensorDeviceClass.POWER,
|
device_class=SensorDeviceClass.POWER,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=POWER_WATT,
|
native_unit_of_measurement=POWER_WATT,
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Humidity",
|
key="Humidity",
|
||||||
|
name="Humidity",
|
||||||
device_class=SensorDeviceClass.HUMIDITY,
|
device_class=SensorDeviceClass.HUMIDITY,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Rssi numeric",
|
key="Rssi numeric",
|
||||||
|
name="Signal strength",
|
||||||
device_class=SensorDeviceClass.SIGNAL_STRENGTH,
|
device_class=SensorDeviceClass.SIGNAL_STRENGTH,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
||||||
|
@ -121,86 +130,104 @@ SENSOR_TYPES = (
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Temperature",
|
key="Temperature",
|
||||||
|
name="Temperature",
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Temperature2",
|
key="Temperature2",
|
||||||
|
name="Temperature 2",
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Total usage",
|
key="Total usage",
|
||||||
|
name="Total energy usage",
|
||||||
device_class=SensorDeviceClass.ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Voltage",
|
key="Voltage",
|
||||||
|
name="Voltage",
|
||||||
device_class=SensorDeviceClass.VOLTAGE,
|
device_class=SensorDeviceClass.VOLTAGE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Wind direction",
|
key="Wind direction",
|
||||||
|
name="Wind direction",
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=DEGREE,
|
native_unit_of_measurement=DEGREE,
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Rain rate",
|
key="Rain rate",
|
||||||
|
name="Rain rate",
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=PRECIPITATION_MILLIMETERS_PER_HOUR,
|
native_unit_of_measurement=PRECIPITATION_MILLIMETERS_PER_HOUR,
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Sound",
|
key="Sound",
|
||||||
|
name="Sound",
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Sensor Status",
|
key="Sensor Status",
|
||||||
|
name="Sensor status",
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Count",
|
key="Count",
|
||||||
|
name="Count",
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
native_unit_of_measurement="count",
|
native_unit_of_measurement="count",
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Counter value",
|
key="Counter value",
|
||||||
|
name="Counter value",
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
native_unit_of_measurement="count",
|
native_unit_of_measurement="count",
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Chill",
|
key="Chill",
|
||||||
|
name="Chill",
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Wind average speed",
|
key="Wind average speed",
|
||||||
|
name="Wind average speed",
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=SPEED_METERS_PER_SECOND,
|
native_unit_of_measurement=SPEED_METERS_PER_SECOND,
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Wind gust",
|
key="Wind gust",
|
||||||
|
name="Wind gust",
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=SPEED_METERS_PER_SECOND,
|
native_unit_of_measurement=SPEED_METERS_PER_SECOND,
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Rain total",
|
key="Rain total",
|
||||||
|
name="Rain total",
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=LENGTH_MILLIMETERS,
|
native_unit_of_measurement=LENGTH_MILLIMETERS,
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Forecast",
|
key="Forecast",
|
||||||
|
name="Forecast status",
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Forecast numeric",
|
key="Forecast numeric",
|
||||||
|
name="Forecast",
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Humidity status",
|
key="Humidity status",
|
||||||
|
name="Humidity status",
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="UV",
|
key="UV",
|
||||||
|
name="UV index",
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=UV_INDEX,
|
native_unit_of_measurement=UV_INDEX,
|
||||||
),
|
),
|
||||||
|
@ -252,7 +279,6 @@ class RfxtrxSensor(RfxtrxEntity, SensorEntity):
|
||||||
"""Initialize the sensor."""
|
"""Initialize the sensor."""
|
||||||
super().__init__(device, device_id, event=event)
|
super().__init__(device, device_id, event=event)
|
||||||
self.entity_description = entity_description
|
self.entity_description = entity_description
|
||||||
self._name = f"{device.type_string} {device.id_string} {entity_description.key}"
|
|
||||||
self._unique_id = "_".join(
|
self._unique_id = "_".join(
|
||||||
x for x in (*self._device_id, entity_description.key)
|
x for x in (*self._device_id, entity_description.key)
|
||||||
)
|
)
|
||||||
|
|
|
@ -475,11 +475,11 @@ async def test_options_replace_sensor_device(hass):
|
||||||
await start_options_flow(hass, entry)
|
await start_options_flow(hass, entry)
|
||||||
|
|
||||||
state = hass.states.get(
|
state = hass.states.get(
|
||||||
"sensor.thgn122_123_thgn132_thgr122_228_238_268_f0_04_rssi_numeric"
|
"sensor.thgn122_123_thgn132_thgr122_228_238_268_f0_04_signal_strength"
|
||||||
)
|
)
|
||||||
assert state
|
assert state
|
||||||
state = hass.states.get(
|
state = hass.states.get(
|
||||||
"sensor.thgn122_123_thgn132_thgr122_228_238_268_f0_04_battery_numeric"
|
"sensor.thgn122_123_thgn132_thgr122_228_238_268_f0_04_battery"
|
||||||
)
|
)
|
||||||
assert state
|
assert state
|
||||||
state = hass.states.get(
|
state = hass.states.get(
|
||||||
|
@ -495,11 +495,11 @@ async def test_options_replace_sensor_device(hass):
|
||||||
)
|
)
|
||||||
assert state
|
assert state
|
||||||
state = hass.states.get(
|
state = hass.states.get(
|
||||||
"sensor.thgn122_123_thgn132_thgr122_228_238_268_23_04_rssi_numeric"
|
"sensor.thgn122_123_thgn132_thgr122_228_238_268_23_04_signal_strength"
|
||||||
)
|
)
|
||||||
assert state
|
assert state
|
||||||
state = hass.states.get(
|
state = hass.states.get(
|
||||||
"sensor.thgn122_123_thgn132_thgr122_228_238_268_23_04_battery_numeric"
|
"sensor.thgn122_123_thgn132_thgr122_228_238_268_23_04_battery"
|
||||||
)
|
)
|
||||||
assert state
|
assert state
|
||||||
state = hass.states.get(
|
state = hass.states.get(
|
||||||
|
@ -565,7 +565,7 @@ async def test_options_replace_sensor_device(hass):
|
||||||
entity_registry = er.async_get(hass)
|
entity_registry = er.async_get(hass)
|
||||||
|
|
||||||
entry = entity_registry.async_get(
|
entry = entity_registry.async_get(
|
||||||
"sensor.thgn122_123_thgn132_thgr122_228_238_268_f0_04_rssi_numeric"
|
"sensor.thgn122_123_thgn132_thgr122_228_238_268_f0_04_signal_strength"
|
||||||
)
|
)
|
||||||
assert entry
|
assert entry
|
||||||
assert entry.device_id == new_device
|
assert entry.device_id == new_device
|
||||||
|
@ -580,7 +580,7 @@ async def test_options_replace_sensor_device(hass):
|
||||||
assert entry
|
assert entry
|
||||||
assert entry.device_id == new_device
|
assert entry.device_id == new_device
|
||||||
entry = entity_registry.async_get(
|
entry = entity_registry.async_get(
|
||||||
"sensor.thgn122_123_thgn132_thgr122_228_238_268_f0_04_battery_numeric"
|
"sensor.thgn122_123_thgn132_thgr122_228_238_268_f0_04_battery"
|
||||||
)
|
)
|
||||||
assert entry
|
assert entry
|
||||||
assert entry.device_id == new_device
|
assert entry.device_id == new_device
|
||||||
|
@ -591,11 +591,11 @@ async def test_options_replace_sensor_device(hass):
|
||||||
assert entry.device_id == new_device
|
assert entry.device_id == new_device
|
||||||
|
|
||||||
state = hass.states.get(
|
state = hass.states.get(
|
||||||
"sensor.thgn122_123_thgn132_thgr122_228_238_268_23_04_rssi_numeric"
|
"sensor.thgn122_123_thgn132_thgr122_228_238_268_23_04_signal_strength"
|
||||||
)
|
)
|
||||||
assert not state
|
assert not state
|
||||||
state = hass.states.get(
|
state = hass.states.get(
|
||||||
"sensor.thgn122_123_thgn132_thgr122_228_238_268_23_04_battery_numeric"
|
"sensor.thgn122_123_thgn132_thgr122_228_238_268_23_04_battery"
|
||||||
)
|
)
|
||||||
assert not state
|
assert not state
|
||||||
state = hass.states.get(
|
state = hass.states.get(
|
||||||
|
@ -637,13 +637,13 @@ async def test_options_replace_control_device(hass):
|
||||||
|
|
||||||
state = hass.states.get("binary_sensor.ac_118cdea_2")
|
state = hass.states.get("binary_sensor.ac_118cdea_2")
|
||||||
assert state
|
assert state
|
||||||
state = hass.states.get("sensor.ac_118cdea_2_rssi_numeric")
|
state = hass.states.get("sensor.ac_118cdea_2_signal_strength")
|
||||||
assert state
|
assert state
|
||||||
state = hass.states.get("switch.ac_118cdea_2")
|
state = hass.states.get("switch.ac_118cdea_2")
|
||||||
assert state
|
assert state
|
||||||
state = hass.states.get("binary_sensor.ac_1118cdea_2")
|
state = hass.states.get("binary_sensor.ac_1118cdea_2")
|
||||||
assert state
|
assert state
|
||||||
state = hass.states.get("sensor.ac_1118cdea_2_rssi_numeric")
|
state = hass.states.get("sensor.ac_1118cdea_2_signal_strength")
|
||||||
assert state
|
assert state
|
||||||
state = hass.states.get("switch.ac_1118cdea_2")
|
state = hass.states.get("switch.ac_1118cdea_2")
|
||||||
assert state
|
assert state
|
||||||
|
@ -700,7 +700,7 @@ async def test_options_replace_control_device(hass):
|
||||||
entry = entity_registry.async_get("binary_sensor.ac_118cdea_2")
|
entry = entity_registry.async_get("binary_sensor.ac_118cdea_2")
|
||||||
assert entry
|
assert entry
|
||||||
assert entry.device_id == new_device
|
assert entry.device_id == new_device
|
||||||
entry = entity_registry.async_get("sensor.ac_118cdea_2_rssi_numeric")
|
entry = entity_registry.async_get("sensor.ac_118cdea_2_signal_strength")
|
||||||
assert entry
|
assert entry
|
||||||
assert entry.device_id == new_device
|
assert entry.device_id == new_device
|
||||||
entry = entity_registry.async_get("switch.ac_118cdea_2")
|
entry = entity_registry.async_get("switch.ac_118cdea_2")
|
||||||
|
@ -709,7 +709,7 @@ async def test_options_replace_control_device(hass):
|
||||||
|
|
||||||
state = hass.states.get("binary_sensor.ac_1118cdea_2")
|
state = hass.states.get("binary_sensor.ac_1118cdea_2")
|
||||||
assert not state
|
assert not state
|
||||||
state = hass.states.get("sensor.ac_1118cdea_2_rssi_numeric")
|
state = hass.states.get("sensor.ac_1118cdea_2_signal_strength")
|
||||||
assert not state
|
assert not state
|
||||||
state = hass.states.get("switch.ac_1118cdea_2")
|
state = hass.states.get("switch.ac_1118cdea_2")
|
||||||
assert not state
|
assert not state
|
||||||
|
|
|
@ -101,19 +101,19 @@ async def test_one_sensor_no_datatype(hass, rfxtrx):
|
||||||
assert state.attributes.get("friendly_name") == f"{base_name} Humidity status"
|
assert state.attributes.get("friendly_name") == f"{base_name} Humidity status"
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is None
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is None
|
||||||
|
|
||||||
state = hass.states.get(f"{base_id}_rssi_numeric")
|
state = hass.states.get(f"{base_id}_signal_strength")
|
||||||
assert state
|
assert state
|
||||||
assert state.state == "unknown"
|
assert state.state == "unknown"
|
||||||
assert state.attributes.get("friendly_name") == f"{base_name} Rssi numeric"
|
assert state.attributes.get("friendly_name") == f"{base_name} Signal strength"
|
||||||
assert (
|
assert (
|
||||||
state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
|
state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
|
||||||
== SIGNAL_STRENGTH_DECIBELS_MILLIWATT
|
== SIGNAL_STRENGTH_DECIBELS_MILLIWATT
|
||||||
)
|
)
|
||||||
|
|
||||||
state = hass.states.get(f"{base_id}_battery_numeric")
|
state = hass.states.get(f"{base_id}_battery")
|
||||||
assert state
|
assert state
|
||||||
assert state.state == "unknown"
|
assert state.state == "unknown"
|
||||||
assert state.attributes.get("friendly_name") == f"{base_name} Battery numeric"
|
assert state.attributes.get("friendly_name") == f"{base_name} Battery"
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
|
||||||
|
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ async def test_discover_sensor(hass, rfxtrx_automatic):
|
||||||
assert state.state == "normal"
|
assert state.state == "normal"
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is None
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is None
|
||||||
|
|
||||||
state = hass.states.get(f"{base_id}_rssi_numeric")
|
state = hass.states.get(f"{base_id}_signal_strength")
|
||||||
assert state
|
assert state
|
||||||
assert state.state == "-64"
|
assert state.state == "-64"
|
||||||
assert (
|
assert (
|
||||||
|
@ -192,7 +192,7 @@ async def test_discover_sensor(hass, rfxtrx_automatic):
|
||||||
assert state.state == "18.4"
|
assert state.state == "18.4"
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == TEMP_CELSIUS
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == TEMP_CELSIUS
|
||||||
|
|
||||||
state = hass.states.get(f"{base_id}_battery_numeric")
|
state = hass.states.get(f"{base_id}_battery")
|
||||||
assert state
|
assert state
|
||||||
assert state.state == "100"
|
assert state.state == "100"
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
|
||||||
|
@ -211,7 +211,7 @@ async def test_discover_sensor(hass, rfxtrx_automatic):
|
||||||
assert state.state == "normal"
|
assert state.state == "normal"
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is None
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is None
|
||||||
|
|
||||||
state = hass.states.get(f"{base_id}_rssi_numeric")
|
state = hass.states.get(f"{base_id}_signal_strength")
|
||||||
assert state
|
assert state
|
||||||
assert state.state == "-64"
|
assert state.state == "-64"
|
||||||
assert (
|
assert (
|
||||||
|
@ -224,7 +224,7 @@ async def test_discover_sensor(hass, rfxtrx_automatic):
|
||||||
assert state.state == "14.9"
|
assert state.state == "14.9"
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == TEMP_CELSIUS
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == TEMP_CELSIUS
|
||||||
|
|
||||||
state = hass.states.get(f"{base_id}_battery_numeric")
|
state = hass.states.get(f"{base_id}_battery")
|
||||||
assert state
|
assert state
|
||||||
assert state.state == "100"
|
assert state.state == "100"
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
|
||||||
|
@ -243,7 +243,7 @@ async def test_discover_sensor(hass, rfxtrx_automatic):
|
||||||
assert state.state == "normal"
|
assert state.state == "normal"
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is None
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is None
|
||||||
|
|
||||||
state = hass.states.get(f"{base_id}_rssi_numeric")
|
state = hass.states.get(f"{base_id}_signal_strength")
|
||||||
assert state
|
assert state
|
||||||
assert state.state == "-64"
|
assert state.state == "-64"
|
||||||
assert (
|
assert (
|
||||||
|
@ -256,7 +256,7 @@ async def test_discover_sensor(hass, rfxtrx_automatic):
|
||||||
assert state.state == "17.9"
|
assert state.state == "17.9"
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == TEMP_CELSIUS
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == TEMP_CELSIUS
|
||||||
|
|
||||||
state = hass.states.get(f"{base_id}_battery_numeric")
|
state = hass.states.get(f"{base_id}_battery")
|
||||||
assert state
|
assert state
|
||||||
assert state.state == "100"
|
assert state.state == "100"
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
|
||||||
|
@ -328,19 +328,19 @@ async def test_rssi_sensor(hass, rfxtrx):
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
await hass.async_start()
|
await hass.async_start()
|
||||||
|
|
||||||
state = hass.states.get("sensor.pt2262_22670e_rssi_numeric")
|
state = hass.states.get("sensor.pt2262_22670e_signal_strength")
|
||||||
assert state
|
assert state
|
||||||
assert state.state == "unknown"
|
assert state.state == "unknown"
|
||||||
assert state.attributes.get("friendly_name") == "PT2262 22670e Rssi numeric"
|
assert state.attributes.get("friendly_name") == "PT2262 22670e Signal strength"
|
||||||
assert (
|
assert (
|
||||||
state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
|
state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
|
||||||
== SIGNAL_STRENGTH_DECIBELS_MILLIWATT
|
== SIGNAL_STRENGTH_DECIBELS_MILLIWATT
|
||||||
)
|
)
|
||||||
|
|
||||||
state = hass.states.get("sensor.ac_213c7f2_48_rssi_numeric")
|
state = hass.states.get("sensor.ac_213c7f2_48_signal_strength")
|
||||||
assert state
|
assert state
|
||||||
assert state.state == "unknown"
|
assert state.state == "unknown"
|
||||||
assert state.attributes.get("friendly_name") == "AC 213c7f2:48 Rssi numeric"
|
assert state.attributes.get("friendly_name") == "AC 213c7f2:48 Signal strength"
|
||||||
assert (
|
assert (
|
||||||
state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
|
state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
|
||||||
== SIGNAL_STRENGTH_DECIBELS_MILLIWATT
|
== SIGNAL_STRENGTH_DECIBELS_MILLIWATT
|
||||||
|
@ -349,21 +349,21 @@ async def test_rssi_sensor(hass, rfxtrx):
|
||||||
await rfxtrx.signal("0913000022670e013b70")
|
await rfxtrx.signal("0913000022670e013b70")
|
||||||
await rfxtrx.signal("0b1100cd0213c7f230010f71")
|
await rfxtrx.signal("0b1100cd0213c7f230010f71")
|
||||||
|
|
||||||
state = hass.states.get("sensor.pt2262_22670e_rssi_numeric")
|
state = hass.states.get("sensor.pt2262_22670e_signal_strength")
|
||||||
assert state
|
assert state
|
||||||
assert state.state == "-64"
|
assert state.state == "-64"
|
||||||
|
|
||||||
state = hass.states.get("sensor.ac_213c7f2_48_rssi_numeric")
|
state = hass.states.get("sensor.ac_213c7f2_48_signal_strength")
|
||||||
assert state
|
assert state
|
||||||
assert state.state == "-64"
|
assert state.state == "-64"
|
||||||
|
|
||||||
await rfxtrx.signal("0913000022670e013b60")
|
await rfxtrx.signal("0913000022670e013b60")
|
||||||
await rfxtrx.signal("0b1100cd0213c7f230010f61")
|
await rfxtrx.signal("0b1100cd0213c7f230010f61")
|
||||||
|
|
||||||
state = hass.states.get("sensor.pt2262_22670e_rssi_numeric")
|
state = hass.states.get("sensor.pt2262_22670e_signal_strength")
|
||||||
assert state
|
assert state
|
||||||
assert state.state == "-72"
|
assert state.state == "-72"
|
||||||
|
|
||||||
state = hass.states.get("sensor.ac_213c7f2_48_rssi_numeric")
|
state = hass.states.get("sensor.ac_213c7f2_48_signal_strength")
|
||||||
assert state
|
assert state
|
||||||
assert state.state == "-72"
|
assert state.state == "-72"
|
||||||
|
|
Loading…
Reference in New Issue