Example #1
0
 def test_set(self):
     """Test setting value."""
     xknx = XKNX()
     remote_value = RemoteValueDpt2ByteUnsigned(
         xknx, group_address=GroupAddress("1/2/3"))
     self.loop.run_until_complete(remote_value.set(2571))
     self.assertEqual(xknx.telegrams.qsize(), 1)
     telegram = xknx.telegrams.get_nowait()
     self.assertEqual(
         telegram,
         Telegram(
             destination_address=GroupAddress("1/2/3"),
             payload=GroupValueWrite(DPTArray((0x0A, 0x0B))),
         ),
     )
     self.loop.run_until_complete(remote_value.set(5500))
     self.assertEqual(xknx.telegrams.qsize(), 1)
     telegram = xknx.telegrams.get_nowait()
     self.assertEqual(
         telegram,
         Telegram(
             destination_address=GroupAddress("1/2/3"),
             payload=GroupValueWrite(DPTArray((
                 0x15,
                 0x7C,
             ))),
         ),
     )
Example #2
0
 def test_to_process_error(self):
     """Test process errornous telegram."""
     xknx = XKNX()
     remote_value = RemoteValueDpt2ByteUnsigned(
         xknx, group_address=GroupAddress("1/2/3"))
     with self.assertRaises(CouldNotParseTelegram):
         telegram = Telegram(
             destination_address=GroupAddress("1/2/3"),
             payload=GroupValueWrite(DPTBinary(1)),
         )
         self.loop.run_until_complete(remote_value.process(telegram))
     with self.assertRaises(CouldNotParseTelegram):
         telegram = Telegram(
             destination_address=GroupAddress("1/2/3"),
             payload=GroupValueWrite(DPTArray((0x64, ))),
         )
         self.loop.run_until_complete(remote_value.process(telegram))
     with self.assertRaises(CouldNotParseTelegram):
         telegram = Telegram(
             destination_address=GroupAddress("1/2/3"),
             payload=GroupValueWrite(DPTArray((
                 0x64,
                 0x53,
                 0x42,
             ))),
         )
         self.loop.run_until_complete(remote_value.process(telegram))
    async def test_to_process_error(self):
        """Test process errornous telegram."""
        xknx = XKNX()
        remote_value = RemoteValueDpt2ByteUnsigned(
            xknx, group_address=GroupAddress("1/2/3"))

        telegram = Telegram(
            destination_address=GroupAddress("1/2/3"),
            payload=GroupValueWrite(DPTBinary(1)),
        )
        assert await remote_value.process(telegram) is False

        telegram = Telegram(
            destination_address=GroupAddress("1/2/3"),
            payload=GroupValueWrite(DPTArray((0x64, ))),
        )
        assert await remote_value.process(telegram) is False

        telegram = Telegram(
            destination_address=GroupAddress("1/2/3"),
            payload=GroupValueWrite(DPTArray((0x64, 0x53, 0x42))),
        )
        assert await remote_value.process(telegram) is False

        assert remote_value.value is None
Example #4
0
 def test_to_knx_error(self):
     """Test to_knx function with wrong parameters."""
     xknx = XKNX()
     remote_value = RemoteValueDpt2ByteUnsigned(xknx)
     with self.assertRaises(ConversionError):
         remote_value.to_knx(65536)
     with self.assertRaises(ConversionError):
         remote_value.to_knx("a")
