Skip to content

Commit

Permalink
Rekeying config with gateway's MAC
Browse files Browse the repository at this point in the history
  • Loading branch information
anotherjulien committed Feb 14, 2023
1 parent 491c951 commit e193070
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion custom_components/myhome/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@
from .const import (
LOGGER,
CONF,
CONF_PLATFORMS,
CONF_GATEWAY,
CONF_WHO,
CONF_WHERE,
CONF_BUS_INTERFACE,
CONF_ENTITIES,
CONF_ZONE,
CONF_MANUFACTURER,
CONF_DEVICE_MODEL,
Expand Down Expand Up @@ -96,9 +98,10 @@ def __call__(self, data):
_rekeyed_data = {}
for gateway in data:
_rekeyed_data[data[gateway][CONF_MAC]] = {}
_rekeyed_data[data[gateway][CONF_MAC]][CONF_PLATFORMS] = {}
for platform in data[gateway]:
if platform != CONF_MAC:
_rekeyed_data[data[gateway][CONF_MAC]][platform] = data[gateway][platform]
_rekeyed_data[data[gateway][CONF_MAC]][CONF_PLATFORMS][platform] = data[gateway][platform]

return _rekeyed_data

Expand All @@ -108,6 +111,7 @@ def __call__(self, data):
_rekeyed_data = {}

for device in data:
data[device][CONF_ENTITIES] = {}
if CONF_DEVICE_CLASS in data[device]:
if data[device][CONF_DEVICE_CLASS] in [SensorDeviceClass.POWER, SensorDeviceClass.ENERGY]:
if CONF_WHO not in data[device]:
Expand Down

0 comments on commit e193070

Please sign in to comment.