mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
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:
parent
befe2cbefe
commit
90cf94bb30
@ -1,7 +1,12 @@
|
|||||||
"""Representation of a Hue remote firing events for button presses."""
|
"""Representation of a Hue remote firing events for button presses."""
|
||||||
import logging
|
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.const import CONF_EVENT, CONF_ID, CONF_UNIQUE_ID
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
@ -50,6 +55,11 @@ class HueEvent(GenericHueDevice):
|
|||||||
"""Fire the event if reason is that state is updated."""
|
"""Fire the event if reason is that state is updated."""
|
||||||
if (
|
if (
|
||||||
self.sensor.state == self._last_state
|
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
|
or
|
||||||
# Filter out old states. Can happen when events fire while refreshing
|
# Filter out old states. Can happen when events fire while refreshing
|
||||||
dt_util.parse_datetime(self.sensor.state["lastupdated"])
|
dt_util.parse_datetime(self.sensor.state["lastupdated"])
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
"name": "Philips Hue",
|
"name": "Philips Hue",
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"documentation": "https://www.home-assistant.io/integrations/hue",
|
"documentation": "https://www.home-assistant.io/integrations/hue",
|
||||||
"requirements": ["aiohue==2.5.1"],
|
"requirements": ["aiohue==2.6.0"],
|
||||||
"ssdp": [
|
"ssdp": [
|
||||||
{
|
{
|
||||||
"manufacturer": "Royal Philips Electronics",
|
"manufacturer": "Royal Philips Electronics",
|
||||||
|
@ -185,7 +185,7 @@ aiohomekit==0.6.0
|
|||||||
aiohttp_cors==0.7.0
|
aiohttp_cors==0.7.0
|
||||||
|
|
||||||
# homeassistant.components.hue
|
# homeassistant.components.hue
|
||||||
aiohue==2.5.1
|
aiohue==2.6.0
|
||||||
|
|
||||||
# homeassistant.components.imap
|
# homeassistant.components.imap
|
||||||
aioimaplib==0.9.0
|
aioimaplib==0.9.0
|
||||||
|
@ -122,7 +122,7 @@ aiohomekit==0.6.0
|
|||||||
aiohttp_cors==0.7.0
|
aiohttp_cors==0.7.0
|
||||||
|
|
||||||
# homeassistant.components.hue
|
# homeassistant.components.hue
|
||||||
aiohue==2.5.1
|
aiohue==2.6.0
|
||||||
|
|
||||||
# homeassistant.components.apache_kafka
|
# homeassistant.components.apache_kafka
|
||||||
aiokafka==0.6.0
|
aiokafka==0.6.0
|
||||||
|
@ -446,6 +446,9 @@ async def test_hue_events(hass, mock_bridge):
|
|||||||
assert len(hass.states.async_all()) == 7
|
assert len(hass.states.async_all()) == 7
|
||||||
assert len(events) == 0
|
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 = dict(SENSOR_RESPONSE)
|
||||||
new_sensor_response["7"]["state"] = {
|
new_sensor_response["7"]["state"] = {
|
||||||
"buttonevent": 18,
|
"buttonevent": 18,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user