Example #5
0
 def test_process(self):
     """Test process telegram."""
     xknx = XKNX(loop=self.loop)
     remote_value = RemoteValueDpt2ByteUnsigned(
         xknx, group_address=GroupAddress("1/2/3"))
     telegram = Telegram(group_address=GroupAddress("1/2/3"),
                         payload=DPTArray((0x0A, 0x0B)))
     self.loop.run_until_complete(remote_value.process(telegram))
     self.assertEqual(remote_value.value, 2571)
 async def test_process(self):
     """Test process telegram."""
     xknx = XKNX()
     remote_value = RemoteValueDpt2ByteUnsigned(
         xknx, group_address=GroupAddress("1/2/3"))
     telegram = Telegram(
         destination_address=GroupAddress("1/2/3"),
         payload=GroupValueWrite(DPTArray((0x0A, 0x0B))),
     )
     await remote_value.process(telegram)
     assert remote_value.value == 2571
 async def test_set(self):
     """Test setting value."""
     xknx = XKNX()
     remote_value = RemoteValueDpt2ByteUnsigned(
         xknx, group_address=GroupAddress("1/2/3"))
     await remote_value.set(2571)
     assert xknx.telegrams.qsize() == 1
     telegram = xknx.telegrams.get_nowait()
     assert telegram == Telegram(
         destination_address=GroupAddress("1/2/3"),
         payload=GroupValueWrite(DPTArray((0x0A, 0x0B))),
     )
     await remote_value.set(5500)
     assert xknx.telegrams.qsize() == 1
     telegram = xknx.telegrams.get_nowait()
     assert telegram == Telegram(
         destination_address=GroupAddress("1/2/3"),
         payload=GroupValueWrite(DPTArray((0x15, 0x7C))),
     )
Example #8
0
 async def test_to_process_error(self):
     """Test process errornous telegram."""
     xknx = XKNX()
     remote_value = RemoteValueDpt2ByteUnsigned(
         xknx, group_address=GroupAddress("1/2/3"))
     with pytest.raises(CouldNotParseTelegram):
         telegram = Telegram(
             destination_address=GroupAddress("1/2/3"),
             payload=GroupValueWrite(DPTBinary(1)),
         )
         await remote_value.process(telegram)
     with pytest.raises(CouldNotParseTelegram):
         telegram = Telegram(
             destination_address=GroupAddress("1/2/3"),
             payload=GroupValueWrite(DPTArray((0x64, ))),
         )
         await remote_value.process(telegram)
     with pytest.raises(CouldNotParseTelegram):
         telegram = Telegram(
             destination_address=GroupAddress("1/2/3"),
             payload=GroupValueWrite(DPTArray((0x64, 0x53, 0x42))),
         )
         await remote_value.process(telegram)
