From b7296c61bc1f91314af00ce52a5b376657fb9095 Mon Sep 17 00:00:00 2001 From: SukramJ <sukramj@icloud.com> Date: Mon, 4 Nov 2019 12:05:39 +0100 Subject: [PATCH] Align attribute naming between light and switch for HomematicIP Cloud (#28271) --- homeassistant/components/homematicip_cloud/light.py | 12 ++++++------ tests/components/homematicip_cloud/test_light.py | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/homematicip_cloud/light.py b/homeassistant/components/homematicip_cloud/light.py index 46a8d95729f..044140e5582 100644 --- a/homeassistant/components/homematicip_cloud/light.py +++ b/homeassistant/components/homematicip_cloud/light.py @@ -28,8 +28,8 @@ from .hap import HomematicipHAP _LOGGER = logging.getLogger(__name__) -ATTR_ENERGY_COUNTER = "energy_counter_kwh" -ATTR_POWER_CONSUMPTION = "power_consumption" +ATTR_TODAY_ENERGY_KWH = "today_energy_kwh" +ATTR_CURRENT_POWER_W = "current_power_w" async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): @@ -95,11 +95,11 @@ class HomematicipLightMeasuring(HomematicipLight): """Return the state attributes of the generic device.""" state_attr = super().device_state_attributes - current_power_consumption = self._device.currentPowerConsumption - if current_power_consumption > 0.05: - state_attr[ATTR_POWER_CONSUMPTION] = round(current_power_consumption, 2) + current_power_w = self._device.currentPowerConsumption + if current_power_w > 0.05: + state_attr[ATTR_CURRENT_POWER_W] = round(current_power_w, 2) - state_attr[ATTR_ENERGY_COUNTER] = round(self._device.energyCounter, 2) + state_attr[ATTR_TODAY_ENERGY_KWH] = round(self._device.energyCounter, 2) return state_attr diff --git a/tests/components/homematicip_cloud/test_light.py b/tests/components/homematicip_cloud/test_light.py index 17e92d9d99d..a55d9ea9151 100644 --- a/tests/components/homematicip_cloud/test_light.py +++ b/tests/components/homematicip_cloud/test_light.py @@ -3,8 +3,8 @@ from homematicip.base.enums import RGBColorState from homeassistant.components.homematicip_cloud import DOMAIN as HMIPC_DOMAIN from homeassistant.components.homematicip_cloud.light import ( - ATTR_ENERGY_COUNTER, - ATTR_POWER_CONSUMPTION, + ATTR_CURRENT_POWER_W, + ATTR_TODAY_ENERGY_KWH, ) from homeassistant.components.light import ( ATTR_BRIGHTNESS, @@ -209,8 +209,8 @@ async def test_hmip_light_measuring(hass, default_mock_hap): await async_manipulate_test_data(hass, hmip_device, "currentPowerConsumption", 50) ha_state = hass.states.get(entity_id) assert ha_state.state == STATE_ON - assert ha_state.attributes[ATTR_POWER_CONSUMPTION] == 50 - assert ha_state.attributes[ATTR_ENERGY_COUNTER] == 6.33 + assert ha_state.attributes[ATTR_CURRENT_POWER_W] == 50 + assert ha_state.attributes[ATTR_TODAY_ENERGY_KWH] == 6.33 await hass.services.async_call( "light", "turn_off", {"entity_id": entity_id}, blocking=True -- GitLab