deCONZ - Library cleanup (#31410)

* Follow library changes

* Bump dependency to v70

* Fix test
pull/31420/head
Robert Svensson 2020-02-02 19:07:20 +01:00 committed by GitHub
parent f21a058f31
commit 883b8f21ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 27 additions and 27 deletions

View File

@ -81,7 +81,7 @@ class DeconzDevice(DeconzBase, Entity):
async def async_added_to_hass(self): async def async_added_to_hass(self):
"""Subscribe to device events.""" """Subscribe to device events."""
self._device.register_async_callback(self.async_update_callback) self._device.register_callback(self.async_update_callback)
self.gateway.deconz_ids[self.entity_id] = self._device.deconz_id self.gateway.deconz_ids[self.entity_id] = self._device.deconz_id
self.listeners.append( self.listeners.append(
async_dispatcher_connect( async_dispatcher_connect(

View File

@ -21,7 +21,7 @@ class DeconzEvent(DeconzBase):
"""Register callback that will be used for signals.""" """Register callback that will be used for signals."""
super().__init__(device, gateway) super().__init__(device, gateway)
self._device.register_async_callback(self.async_update_callback) self._device.register_callback(self.async_update_callback)
self.device_id = None self.device_id = None
self.event_id = slugify(self._device.name) self.event_id = slugify(self._device.name)

View File

@ -156,7 +156,7 @@ class DeconzLight(DeconzDevice, Light):
if ATTR_TRANSITION in kwargs: if ATTR_TRANSITION in kwargs:
data["transitiontime"] = int(kwargs[ATTR_TRANSITION] * 10) data["transitiontime"] = int(kwargs[ATTR_TRANSITION] * 10)
elif "IKEA" in (self._device.manufacturer or ""): elif "IKEA" in self._device.manufacturer:
data["transitiontime"] = 0 data["transitiontime"] = 0
if ATTR_FLASH in kwargs: if ATTR_FLASH in kwargs:

View File

@ -4,7 +4,7 @@
"config_flow": true, "config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/deconz", "documentation": "https://www.home-assistant.io/integrations/deconz",
"requirements": [ "requirements": [
"pydeconz==69" "pydeconz==70"
], ],
"ssdp": [ "ssdp": [
{ {

View File

@ -216,7 +216,7 @@ class DeconzSensorStateTracker:
"""Set up tracker.""" """Set up tracker."""
self.sensor = sensor self.sensor = sensor
self.gateway = gateway self.gateway = gateway
sensor.register_async_callback(self.async_update_callback) sensor.register_callback(self.async_update_callback)
@callback @callback
def close(self): def close(self):

View File

@ -1188,7 +1188,7 @@ pydaikin==1.6.2
pydanfossair==0.1.0 pydanfossair==0.1.0
# homeassistant.components.deconz # homeassistant.components.deconz
pydeconz==69 pydeconz==70
# homeassistant.components.delijn # homeassistant.components.delijn
pydelijn==0.5.1 pydelijn==0.5.1

View File

@ -423,7 +423,7 @@ pycoolmasternet==0.0.4
pydaikin==1.6.2 pydaikin==1.6.2
# homeassistant.components.deconz # homeassistant.components.deconz
pydeconz==69 pydeconz==70
# homeassistant.components.zwave # homeassistant.components.zwave
pydispatcher==2.0.5 pydispatcher==2.0.5

View File

@ -96,7 +96,7 @@ async def test_binary_sensors(hass):
"id": "1", "id": "1",
"state": {"presence": True}, "state": {"presence": True},
} }
gateway.api.async_event_handler(state_changed_event) gateway.api.event_handler(state_changed_event)
await hass.async_block_till_done() await hass.async_block_till_done()
presence_sensor = hass.states.get("binary_sensor.presence_sensor") presence_sensor = hass.states.get("binary_sensor.presence_sensor")
@ -147,7 +147,7 @@ async def test_add_new_binary_sensor(hass):
"id": "1", "id": "1",
"sensor": deepcopy(SENSORS["1"]), "sensor": deepcopy(SENSORS["1"]),
} }
gateway.api.async_event_handler(state_added_event) gateway.api.event_handler(state_added_event)
await hass.async_block_till_done() await hass.async_block_till_done()
assert "binary_sensor.presence_sensor" in gateway.deconz_ids assert "binary_sensor.presence_sensor" in gateway.deconz_ids

View File

@ -95,7 +95,7 @@ async def test_climate_devices(hass):
"id": "1", "id": "1",
"config": {"mode": "off"}, "config": {"mode": "off"},
} }
gateway.api.async_event_handler(state_changed_event) gateway.api.event_handler(state_changed_event)
await hass.async_block_till_done() await hass.async_block_till_done()
thermostat = hass.states.get("climate.thermostat") thermostat = hass.states.get("climate.thermostat")
@ -109,7 +109,7 @@ async def test_climate_devices(hass):
"config": {"mode": "other"}, "config": {"mode": "other"},
"state": {"on": True}, "state": {"on": True},
} }
gateway.api.async_event_handler(state_changed_event) gateway.api.event_handler(state_changed_event)
await hass.async_block_till_done() await hass.async_block_till_done()
thermostat = hass.states.get("climate.thermostat") thermostat = hass.states.get("climate.thermostat")
@ -122,7 +122,7 @@ async def test_climate_devices(hass):
"id": "1", "id": "1",
"state": {"on": False}, "state": {"on": False},
} }
gateway.api.async_event_handler(state_changed_event) gateway.api.event_handler(state_changed_event)
await hass.async_block_till_done() await hass.async_block_till_done()
thermostat = hass.states.get("climate.thermostat") thermostat = hass.states.get("climate.thermostat")
@ -232,7 +232,7 @@ async def test_verify_state_update(hass):
"id": "1", "id": "1",
"state": {"on": False}, "state": {"on": False},
} }
gateway.api.async_event_handler(state_changed_event) gateway.api.event_handler(state_changed_event)
await hass.async_block_till_done() await hass.async_block_till_done()
thermostat = hass.states.get("climate.thermostat") thermostat = hass.states.get("climate.thermostat")
@ -252,7 +252,7 @@ async def test_add_new_climate_device(hass):
"id": "1", "id": "1",
"sensor": deepcopy(SENSORS["1"]), "sensor": deepcopy(SENSORS["1"]),
} }
gateway.api.async_event_handler(state_added_event) gateway.api.event_handler(state_added_event)
await hass.async_block_till_done() await hass.async_block_till_done()
assert "climate.thermostat" in gateway.deconz_ids assert "climate.thermostat" in gateway.deconz_ids