Example #9
0
    def __init__(
        self,
        xknx: XKNX,
        name: str,
        group_address_switch: GroupAddressesType | None = None,
        group_address_switch_state: GroupAddressesType | None = None,
        group_address_brightness: GroupAddressesType | None = None,
        group_address_brightness_state: GroupAddressesType | None = None,
        group_address_color: GroupAddressesType | None = None,
        group_address_color_state: GroupAddressesType | None = None,
        group_address_rgbw: GroupAddressesType | None = None,
        group_address_rgbw_state: GroupAddressesType | None = None,
        group_address_tunable_white: GroupAddressesType | None = None,
        group_address_tunable_white_state: GroupAddressesType | None = None,
        group_address_color_temperature: GroupAddressesType | None = None,
        group_address_color_temperature_state: GroupAddressesType
        | None = None,
        group_address_switch_red: GroupAddressesType | None = None,
        group_address_switch_red_state: GroupAddressesType | None = None,
        group_address_brightness_red: GroupAddressesType | None = None,
        group_address_brightness_red_state: GroupAddressesType | None = None,
        group_address_switch_green: GroupAddressesType | None = None,
        group_address_switch_green_state: GroupAddressesType | None = None,
        group_address_brightness_green: GroupAddressesType | None = None,
        group_address_brightness_green_state: GroupAddressesType | None = None,
        group_address_switch_blue: GroupAddressesType | None = None,
        group_address_switch_blue_state: GroupAddressesType | None = None,
        group_address_brightness_blue: GroupAddressesType | None = None,
        group_address_brightness_blue_state: GroupAddressesType | None = None,
        group_address_switch_white: GroupAddressesType | None = None,
        group_address_switch_white_state: GroupAddressesType | None = None,
        group_address_brightness_white: GroupAddressesType | None = None,
        group_address_brightness_white_state: GroupAddressesType | None = None,
        min_kelvin: int | None = None,
        max_kelvin: int | None = None,
        device_updated_cb: DeviceCallbackType | None = None,
    ):
        """Initialize Light class."""
        super().__init__(xknx, name, device_updated_cb)

        self.switch = RemoteValueSwitch(
            xknx,
            group_address_switch,
            group_address_switch_state,
            device_name=self.name,
            feature_name="State",
            after_update_cb=self.after_update,
        )

        self.brightness = RemoteValueScaling(
            xknx,
            group_address_brightness,
            group_address_brightness_state,
            device_name=self.name,
            feature_name="Brightness",
            after_update_cb=self.after_update,
            range_from=0,
            range_to=255,
        )

        self.color = RemoteValueColorRGB(
            xknx,
            group_address_color,
            group_address_color_state,
            device_name=self.name,
            after_update_cb=self.after_update,
        )

        self.rgbw = RemoteValueColorRGBW(
            xknx,
            group_address_rgbw,
            group_address_rgbw_state,
            device_name=self.name,
            after_update_cb=self.after_update,
        )

        self.tunable_white = RemoteValueScaling(
            xknx,
            group_address_tunable_white,
            group_address_tunable_white_state,
            device_name=self.name,
            feature_name="Tunable white",
            after_update_cb=self.after_update,
            range_from=0,
            range_to=255,
        )

        self.color_temperature = RemoteValueDpt2ByteUnsigned(
            xknx,
            group_address_color_temperature,
            group_address_color_temperature_state,
            device_name=self.name,
            feature_name="Color temperature",
            after_update_cb=self.after_update,
        )

        self.red = _SwitchAndBrightness(
            xknx,
            self.name,
            "red",
            group_address_switch_red,
            group_address_switch_red_state,
            group_address_brightness_red,
            group_address_brightness_red_state,
            self.after_update,
        )

        self.green = _SwitchAndBrightness(
            xknx,
            self.name,
            "green",
            group_address_switch_green,
            group_address_switch_green_state,
            group_address_brightness_green,
            group_address_brightness_green_state,
            self.after_update,
        )

        self.blue = _SwitchAndBrightness(
            xknx,
            self.name,
            "blue",
            group_address_switch_blue,
            group_address_switch_blue_state,
            group_address_brightness_blue,
            group_address_brightness_blue_state,
            self.after_update,
        )

        self.white = _SwitchAndBrightness(
            xknx,
            self.name,
            "white",
            group_address_switch_white,
            group_address_switch_white_state,
            group_address_brightness_white,
            group_address_brightness_white_state,
            self.after_update,
        )

        self.min_kelvin = min_kelvin
        self.max_kelvin = max_kelvin
