Add sensors for smart and gas meter identifiers (serial numbers) in HomeWizard (#86282)
parent
e1512fd3e1
commit
658db7ff05
|
@ -63,6 +63,13 @@ SENSORS: Final[tuple[HomeWizardSensorEntityDescription, ...]] = (
|
|||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
value_fn=lambda data: data.meter_model,
|
||||
),
|
||||
HomeWizardSensorEntityDescription(
|
||||
key="unique_meter_id",
|
||||
name="Smart meter identifier",
|
||||
icon="mdi:alphabetical-variant",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
value_fn=lambda data: data.unique_meter_id,
|
||||
),
|
||||
HomeWizardSensorEntityDescription(
|
||||
key="wifi_ssid",
|
||||
name="Wi-Fi SSID",
|
||||
|
@ -343,6 +350,13 @@ SENSORS: Final[tuple[HomeWizardSensorEntityDescription, ...]] = (
|
|||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
value_fn=lambda data: data.total_gas_m3,
|
||||
),
|
||||
HomeWizardSensorEntityDescription(
|
||||
key="gas_unique_id",
|
||||
name="Gas meter identifier",
|
||||
icon="mdi:alphabetical-variant",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
value_fn=lambda data: data.gas_unique_id,
|
||||
),
|
||||
HomeWizardSensorEntityDescription(
|
||||
key="active_liter_lpm",
|
||||
name="Active water usage",
|
||||
|
|
|
@ -110,6 +110,46 @@ async def test_sensor_entity_meter_model(
|
|||
assert state.attributes.get(ATTR_ICON) == "mdi:gauge"
|
||||
|
||||
|
||||
async def test_sensor_entity_unique_meter_id(
|
||||
hass, mock_config_entry_data, mock_config_entry
|
||||
):
|
||||
"""Test entity loads unique meter id."""
|
||||
|
||||
api = get_mock_device()
|
||||
api.data = AsyncMock(return_value=Data.from_dict({"unique_id": "4E47475955"}))
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.homewizard.coordinator.HomeWizardEnergy",
|
||||
return_value=api,
|
||||
):
|
||||
entry = mock_config_entry
|
||||
entry.data = mock_config_entry_data
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
entity_registry = er.async_get(hass)
|
||||
|
||||
state = hass.states.get("sensor.product_name_aabbccddeeff_smart_meter_identifier")
|
||||
entry = entity_registry.async_get(
|
||||
"sensor.product_name_aabbccddeeff_smart_meter_identifier"
|
||||
)
|
||||
assert entry
|
||||
assert state
|
||||
assert entry.unique_id == "aabbccddeeff_unique_meter_id"
|
||||
assert not entry.disabled
|
||||
assert state.state == "NGGYU"
|
||||
assert (
|
||||
state.attributes.get(ATTR_FRIENDLY_NAME)
|
||||
== "Product Name (aabbccddeeff) Smart meter identifier"
|
||||
)
|
||||
assert ATTR_STATE_CLASS not in state.attributes
|
||||
assert ATTR_UNIT_OF_MEASUREMENT not in state.attributes
|
||||
assert ATTR_DEVICE_CLASS not in state.attributes
|
||||
assert state.attributes.get(ATTR_ICON) == "mdi:alphabetical-variant"
|
||||
|
||||
|
||||
async def test_sensor_entity_wifi_ssid(hass, mock_config_entry_data, mock_config_entry):
|
||||
"""Test entity loads wifi ssid."""
|
||||
|
||||
|
@ -574,6 +614,46 @@ async def test_sensor_entity_total_gas(hass, mock_config_entry_data, mock_config
|
|||
assert ATTR_ICON not in state.attributes
|
||||
|
||||
|
||||
async def test_sensor_entity_unique_gas_meter_id(
|
||||
hass, mock_config_entry_data, mock_config_entry
|
||||
):
|
||||
"""Test entity loads unique gas meter id."""
|
||||
|
||||
api = get_mock_device()
|
||||
api.data = AsyncMock(return_value=Data.from_dict({"gas_unique_id": "4E47475955"}))
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.homewizard.coordinator.HomeWizardEnergy",
|
||||
return_value=api,
|
||||
):
|
||||
entry = mock_config_entry
|
||||
entry.data = mock_config_entry_data
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
entity_registry = er.async_get(hass)
|
||||
|
||||
state = hass.states.get("sensor.product_name_aabbccddeeff_gas_meter_identifier")
|
||||
entry = entity_registry.async_get(
|
||||
"sensor.product_name_aabbccddeeff_gas_meter_identifier"
|
||||
)
|
||||
assert entry
|
||||
assert state
|
||||
assert entry.unique_id == "aabbccddeeff_gas_unique_id"
|
||||
assert not entry.disabled
|
||||
assert state.state == "NGGYU"
|
||||
assert (
|
||||
state.attributes.get(ATTR_FRIENDLY_NAME)
|
||||
== "Product Name (aabbccddeeff) Gas meter identifier"
|
||||
)
|
||||
assert ATTR_STATE_CLASS not in state.attributes
|
||||
assert ATTR_UNIT_OF_MEASUREMENT not in state.attributes
|
||||
assert ATTR_DEVICE_CLASS not in state.attributes
|
||||
assert state.attributes.get(ATTR_ICON) == "mdi:alphabetical-variant"
|
||||
|
||||
|
||||
async def test_sensor_entity_active_voltage_l1(
|
||||
hass, mock_config_entry_data, mock_config_entry
|
||||
):
|
||||
|
|
Loading…
Reference in New Issue