Skip to content

Commit

Permalink
deCONZ - Services normalize bridge id (home-assistant#31378)
Browse files Browse the repository at this point in the history
* Services should also make sure to normalize bridge id since users do not know to manage themselves
  • Loading branch information
Kane610 authored Feb 1, 2020
1 parent 9821047 commit e0704d7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
12 changes: 6 additions & 6 deletions homeassistant/components/deconz/services.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""deCONZ services."""
from pydeconz.utils import normalize_bridge_id
import voluptuous as vol

from homeassistant.helpers import config_validation as cv
Expand Down Expand Up @@ -97,15 +98,14 @@ async def async_configure_service(hass, data):
See Dresden Elektroniks REST API documentation for details:
http://dresden-elektronik.github.io/deconz-rest-doc/rest/
"""
bridgeid = data.get(CONF_BRIDGE_ID)
gateway = get_master_gateway(hass)
if CONF_BRIDGE_ID in data:
gateway = hass.data[DOMAIN][normalize_bridge_id(data[CONF_BRIDGE_ID])]

field = data.get(SERVICE_FIELD, "")
entity_id = data.get(SERVICE_ENTITY)
data = data[SERVICE_DATA]

gateway = get_master_gateway(hass)
if bridgeid:
gateway = hass.data[DOMAIN][bridgeid]

if entity_id:
try:
field = gateway.deconz_ids[entity_id] + field
Expand All @@ -120,7 +120,7 @@ async def async_refresh_devices_service(hass, data):
"""Refresh available devices from deCONZ."""
gateway = get_master_gateway(hass)
if CONF_BRIDGE_ID in data:
gateway = hass.data[DOMAIN][data[CONF_BRIDGE_ID]]
gateway = hass.data[DOMAIN][normalize_bridge_id(data[CONF_BRIDGE_ID])]

groups = set(gateway.api.groups.keys())
lights = set(gateway.api.lights.keys())
Expand Down
1 change: 1 addition & 0 deletions requirements_test_pre_commit.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

bandit==1.6.2
black==19.10b0
codespell==v1.16.0
flake8-docstrings==1.5.0
flake8==3.7.9
isort==v4.3.21
Expand Down

0 comments on commit e0704d7

Please sign in to comment.