Example #10
0
    def __init__(
        self,
        xknx,
        name,
        addr,
        sw_cb=None,
        #
        val_cb=None,
        val_dim_cb=None,
        #
        clr_rgb_cb=None,
        clr_rgb_dim=None,
        #
        clr_r_cb=None,
        clr_r_dim_cb=None,
        clr_r_sw_cb=None,
        #
        clr_g_cb=None,
        clr_g_dim_cb=None,
        clr_g_sw_cb=None,
        #
        clr_b_cb=None,
        clr_b_dim_cb=None,
        clr_b_sw_cb=None,
        #
        clr_cct_cb=None,
        clr_cct_dim_cb=None,
        #
        clr_h_cb=None,
        clr_h_dim_cb=None,
        #
        clr_s_cb=None,
        clr_s_dim_cb=None,
    ):
        """Initialize Group class."""
        # pylint: disable=too-many-arguments
        super().__init__(xknx, name)
        self.xknx = xknx

        self.sw = RV_SWITCH(xknx, addr["SW"], None, self.name, sw_cb)
        self.sw_stat = RV_SWITCH(xknx, addr["SW_STAT"], None, self.name)

        self.val = RV_SCALE(
            xknx,
            addr["VAL"],
            None,
            self.name,
            val_cb,
            0,
            255,
        )
        self.val_dim = RV_DIM(xknx, addr["VAL_DIM"], None, self.name,
                              val_dim_cb)
        self.val_stat = RV_SCALE(xknx, addr["VAL_STAT"], None, self.name, None,
                                 0, 255)
        #
        self.clr_xyy = RV_XYY(xknx, addr["CLR_xyY"], None, self.name)
        self.clr_xyy_stat = RV_XYY(xknx, addr["CLR_xyY_STAT"], None, self.name)
        self.clr_cct_abs = RV_ABS(xknx, addr["CLR_CCT_ABS"], None, self.name)
        #
        self.clr_rgb = RV_RGB(xknx, addr["CLR_RGB"], None, self.name,
                              clr_rgb_cb)
        self.clr_rgb_dim = RV_DIM(xknx, addr["CLR_RGB_DIM"], None, self.name,
                                  val_dim_cb)
        self.clr_rgb_stat = RV_RGB(xknx, addr["CLR_RGB_STAT"], None, self.name)
        #
        self.clr_r = RV_SCALE(xknx, addr["CLR_R"], None, self.name, clr_r_cb,
                              0, 255)
        self.clr_r_dim = RV_DIM(xknx, addr["CLR_R_DIM"], None, self.name,
                                clr_r_dim_cb)
        self.clr_r_stat = RV_SCALE(xknx, addr["CLR_R_STAT"], None, self.name,
                                   None, 0, 255)
        self.clr_r_sw = RV_SWITCH(xknx, addr["CLR_R_SW"], None, self.name,
                                  clr_r_sw_cb)
        self.clr_r_sw_stat = RV_SWITCH(xknx, addr["CLR_R_SW_STAT"], None,
                                       self.name)
        #
        self.clr_g = RV_SCALE(xknx, addr["CLR_G"], None, self.name, clr_g_cb,
                              0, 255)
        self.clr_g_dim = RV_DIM(xknx, addr["CLR_G_DIM"], None, self.name,
                                clr_g_dim_cb)
        self.clr_g_stat = RV_SCALE(xknx, addr["CLR_G_STAT"], None, self.name,
                                   None, 0, 255)
        self.clr_g_sw = RV_SWITCH(xknx, addr["CLR_G_SW"], None, self.name,
                                  clr_g_sw_cb)
        self.clr_g_sw_stat = RV_SWITCH(xknx, addr["CLR_G_SW_STAT"], None,
                                       self.name)
        #
        self.clr_b = RV_SCALE(xknx, addr["CLR_B"], None, self.name, clr_b_cb,
                              0, 255)
        self.clr_b_dim = RV_DIM(xknx, addr["CLR_B_DIM"], None, self.name,
                                clr_b_dim_cb)
        self.clr_b_stat = RV_SCALE(xknx, addr["CLR_B_STAT"], None, self.name,
                                   None, 0, 255)
        self.clr_b_sw = RV_SWITCH(xknx, addr["CLR_B_SW"], None, self.name,
                                  clr_b_sw_cb)
        self.clr_b_sw_stat = RV_SWITCH(xknx, addr["CLR_B_SW_STAT"], None,
                                       self.name)
        #
        self.clr_cct = RV_SCALE(xknx, addr["CLR_CCT"], None, self.name,
                                clr_cct_cb, 0, 255)
        self.clr_cct_dim = RV_DIM(xknx, addr["CLR_CCT_DIM"], None, self.name,
                                  clr_cct_dim_cb)
        self.clr_cct_stat = RV_SCALE(xknx, addr["CLR_CCT_STAT"], None,
                                     self.name, None, 0, 255)
        #
        self.clr_h = RV_SCALE(
            xknx,
            addr["CLR_H"],
            None,
            self.name,
            clr_h_cb,
            0,
            360,
        )
        self.clr_h_dim = RV_DIM(xknx, addr["CLR_H_DIM"], None, self.name,
                                clr_h_dim_cb)
        self.clr_h_stat = RV_SCALE(
            xknx,
            addr["CLR_H_STAT"],
            None,
            self.name,
            None,
            0,
            360,
        )
        #
        self.clr_s = RV_SCALE(xknx, addr["CLR_S"], None, self.name, clr_s_cb,
                              0, 255)
        self.clr_s_dim = RV_DIM(xknx, addr["CLR_S_DIM"], None, self.name,
                                clr_s_dim_cb)
        self.clr_s_stat = RV_SCALE(xknx, addr["CLR_S_STAT"], None, self.name,
                                   None, 0, 255)