View File

@ -74,7 +74,7 @@ async def test_cover(hass):
"id": "1", "id": "1",
"state": {"on": True}, "state": {"on": True},
} }
gateway.api.async_event_handler(state_changed_event) gateway.api.event_handler(state_changed_event)
await hass.async_block_till_done() await hass.async_block_till_done()
level_controllable_cover = hass.states.get("cover.level_controllable_cover") level_controllable_cover = hass.states.get("cover.level_controllable_cover")

View File

@ -70,7 +70,7 @@ async def test_deconz_events(hass):
mock_listener = Mock() mock_listener = Mock()
unsub = hass.bus.async_listen(CONF_DECONZ_EVENT, mock_listener) unsub = hass.bus.async_listen(CONF_DECONZ_EVENT, mock_listener)
gateway.api.sensors["1"].async_update({"state": {"buttonevent": 2000}}) gateway.api.sensors["1"].update({"state": {"buttonevent": 2000}})
await hass.async_block_till_done() await hass.async_block_till_done()
assert len(mock_listener.mock_calls) == 1 assert len(mock_listener.mock_calls) == 1
@ -85,7 +85,7 @@ async def test_deconz_events(hass):
mock_listener = Mock() mock_listener = Mock()
unsub = hass.bus.async_listen(CONF_DECONZ_EVENT, mock_listener) unsub = hass.bus.async_listen(CONF_DECONZ_EVENT, mock_listener)
gateway.api.sensors["3"].async_update({"state": {"buttonevent": 2000}}) gateway.api.sensors["3"].update({"state": {"buttonevent": 2000}})
await hass.async_block_till_done() await hass.async_block_till_done()
assert len(mock_listener.mock_calls) == 1 assert len(mock_listener.mock_calls) == 1
@ -101,7 +101,7 @@ async def test_deconz_events(hass):
mock_listener = Mock() mock_listener = Mock()
unsub = hass.bus.async_listen(CONF_DECONZ_EVENT, mock_listener) unsub = hass.bus.async_listen(CONF_DECONZ_EVENT, mock_listener)
gateway.api.sensors["4"].async_update({"state": {"gesture": 0}}) gateway.api.sensors["4"].update({"state": {"gesture": 0}})
await hass.async_block_till_done() await hass.async_block_till_done()
assert len(mock_listener.mock_calls) == 1 assert len(mock_listener.mock_calls) == 1

View File

@ -131,7 +131,7 @@ async def test_lights_and_groups(hass):
"id": "1", "id": "1",
"state": {"on": False}, "state": {"on": False},
} }
gateway.api.async_event_handler(state_changed_event) gateway.api.event_handler(state_changed_event)
await hass.async_block_till_done() await hass.async_block_till_done()
rgb_light = hass.states.get("light.rgb_light") rgb_light = hass.states.get("light.rgb_light")

View File

@ -144,7 +144,7 @@ async def test_sensors(hass):
"id": "1", "id": "1",
"state": {"lightlevel": 2000}, "state": {"lightlevel": 2000},
} }
gateway.api.async_event_handler(state_changed_event) gateway.api.event_handler(state_changed_event)
state_changed_event = { state_changed_event = {
"t": "event", "t": "event",
@ -153,7 +153,7 @@ async def test_sensors(hass):
"id": "4", "id": "4",
"config": {"battery": 75}, "config": {"battery": 75},
} }
gateway.api.async_event_handler(state_changed_event) gateway.api.event_handler(state_changed_event)
await hass.async_block_till_done() await hass.async_block_till_done()
light_level_sensor = hass.states.get("sensor.light_level_sensor") light_level_sensor = hass.states.get("sensor.light_level_sensor")
@ -231,7 +231,7 @@ async def test_add_new_sensor(hass):
"id": "1", "id": "1",
"sensor": deepcopy(SENSORS["1"]), "sensor": deepcopy(SENSORS["1"]),
} }
gateway.api.async_event_handler(state_added_event) gateway.api.event_handler(state_added_event)
await hass.async_block_till_done() await hass.async_block_till_done()
assert "sensor.light_level_sensor" in gateway.deconz_ids assert "sensor.light_level_sensor" in gateway.deconz_ids
@ -248,14 +248,14 @@ async def test_add_battery_later(hass):
remote = gateway.api.sensors["1"] remote = gateway.api.sensors["1"]
assert len(gateway.deconz_ids) == 0 assert len(gateway.deconz_ids) == 0
assert len(gateway.events) == 1 assert len(gateway.events) == 1
assert len(remote._async_callbacks) == 2 assert len(remote._callbacks) == 2
remote.async_update({"config": {"battery": 50}}) remote.update({"config": {"battery": 50}})
await hass.async_block_till_done() await hass.async_block_till_done()
assert len(gateway.deconz_ids) == 1 assert len(gateway.deconz_ids) == 1
assert len(gateway.events) == 1 assert len(gateway.events) == 1
assert len(remote._async_callbacks) == 2 assert len(remote._callbacks) == 2
battery_sensor = hass.states.get("sensor.switch_1_battery_level") battery_sensor = hass.states.get("sensor.switch_1_battery_level")
assert battery_sensor is not None assert battery_sensor is not None

View File

@ -97,7 +97,7 @@ async def test_switches(hass):
"id": "1", "id": "1",
"state": {"on": False}, "state": {"on": False},
} }
gateway.api.async_event_handler(state_changed_event) gateway.api.event_handler(state_changed_event)
state_changed_event = { state_changed_event = {
"t": "event", "t": "event",
"e": "changed", "e": "changed",
@ -105,7 +105,7 @@ async def test_switches(hass):
"id": "3", "id": "3",
"state": {"alert": None}, "state": {"alert": None},
} }
gateway.api.async_event_handler(state_changed_event) gateway.api.event_handler(state_changed_event)
await hass.async_block_till_done() await hass.async_block_till_done()
on_off_switch = hass.states.get("switch.on_off_switch") on_off_switch = hass.states.get("switch.on_off_switch")