Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions homeassistant/components/light/homematicip_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
_LOGGER = logging.getLogger(__name__)

ATTR_POWER_CONSUMPTION = 'power_consumption'
ATTR_ENERGIE_COUNTER = 'energie_counter'
ATTR_ENERGIE_COUNTER = 'energie_counter_kwh'
ATTR_PROFILE_MODE = 'profile_mode'


Expand All @@ -29,13 +29,13 @@ async def async_setup_platform(hass, config, async_add_devices,

async def async_setup_entry(hass, config_entry, async_add_devices):
"""Set up the HomematicIP lights from a config entry."""
from homematicip.device import (
BrandSwitchMeasuring)
from homematicip.aio.device import (
AsyncBrandSwitchMeasuring)

home = hass.data[HMIPC_DOMAIN][config_entry.data[HMIPC_HAPID]].home
devices = []
for device in home.devices:
if isinstance(device, BrandSwitchMeasuring):
if isinstance(device, AsyncBrandSwitchMeasuring):
devices.append(HomematicipLightMeasuring(home, device))

if devices:
Expand Down Expand Up @@ -67,13 +67,15 @@ class HomematicipLightMeasuring(HomematicipLight):
"""MomematicIP measuring light device."""

@property
def current_power_w(self):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since these properties are removed, this is a breaking change.

"""Return the current power usage in W."""
return self._device.currentPowerConsumption

@property
def today_energy_kwh(self):
"""Return the today total energy usage in kWh."""
if self._device.energyCounter is None:
return 0
return round(self._device.energyCounter)
def device_state_attributes(self):
"""Return the state attributes of the generic device."""
attr = super().device_state_attributes
if self._device.currentPowerConsumption > 0.05:
attr.update({
ATTR_POWER_CONSUMPTION:
round(self._device.currentPowerConsumption, 2)
})
attr.update({
ATTR_ENERGIE_COUNTER: round(self._device.energyCounter, 2)
})
return attr