pyzerproc/light.py
async def _do_get_state(self):
        """Get the current state of the light"""
        # Clear the queue if a value is somehow left over
        try:
            self._notification_queue.get_nowait()
        except asyncio.QueueEmpty:
            pass

        await self._write(CHARACTERISTIC_COMMAND_WRITE, b'\xEF\x01\x77')

        response = await self._notification_queue.get()

        on_off_value = int(response[2])

        r = int(response[6])
        g = int(response[7])
        b = int(response[8])

        if on_off_value == 0x23:
            is_on = True
        elif on_off_value == 0x24:
            is_on = False
        else:
            is_on = None

        # Normalize and clamp from 0-31, to 0-255
        r = int(min(r * 255 / 31, 255))
        g = int(min(g * 255 / 31, 255))
        b = int(min(b * 255 / 31, 255))

        state = LightState(is_on, (r, g, b))

        _LOGGER.info("Got state of %s: %s", self._address, state)

        return state
Get the current state of the light
Get the current state of the light
Get the current state of the light
async def _do_get_state(self):
        try:
            self._notification_queue.get_nowait()
        except asyncio.QueueEmpty:
            pass
        await self._write(CHARACTERISTIC_COMMAND_WRITE, b'\xEF\x01\x77')
        response = await self._notification_queue.get()
        on_off_value = int(response[2])
        r = int(response[6])
        g = int(response[7])
        b = int(response[8])
        if on_off_value == 0x23:
            is_on = True
        elif on_off_value == 0x24:
            is_on = False
        else:
            is_on = None
        r = int(min(r * 255 / 31, 255))
        g = int(min(g * 255 / 31, 255))
        b = int(min(b * 255 / 31, 255))
        state = LightState(is_on, (r, g, b))
        _LOGGER.info("Got state of %s: %s", self._address, state)
        return state
async def _do_get_state ( self ) : try : self . _notification_queue . get_nowait ( ) except asyncio . QueueEmpty : pass await self . _write ( CHARACTERISTIC_COMMAND_WRITE , b'\xEF\x01\x77' ) response = await self . _notification_queue . get ( ) on_off_value = int ( response [ 2 ] ) r = int ( response [ 6 ] ) g = int ( response [ 7 ] ) b = int ( response [ 8 ] ) if on_off_value == 0x23 : is_on = True elif on_off_value == 0x24 : is_on = False else : is_on = None r = int ( min ( r * 255 / 31 , 255 ) ) g = int ( min ( g * 255 / 31 , 255 ) ) b = int ( min ( b * 255 / 31 , 255 ) ) state = LightState ( is_on , ( r , g , b ) ) _LOGGER . info ( "Got state of %s: %s" , self . _address , state ) return state
Get the current state of the light
Get the current state of the light
"""Get the current state of the light""" # Clear the queue if a value is somehow left over # Normalize and clamp from 0-31, to 0-255
self