mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
Add sensors for HomeWizard Watermeter (#74756)
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
This commit is contained in:
parent
85148b343d
commit
124c8e8f73
@ -4,7 +4,7 @@
|
|||||||
"documentation": "https://www.home-assistant.io/integrations/homewizard",
|
"documentation": "https://www.home-assistant.io/integrations/homewizard",
|
||||||
"codeowners": ["@DCSBL"],
|
"codeowners": ["@DCSBL"],
|
||||||
"dependencies": [],
|
"dependencies": [],
|
||||||
"requirements": ["python-homewizard-energy==1.0.3"],
|
"requirements": ["python-homewizard-energy==1.1.0"],
|
||||||
"zeroconf": ["_hwenergy._tcp.local."],
|
"zeroconf": ["_hwenergy._tcp.local."],
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"iot_class": "local_polling",
|
"iot_class": "local_polling",
|
||||||
|
@ -119,6 +119,20 @@ SENSORS: Final[tuple[SensorEntityDescription, ...]] = (
|
|||||||
device_class=SensorDeviceClass.GAS,
|
device_class=SensorDeviceClass.GAS,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
|
SensorEntityDescription(
|
||||||
|
key="active_liter_lpm",
|
||||||
|
name="Active Water Usage",
|
||||||
|
native_unit_of_measurement="l/min",
|
||||||
|
icon="mdi:water",
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
),
|
||||||
|
SensorEntityDescription(
|
||||||
|
key="total_liter_m3",
|
||||||
|
name="Total Water Usage",
|
||||||
|
native_unit_of_measurement=VOLUME_CUBIC_METERS,
|
||||||
|
icon="mdi:gauge",
|
||||||
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1907,7 +1907,7 @@ python-gc100==1.0.3a0
|
|||||||
python-gitlab==1.6.0
|
python-gitlab==1.6.0
|
||||||
|
|
||||||
# homeassistant.components.homewizard
|
# homeassistant.components.homewizard
|
||||||
python-homewizard-energy==1.0.3
|
python-homewizard-energy==1.1.0
|
||||||
|
|
||||||
# homeassistant.components.hp_ilo
|
# homeassistant.components.hp_ilo
|
||||||
python-hpilo==4.3
|
python-hpilo==4.3
|
||||||
|
@ -1281,7 +1281,7 @@ python-ecobee-api==0.2.14
|
|||||||
python-forecastio==1.4.0
|
python-forecastio==1.4.0
|
||||||
|
|
||||||
# homeassistant.components.homewizard
|
# homeassistant.components.homewizard
|
||||||
python-homewizard-energy==1.0.3
|
python-homewizard-energy==1.1.0
|
||||||
|
|
||||||
# homeassistant.components.izone
|
# homeassistant.components.izone
|
||||||
python-izone==1.2.3
|
python-izone==1.2.3
|
||||||
|
@ -12,5 +12,7 @@
|
|||||||
"active_power_l2_w": 456,
|
"active_power_l2_w": 456,
|
||||||
"active_power_l3_w": 123.456,
|
"active_power_l3_w": 123.456,
|
||||||
"total_gas_m3": 1122.333,
|
"total_gas_m3": 1122.333,
|
||||||
"gas_timestamp": 210314112233
|
"gas_timestamp": 210314112233,
|
||||||
|
"active_liter_lpm": 12.345,
|
||||||
|
"total_liter_m3": 1234.567
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,8 @@ async def test_diagnostics(
|
|||||||
"active_power_l3_w": 123.456,
|
"active_power_l3_w": 123.456,
|
||||||
"total_gas_m3": 1122.333,
|
"total_gas_m3": 1122.333,
|
||||||
"gas_timestamp": "2021-03-14T11:22:33",
|
"gas_timestamp": "2021-03-14T11:22:33",
|
||||||
|
"active_liter_lpm": 12.345,
|
||||||
|
"total_liter_m3": 1234.567,
|
||||||
},
|
},
|
||||||
"state": {"power_on": True, "switch_lock": False, "brightness": 255},
|
"state": {"power_on": True, "switch_lock": False, "brightness": 255},
|
||||||
},
|
},
|
||||||
|
@ -534,6 +534,88 @@ async def test_sensor_entity_total_gas(hass, mock_config_entry_data, mock_config
|
|||||||
assert ATTR_ICON not in state.attributes
|
assert ATTR_ICON not in state.attributes
|
||||||
|
|
||||||
|
|
||||||
|
async def test_sensor_entity_active_liters(
|
||||||
|
hass, mock_config_entry_data, mock_config_entry
|
||||||
|
):
|
||||||
|
"""Test entity loads active liters (watermeter)."""
|
||||||
|
|
||||||
|
api = get_mock_device()
|
||||||
|
api.data = AsyncMock(return_value=Data.from_dict({"active_liter_lpm": 12.345}))
|
||||||
|
|
||||||
|
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_active_water_usage")
|
||||||
|
entry = entity_registry.async_get(
|
||||||
|
"sensor.product_name_aabbccddeeff_active_water_usage"
|
||||||
|
)
|
||||||
|
assert entry
|
||||||
|
assert state
|
||||||
|
assert entry.unique_id == "aabbccddeeff_active_liter_lpm"
|
||||||
|
assert not entry.disabled
|
||||||
|
assert state.state == "12.345"
|
||||||
|
assert (
|
||||||
|
state.attributes.get(ATTR_FRIENDLY_NAME)
|
||||||
|
== "Product Name (aabbccddeeff) Active Water Usage"
|
||||||
|
)
|
||||||
|
|
||||||
|
assert state.attributes.get(ATTR_STATE_CLASS) == STATE_CLASS_MEASUREMENT
|
||||||
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == "l/min"
|
||||||
|
assert ATTR_DEVICE_CLASS not in state.attributes
|
||||||
|
assert state.attributes.get(ATTR_ICON) == "mdi:water"
|
||||||
|
|
||||||
|
|
||||||
|
async def test_sensor_entity_total_liters(
|
||||||
|
hass, mock_config_entry_data, mock_config_entry
|
||||||
|
):
|
||||||
|
"""Test entity loads total liters (watermeter)."""
|
||||||
|
|
||||||
|
api = get_mock_device()
|
||||||
|
api.data = AsyncMock(return_value=Data.from_dict({"total_liter_m3": 1234.567}))
|
||||||
|
|
||||||
|
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_total_water_usage")
|
||||||
|
entry = entity_registry.async_get(
|
||||||
|
"sensor.product_name_aabbccddeeff_total_water_usage"
|
||||||
|
)
|
||||||
|
assert entry
|
||||||
|
assert state
|
||||||
|
assert entry.unique_id == "aabbccddeeff_total_liter_m3"
|
||||||
|
assert not entry.disabled
|
||||||
|
assert state.state == "1234.567"
|
||||||
|
assert (
|
||||||
|
state.attributes.get(ATTR_FRIENDLY_NAME)
|
||||||
|
== "Product Name (aabbccddeeff) Total Water Usage"
|
||||||
|
)
|
||||||
|
|
||||||
|
assert state.attributes.get(ATTR_STATE_CLASS) == STATE_CLASS_TOTAL_INCREASING
|
||||||
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == VOLUME_CUBIC_METERS
|
||||||
|
assert ATTR_DEVICE_CLASS not in state.attributes
|
||||||
|
assert state.attributes.get(ATTR_ICON) == "mdi:gauge"
|
||||||
|
|
||||||
|
|
||||||
async def test_sensor_entity_disabled_when_null(
|
async def test_sensor_entity_disabled_when_null(
|
||||||
hass, mock_config_entry_data, mock_config_entry
|
hass, mock_config_entry_data, mock_config_entry
|
||||||
):
|
):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user