diff --git a/homeassistant/components/homewizard/manifest.json b/homeassistant/components/homewizard/manifest.json index e426234b449..97b3c80b50d 100644 --- a/homeassistant/components/homewizard/manifest.json +++ b/homeassistant/components/homewizard/manifest.json @@ -4,7 +4,7 @@ "documentation": "https://www.home-assistant.io/integrations/homewizard", "codeowners": ["@DCSBL"], "dependencies": [], - "requirements": ["python-homewizard-energy==1.0.3"], + "requirements": ["python-homewizard-energy==1.1.0"], "zeroconf": ["_hwenergy._tcp.local."], "config_flow": true, "iot_class": "local_polling", diff --git a/homeassistant/components/homewizard/sensor.py b/homeassistant/components/homewizard/sensor.py index b7f759f6a0e..de39ce6f242 100644 --- a/homeassistant/components/homewizard/sensor.py +++ b/homeassistant/components/homewizard/sensor.py @@ -119,6 +119,20 @@ SENSORS: Final[tuple[SensorEntityDescription, ...]] = ( device_class=SensorDeviceClass.GAS, 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, + ), ) diff --git a/requirements_all.txt b/requirements_all.txt index 69733bda770..2ab6ccf679e 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1907,7 +1907,7 @@ python-gc100==1.0.3a0 python-gitlab==1.6.0 # homeassistant.components.homewizard -python-homewizard-energy==1.0.3 +python-homewizard-energy==1.1.0 # homeassistant.components.hp_ilo python-hpilo==4.3 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 27541bcc27e..727724e1e1d 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1281,7 +1281,7 @@ python-ecobee-api==0.2.14 python-forecastio==1.4.0 # homeassistant.components.homewizard -python-homewizard-energy==1.0.3 +python-homewizard-energy==1.1.0 # homeassistant.components.izone python-izone==1.2.3 diff --git a/tests/components/homewizard/fixtures/data.json b/tests/components/homewizard/fixtures/data.json index b6eada38038..35cfd2197a1 100644 --- a/tests/components/homewizard/fixtures/data.json +++ b/tests/components/homewizard/fixtures/data.json @@ -12,5 +12,7 @@ "active_power_l2_w": 456, "active_power_l3_w": 123.456, "total_gas_m3": 1122.333, - "gas_timestamp": 210314112233 + "gas_timestamp": 210314112233, + "active_liter_lpm": 12.345, + "total_liter_m3": 1234.567 } diff --git a/tests/components/homewizard/test_diagnostics.py b/tests/components/homewizard/test_diagnostics.py index e477c94d914..899bfb5fb2f 100644 --- a/tests/components/homewizard/test_diagnostics.py +++ b/tests/components/homewizard/test_diagnostics.py @@ -41,6 +41,8 @@ async def test_diagnostics( "active_power_l3_w": 123.456, "total_gas_m3": 1122.333, "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}, }, diff --git a/tests/components/homewizard/test_sensor.py b/tests/components/homewizard/test_sensor.py index 8195aa11708..a81291861a2 100644 --- a/tests/components/homewizard/test_sensor.py +++ b/tests/components/homewizard/test_sensor.py @@ -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 +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( hass, mock_config_entry_data, mock_config_entry ):