Source code for platypush.message.event.hue

from platypush.message.event import Event


[docs] class HueEvent(Event): """ Base class for events generated by devices connected to a Philips Hue bridge. """
[docs] class HueSensorEvent(HueEvent): """ Event triggered when the state of a sensor or accessory connected to a Philips Hue bridge changes. Note that switches, dimmers and buttons paired to the bridge are also exposed as sensors (usually with type ``ZLLSwitch`` or ``ZGPSwitch``), and their button events are reported through the ``buttonevent`` state attribute. For devices that follow the standard Hue button-event encoding, the event also exposes the decoded ``button`` index and ``button_action``. """
[docs] def __init__( self, *args, sensor_id=None, sensor_name=None, sensor_type=None, unique_id=None, state=None, button=None, button_action=None, **kwargs, ): """ :param sensor_id: ID of the sensor that triggered the event :type sensor_id: int or str :param sensor_name: Name of the sensor that triggered the event :type sensor_name: str :param sensor_type: Hue type of the sensor (e.g. ``ZLLSwitch``, ``ZLLPresence``, ``ZLLTemperature``, ``ZLLLightLevel``, ``ZGPSwitch``) :type sensor_type: str :param unique_id: Unique ID of the sensor (usually derived from its MAC address) :type unique_id: str :param state: Current state reported by the sensor (e.g. ``buttonevent`` for switches, ``presence`` for motion sensors, ``temperature`` for temperature sensors) :type state: dict :param button: Decoded button index, if the sensor is a switch that follows the standard Hue ``buttonevent`` encoding (e.g. 1-4 on a Hue dimmer switch) :type button: int :param button_action: Decoded button action - one of ``initial_press``, ``hold``, ``short_release`` or ``long_release`` - if the sensor is a switch that follows the standard Hue ``buttonevent`` encoding :type button_action: str """ attrs = {} if sensor_id is not None: attrs['sensor_id'] = sensor_id if sensor_name is not None: attrs['sensor_name'] = sensor_name if sensor_type is not None: attrs['sensor_type'] = sensor_type if unique_id is not None: attrs['unique_id'] = unique_id if state is not None: attrs['state'] = state if button is not None: attrs['button'] = button if button_action is not None: attrs['button_action'] = button_action super().__init__(*args, **attrs, **kwargs)
# vim:sw=4:ts=4:et: