mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
This commit is contained in:
parent
a54e242245
commit
ff4204244b
@ -16,6 +16,7 @@ ATTR_IN_USE = 'in_use'
|
|||||||
|
|
||||||
LOAD_POWER = 'load_power'
|
LOAD_POWER = 'load_power'
|
||||||
POWER_CONSUMED = 'power_consumed'
|
POWER_CONSUMED = 'power_consumed'
|
||||||
|
ENERGY_CONSUMED = 'energy_consumed'
|
||||||
IN_USE = 'inuse'
|
IN_USE = 'inuse'
|
||||||
|
|
||||||
|
|
||||||
@ -57,8 +58,12 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||||||
'channel_1',
|
'channel_1',
|
||||||
False, gateway))
|
False, gateway))
|
||||||
elif model in ['86plug', 'ctrl_86plug', 'ctrl_86plug.aq1']:
|
elif model in ['86plug', 'ctrl_86plug', 'ctrl_86plug.aq1']:
|
||||||
|
if 'proto' not in device or int(device['proto'][0:1]) == 1:
|
||||||
|
data_key = 'status'
|
||||||
|
else:
|
||||||
|
data_key = 'channel_0'
|
||||||
devices.append(XiaomiGenericSwitch(device, 'Wall Plug',
|
devices.append(XiaomiGenericSwitch(device, 'Wall Plug',
|
||||||
'status', True, gateway))
|
data_key, True, gateway))
|
||||||
add_entities(devices)
|
add_entities(devices)
|
||||||
|
|
||||||
|
|
||||||
@ -122,8 +127,12 @@ class XiaomiGenericSwitch(XiaomiDevice, SwitchDevice):
|
|||||||
self._in_use = int(data[IN_USE])
|
self._in_use = int(data[IN_USE])
|
||||||
if not self._in_use:
|
if not self._in_use:
|
||||||
self._load_power = 0
|
self._load_power = 0
|
||||||
if POWER_CONSUMED in data:
|
|
||||||
self._power_consumed = round(float(data[POWER_CONSUMED]), 2)
|
for key in [POWER_CONSUMED, ENERGY_CONSUMED]:
|
||||||
|
if key in data:
|
||||||
|
self._power_consumed = round(float(data[key]), 2)
|
||||||
|
break
|
||||||
|
|
||||||
if LOAD_POWER in data:
|
if LOAD_POWER in data:
|
||||||
self._load_power = round(float(data[LOAD_POWER]), 2)
|
self._load_power = round(float(data[LOAD_POWER]), 2)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user