Esempio n. 1
0
    async def async_handle_push_notification(self, namespace: Namespace,
                                             data: dict) -> bool:
        locally_handled = False

        if namespace == Namespace.CONTROL_SPRAY:
            _LOGGER.debug(
                f"{self.__class__.__name__} handling push notification for namespace {namespace}"
            )
            payload = data.get('spray')
            if payload is None:
                _LOGGER.error(
                    f"{self.__class__.__name__} could not find 'spray' attribute in push notification data: "
                    f"{data}")
                locally_handled = False
            else:
                # Update the status of every channel that has been reported in this push
                # notification.
                for c in payload:
                    channel = c['channel']
                    strmode = c['mode']
                    mode = SprayMode(strmode)
                    self._channel_spray_status[channel] = mode

                locally_handled = True

        # Always call the parent handler when done with local specific logic. This gives the opportunity to all
        # ancestors to catch all events.
        parent_handled = await super().async_handle_push_notification(
            namespace=namespace, data=data)
        return locally_handled or parent_handled
Esempio n. 2
0
    async def async_handle_update(self, namespace: Namespace, data: dict) -> bool:
        _LOGGER.debug(f"Handling {self.__class__.__name__} mixin data update.")
        locally_handled = False
        if namespace == Namespace.SYSTEM_ALL:
            spray_data = data.get('all', {}).get('digest', {}).get('spray', [])
            for c in spray_data:
                channel = c['channel']
                strmode = c['mode']
                mode = SprayMode(strmode)
                self._channel_spray_status[channel] = mode
            locally_handled = True

        super_handled = await super().async_handle_update(namespace=namespace, data=data)
        return super_handled or locally_handled