Example #11
0
class Group(Device):
    """Class for managing a light."""

    # pylint: disable=too-many-locals

    def __init__(
        self,
        xknx,
        name,
        addr,
        sw_cb=None,
        #
        val_cb=None,
        val_dim_cb=None,
        #
        clr_rgb_cb=None,
        clr_rgb_dim=None,
        #
        clr_r_cb=None,
        clr_r_dim_cb=None,
        clr_r_sw_cb=None,
        #
        clr_g_cb=None,
        clr_g_dim_cb=None,
        clr_g_sw_cb=None,
        #
        clr_b_cb=None,
        clr_b_dim_cb=None,
        clr_b_sw_cb=None,
        #
        clr_cct_cb=None,
        clr_cct_dim_cb=None,
        #
        clr_h_cb=None,
        clr_h_dim_cb=None,
        #
        clr_s_cb=None,
        clr_s_dim_cb=None,
    ):
        """Initialize Group class."""
        # pylint: disable=too-many-arguments
        super().__init__(xknx, name)
        self.xknx = xknx

        self.sw = RV_SWITCH(xknx, addr["SW"], None, self.name, sw_cb)
        self.sw_stat = RV_SWITCH(xknx, addr["SW_STAT"], None, self.name)

        self.val = RV_SCALE(
            xknx,
            addr["VAL"],
            None,
            self.name,
            val_cb,
            0,
            255,
        )
        self.val_dim = RV_DIM(xknx, addr["VAL_DIM"], None, self.name,
                              val_dim_cb)
        self.val_stat = RV_SCALE(xknx, addr["VAL_STAT"], None, self.name, None,
                                 0, 255)
        #
        self.clr_xyy = RV_XYY(xknx, addr["CLR_xyY"], None, self.name)
        self.clr_xyy_stat = RV_XYY(xknx, addr["CLR_xyY_STAT"], None, self.name)
        self.clr_cct_abs = RV_ABS(xknx, addr["CLR_CCT_ABS"], None, self.name)
        #
        self.clr_rgb = RV_RGB(xknx, addr["CLR_RGB"], None, self.name,
                              clr_rgb_cb)
        self.clr_rgb_dim = RV_DIM(xknx, addr["CLR_RGB_DIM"], None, self.name,
                                  val_dim_cb)
        self.clr_rgb_stat = RV_RGB(xknx, addr["CLR_RGB_STAT"], None, self.name)
        #
        self.clr_r = RV_SCALE(xknx, addr["CLR_R"], None, self.name, clr_r_cb,
                              0, 255)
        self.clr_r_dim = RV_DIM(xknx, addr["CLR_R_DIM"], None, self.name,
                                clr_r_dim_cb)
        self.clr_r_stat = RV_SCALE(xknx, addr["CLR_R_STAT"], None, self.name,
                                   None, 0, 255)
        self.clr_r_sw = RV_SWITCH(xknx, addr["CLR_R_SW"], None, self.name,
                                  clr_r_sw_cb)
        self.clr_r_sw_stat = RV_SWITCH(xknx, addr["CLR_R_SW_STAT"], None,
                                       self.name)
        #
        self.clr_g = RV_SCALE(xknx, addr["CLR_G"], None, self.name, clr_g_cb,
                              0, 255)
        self.clr_g_dim = RV_DIM(xknx, addr["CLR_G_DIM"], None, self.name,
                                clr_g_dim_cb)
        self.clr_g_stat = RV_SCALE(xknx, addr["CLR_G_STAT"], None, self.name,
                                   None, 0, 255)
        self.clr_g_sw = RV_SWITCH(xknx, addr["CLR_G_SW"], None, self.name,
                                  clr_g_sw_cb)
        self.clr_g_sw_stat = RV_SWITCH(xknx, addr["CLR_G_SW_STAT"], None,
                                       self.name)
        #
        self.clr_b = RV_SCALE(xknx, addr["CLR_B"], None, self.name, clr_b_cb,
                              0, 255)
        self.clr_b_dim = RV_DIM(xknx, addr["CLR_B_DIM"], None, self.name,
                                clr_b_dim_cb)
        self.clr_b_stat = RV_SCALE(xknx, addr["CLR_B_STAT"], None, self.name,
                                   None, 0, 255)
        self.clr_b_sw = RV_SWITCH(xknx, addr["CLR_B_SW"], None, self.name,
                                  clr_b_sw_cb)
        self.clr_b_sw_stat = RV_SWITCH(xknx, addr["CLR_B_SW_STAT"], None,
                                       self.name)
        #
        self.clr_cct = RV_SCALE(xknx, addr["CLR_CCT"], None, self.name,
                                clr_cct_cb, 0, 255)
        self.clr_cct_dim = RV_DIM(xknx, addr["CLR_CCT_DIM"], None, self.name,
                                  clr_cct_dim_cb)
        self.clr_cct_stat = RV_SCALE(xknx, addr["CLR_CCT_STAT"], None,
                                     self.name, None, 0, 255)
        #
        self.clr_h = RV_SCALE(
            xknx,
            addr["CLR_H"],
            None,
            self.name,
            clr_h_cb,
            0,
            360,
        )
        self.clr_h_dim = RV_DIM(xknx, addr["CLR_H_DIM"], None, self.name,
                                clr_h_dim_cb)
        self.clr_h_stat = RV_SCALE(
            xknx,
            addr["CLR_H_STAT"],
            None,
            self.name,
            None,
            0,
            360,
        )
        #
        self.clr_s = RV_SCALE(xknx, addr["CLR_S"], None, self.name, clr_s_cb,
                              0, 255)
        self.clr_s_dim = RV_DIM(xknx, addr["CLR_S_DIM"], None, self.name,
                                clr_s_dim_cb)
        self.clr_s_stat = RV_SCALE(xknx, addr["CLR_S_STAT"], None, self.name,
                                   None, 0, 255)

    def update(self, addresses):
        self.sw.group_addresses = addresses["SW"]
        self.sw_stat.group_addresses = addresses["SW_STAT"]
        #
        self.val.group_addresses = addresses["VAL"]
        self.val_dim.group_addresses = addresses["VAL_DIM"]
        self.val_stat.group_addresses = addresses["VAL_STAT"]
        #
        self.clr_xyy.group_addresses = addresses["CLR_xyY"]
        self.clr_xyy_stat.group_addresses = addresses["CLR_xyY_STAT"]
        self.clr_cct_abs.group_addresses = addresses["CLR_CCT_ABS"]
        #
        self.clr_rgb.group_addresses = addresses["CLR_RGB"]
        self.clr_rgb_dim.group_addresses = addresses["CLR_RGB"]
        self.clr_rgb_stat.group_addresses = addresses["CLR_RGB_STAT"]
        #
        self.clr_r.group_addresses = addresses["CLR_R"]
        self.clr_r_dim.group_addresses = addresses["CLR_R_DIM"]
        self.clr_r_stat.group_addresses = addresses["CLR_R_STAT"]
        self.clr_r_sw.group_addresses = addresses["CLR_R_SW"]
        self.clr_r_sw_stat.group_addresses = addresses["CLR_R_SW_STAT"]
        #
        self.clr_g.group_addresses = addresses["CLR_G"]
        self.clr_g_dim.group_addresses = addresses["CLR_G_DIM"]
        self.clr_g_stat.group_addresses = addresses["CLR_G_STAT"]
        self.clr_g_sw.group_addresses = addresses["CLR_G_SW"]
        self.clr_g_sw_stat.group_addresses = addresses["CLR_G_SW_STAT"]
        #
        self.clr_b.group_addresses = addresses["CLR_B"]
        self.clr_b_dim.group_addresses = addresses["CLR_B_DIM"]
        self.clr_b_stat.group_addresses = addresses["CLR_B_STAT"]
        self.clr_b_sw.group_addresses = addresses["CLR_B_SW"]
        self.clr_b_sw_stat.group_addresses = addresses["CLR_B_SW_STAT"]
        #
        self.clr_cct.group_addresses = addresses["CLR_CCT"]
        self.clr_cct_dim.group_addresses = addresses["CLR_CCT_DIM"]
        self.clr_cct_stat.group_addresses = addresses["CLR_CCT_STAT"]
        #
        self.clr_h.group_addresses = addresses["CLR_H"]
        self.clr_h_dim.group_addresses = addresses["CLR_H_DIM"]
        self.clr_h_stat.group_addresses = addresses["CLR_H_STAT"]
        #
        self.clr_s.group_addresses = addresses["CLR_S"]
        self.clr_s_dim.group_addresses = addresses["CLR_S_DIM"]
        self.clr_s_stat.group_addresses = addresses["CLR_S_STAT"]

    @property
    def supports_dimming(self):
        return self.dimming_val.initialized

    @property
    def supports_brightness(self):
        return self.brightness.initialized

    @property
    def supports_color(self):
        return self.color_rgb.initialized

    @property
    def supports_color_xyY(self):
        return self.color_xyY.initialized

    def has_group_address(self, group_address):
        """Test if device has given group address. Not used for Status"""
        return (
            self.sw.has_group_address(group_address)
            or self.val.has_group_address(group_address)  # noqa W503
            or self.val_dim.has_group_address(group_address)  # noqa W503
            #
            or self.clr_xyy.has_group_address(group_address)  # noqa W503
            or self.clr_cct_abs.has_group_address(group_address)  # noqa W503
            #
            or self.clr_rgb.has_group_address(group_address)  # noqa W503
            or self.clr_rgb_dim.has_group_address(group_address)  # noqa W503
            #
            or self.clr_r.has_group_address(group_address)  # noqa W503
            or self.clr_r_dim.has_group_address(group_address)  # noqa W503
            or self.clr_r_sw.has_group_address(group_address)  # noqa W503
            #
            or self.clr_g.has_group_address(group_address)  # noqa W503
            or self.clr_g_dim.has_group_address(group_address)  # noqa W503
            or self.clr_g_sw.has_group_address(group_address)  # noqa W503
            #
            or self.clr_b.has_group_address(group_address)  # noqa W503
            or self.clr_b_dim.has_group_address(group_address)  # noqa W503
            or self.clr_b_sw.has_group_address(group_address)  # noqa W503
            #
            or self.clr_h.has_group_address(group_address)  # noqa W503
            or self.clr_h_dim.has_group_address(group_address)  # noqa W503
            #
            or self.clr_s.has_group_address(group_address)  # noqa W503
            or self.clr_s_dim.has_group_address(group_address)  # noqa W503
            #
            or self.clr_cct.has_group_address(group_address)  # noqa W503
            or self.clr_cct_dim.has_group_address(group_address)  # noqa W503
        )

    def __repr__(self):
        """Return object as readable string."""
        return (
            f"KNX_Group(name={self.name}, sw:{self.sw.group_address}"
            f", sw_stat: {self.sw_stat.group_address}"
            f", val_dim:{self.val_dim.group_address}, val:{self.val.group_address}"
            f", clr_xyy: {self.clr_xyy.group_address}, clr_rgb: {self.clr_rgb.group_address}"
            f", clr_rgb_stat:{self.clr_rgb_stat.group_address}")

    async def process_group_write(self, telegram):
        """Process incoming GROUP WRITE telegram."""
        await self.sw.process(telegram)
        await self.val_dim.process(telegram)
        await self.val.process(telegram)
        #
        # await self.clr_xyy.process(telegram)
        #
        await self.clr_rgb.process(telegram)
        await self.clr_rgb_dim.process(telegram)
        #
        await self.clr_r.process(telegram)
        await self.clr_r_dim.process(telegram)
        await self.clr_r_sw.process(telegram)
        #
        await self.clr_g.process(telegram)
        await self.clr_g_dim.process(telegram)
        await self.clr_g_sw.process(telegram)
        #
        await self.clr_b.process(telegram)
        await self.clr_b_dim.process(telegram)
        await self.clr_b_sw.process(telegram)
        #
        await self.clr_h.process(telegram)
        await self.clr_h_dim.process(telegram)
        #
        await self.clr_s.process(telegram)
        await self.clr_s_dim.process(telegram)
        #
        await self.clr_cct.process(telegram)
        await self.clr_cct_dim.process(telegram)

    def __eq__(self, other):
        """Equal operator."""
        return self.__dict__ == other.__dict__
Example #12
0
    def __init__(self,
                 xknx,
                 name,
                 group_address_switch=None,
                 group_address_switch_state=None,
                 group_address_brightness=None,
                 group_address_brightness_state=None,
                 group_address_color=None,
                 group_address_color_state=None,
                 group_address_rgbw=None,
                 group_address_rgbw_state=None,
                 group_address_tunable_white=None,
                 group_address_tunable_white_state=None,
                 group_address_color_temperature=None,
                 group_address_color_temperature_state=None,
                 min_kelvin=None,
                 max_kelvin=None,
                 device_updated_cb=None):
        """Initialize Light class."""
        # pylint: disable=too-many-arguments
        super().__init__(xknx, name, device_updated_cb)

        self.switch = RemoteValueSwitch(xknx,
                                        group_address_switch,
                                        group_address_switch_state,
                                        device_name=self.name,
                                        feature_name="State",
                                        after_update_cb=self.after_update)

        self.brightness = RemoteValueScaling(xknx,
                                             group_address_brightness,
                                             group_address_brightness_state,
                                             device_name=self.name,
                                             feature_name="Brightness",
                                             after_update_cb=self.after_update,
                                             range_from=0,
                                             range_to=255)

        self.color = RemoteValueColorRGB(xknx,
                                         group_address_color,
                                         group_address_color_state,
                                         device_name=self.name,
                                         after_update_cb=self.after_update)

        self.rgbw = RemoteValueColorRGBW(xknx,
                                         group_address_rgbw,
                                         group_address_rgbw_state,
                                         device_name=self.name,
                                         after_update_cb=self.after_update)

        self.tunable_white = RemoteValueScaling(
            xknx,
            group_address_tunable_white,
            group_address_tunable_white_state,
            device_name=self.name,
            feature_name="Tunable white",
            after_update_cb=self.after_update,
            range_from=0,
            range_to=255)

        self.color_temperature = RemoteValueDpt2ByteUnsigned(
            xknx,
            group_address_color_temperature,
            group_address_color_temperature_state,
            device_name=self.name,
            feature_name="Color temperature",
            after_update_cb=self.after_update)

        self.min_kelvin = min_kelvin
        self.max_kelvin = max_kelvin
Example #13
0
 def test_from_knx(self):
     """Test from_knx function with normal operation."""
     xknx = XKNX()
     remote_value = RemoteValueDpt2ByteUnsigned(xknx)
     self.assertEqual(remote_value.from_knx(DPTArray((0x0A, 0x0B))), 2571)
 def test_to_knx(self):
     """Test to_knx function with normal operation."""
     xknx = XKNX(loop=self.loop)
     remote_value = RemoteValueDpt2ByteUnsigned(xknx)
     self.assertEqual(remote_value.to_knx(2571), DPTArray((0x0A, 0x0B)))
 def test_to_knx(self):
     """Test to_knx function with normal operation."""
     xknx = XKNX()
     remote_value = RemoteValueDpt2ByteUnsigned(xknx)
     assert remote_value.to_knx(2571) == DPTArray((0x0A, 0x0B))