Bump Hue and only fire events for button presses (#53781)

* Bump Hue and only fire events for button presses

* Fix tests
This commit is contained in:
Paulus Schoutsen 2021-07-30 14:14:58 -07:00 committed by GitHub
parent befe2cbefe
commit 90cf94bb30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 4 deletions

View File

@ -1,7 +1,12 @@
"""Representation of a Hue remote firing events for button presses."""
import logging
from aiohue.sensors import TYPE_ZGP_SWITCH, TYPE_ZLL_ROTARY, TYPE_ZLL_SWITCH
from aiohue.sensors import (
EVENT_BUTTON,
TYPE_ZGP_SWITCH,
TYPE_ZLL_ROTARY,
TYPE_ZLL_SWITCH,
)
from homeassistant.const import CONF_EVENT, CONF_ID, CONF_UNIQUE_ID
from homeassistant.core import callback
@ -50,6 +55,11 @@ class HueEvent(GenericHueDevice):
"""Fire the event if reason is that state is updated."""
if (
self.sensor.state == self._last_state
# Filter out non-button events if last event type is available
or (
self.sensor.last_event is not None
and self.sensor.last_event["type"] != EVENT_BUTTON
)
or
# Filter out old states. Can happen when events fire while refreshing
dt_util.parse_datetime(self.sensor.state["lastupdated"])

View File

@ -3,7 +3,7 @@
"name": "Philips Hue",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/hue",
"requirements": ["aiohue==2.5.1"],
"requirements": ["aiohue==2.6.0"],
"ssdp": [
{
"manufacturer": "Royal Philips Electronics",

View File

@ -185,7 +185,7 @@ aiohomekit==0.6.0
aiohttp_cors==0.7.0
# homeassistant.components.hue
aiohue==2.5.1
aiohue==2.6.0
# homeassistant.components.imap
aioimaplib==0.9.0

View File

@ -122,7 +122,7 @@ aiohomekit==0.6.0
aiohttp_cors==0.7.0
# homeassistant.components.hue
aiohue==2.5.1
aiohue==2.6.0
# homeassistant.components.apache_kafka
aiokafka==0.6.0

View File

@ -446,6 +446,9 @@ async def test_hue_events(hass, mock_bridge):
assert len(hass.states.async_all()) == 7
assert len(events) == 0
mock_bridge.api.sensors["7"].last_event = {"type": "button"}
mock_bridge.api.sensors["8"].last_event = {"type": "button"}
new_sensor_response = dict(SENSOR_RESPONSE)
new_sensor_response["7"]["state"] = {
"buttonevent": 18,