Add deCONZ entities in a predicitive order (#11712)

* Make sure that entities names are created in a predicitive order

* Debug print for deconz config parameters

* Bump requirement to v25
This commit is contained in:
Kane610 2018-01-18 06:22:42 +01:00 committed by Paulus Schoutsen
parent aac01cb096
commit 8bcaf832ae
4 changed files with 9 additions and 6 deletions

View file

@ -25,8 +25,9 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
sensors = hass.data[DECONZ_DATA].sensors sensors = hass.data[DECONZ_DATA].sensors
entities = [] entities = []
for sensor in sensors.values(): for key in sorted(sensors.keys(), key=int):
if sensor.type in DECONZ_BINARY_SENSOR: sensor = sensors[key]
if sensor and sensor.type in DECONZ_BINARY_SENSOR:
entities.append(DeconzBinarySensor(sensor)) entities.append(DeconzBinarySensor(sensor))
async_add_devices(entities, True) async_add_devices(entities, True)

View file

@ -17,7 +17,7 @@ from homeassistant.helpers import discovery
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.util.json import load_json, save_json from homeassistant.util.json import load_json, save_json
REQUIREMENTS = ['pydeconz==24'] REQUIREMENTS = ['pydeconz==25']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -90,6 +90,7 @@ def async_setup_deconz(hass, config, deconz_config):
Load config, group, light and sensor data for server information. Load config, group, light and sensor data for server information.
Start websocket for push notification of state changes from deCONZ. Start websocket for push notification of state changes from deCONZ.
""" """
_LOGGER.debug('deCONZ config %s', deconz_config)
from pydeconz import DeconzSession from pydeconz import DeconzSession
websession = async_get_clientsession(hass) websession = async_get_clientsession(hass)
deconz = DeconzSession(hass.loop, websession, **deconz_config) deconz = DeconzSession(hass.loop, websession, **deconz_config)

View file

@ -29,8 +29,9 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
sensors = hass.data[DECONZ_DATA].sensors sensors = hass.data[DECONZ_DATA].sensors
entities = [] entities = []
for sensor in sensors.values(): for key in sorted(sensors.keys(), key=int):
if sensor.type in DECONZ_SENSOR: sensor = sensors[key]
if sensor and sensor.type in DECONZ_SENSOR:
if sensor.type in DECONZ_REMOTE: if sensor.type in DECONZ_REMOTE:
DeconzEvent(hass, sensor) DeconzEvent(hass, sensor)
if sensor.battery: if sensor.battery:

View file

@ -681,7 +681,7 @@ pycsspeechtts==1.0.2
pydaikin==0.4 pydaikin==0.4
# homeassistant.components.deconz # homeassistant.components.deconz
pydeconz==24 pydeconz==25
# homeassistant.components.zwave # homeassistant.components.zwave
pydispatcher==2.0.5 pydispatcher==2.0.5