|
3 | 3 | from enum import IntEnum |
4 | 4 | from typing import TYPE_CHECKING, Any, List |
5 | 5 |
|
| 6 | +from inelsmqtt.utils.common import SettableAttribute |
| 7 | + |
6 | 8 | if TYPE_CHECKING: |
7 | 9 | from inelsmqtt.utils.core import DeviceValue |
8 | 10 |
|
@@ -93,6 +95,9 @@ class Command(IntEnum): |
93 | 95 |
|
94 | 96 | DATA: DataDict = {RELAY: 1} |
95 | 97 |
|
| 98 | + # NOTE: This dictionary is used ONLY for testing purposes. |
| 99 | + SETTABLE_ATTRIBUTES = {"is_on": SettableAttribute("simple_relay.0.is_on", bool, [True, False])} |
| 100 | + |
96 | 101 | @classmethod |
97 | 102 | def COMM_TEST(cls) -> str: |
98 | 103 | return cls.create_command_payload(cls.Command.COMM_TEST) |
@@ -138,6 +143,8 @@ class Command(IntEnum): |
138 | 143 | TIME_HIGH_BYTE = 0 |
139 | 144 | TIME_LOW_BYTE = 0 |
140 | 145 |
|
| 146 | + SETTABLE_ATTRIBUTES = {"is_on": SettableAttribute("simple_relay.0.is_on", bool, [True, False])} |
| 147 | + |
141 | 148 | @classmethod |
142 | 149 | def COMM_TEST(cls) -> str: |
143 | 150 | return cls.create_command_payload(cls.Command.COMM_TEST, cls.TIME_HIGH_BYTE, cls.TIME_LOW_BYTE) |
@@ -193,6 +200,14 @@ class Command(IntEnum): |
193 | 200 | Shutter_state.Stop_down: Command.STOP_DOWN, |
194 | 201 | } |
195 | 202 |
|
| 203 | + SETTABLE_ATTRIBUTES = { |
| 204 | + "state": SettableAttribute( |
| 205 | + "shutters.0.state", |
| 206 | + Shutter_state, |
| 207 | + [Shutter_state.Open, Shutter_state.Closed, Shutter_state.Stop_up, Shutter_state.Stop_down], |
| 208 | + ), |
| 209 | + } |
| 210 | + |
196 | 211 | @classmethod |
197 | 212 | def COMM_TEST(cls) -> str: |
198 | 213 | return cls.create_command_payload(cls.Command.COMM_TEST, cls.TIME_HIGH_BYTE, cls.TIME_LOW_BYTE) |
@@ -235,6 +250,10 @@ class Command(IntEnum): |
235 | 250 |
|
236 | 251 | DATA: DataDict = {RF_DIMMER: [0, 1]} |
237 | 252 |
|
| 253 | + SETTABLE_ATTRIBUTES = { |
| 254 | + "brightness": SettableAttribute("simple_light.0.brightness", int, list(range(0, 101, 10))), |
| 255 | + } |
| 256 | + |
238 | 257 | @classmethod |
239 | 258 | def COMM_TEST(cls) -> str: |
240 | 259 | return cls.create_command_payload(cls.Command.COMM_TEST) |
@@ -279,6 +298,10 @@ class Command(IntEnum): |
279 | 298 |
|
280 | 299 | DATA: DataDict = {RF_DIMMER: [0, 1]} |
281 | 300 |
|
| 301 | + SETTABLE_ATTRIBUTES = { |
| 302 | + "brightness": SettableAttribute("simple_light.0.brightness", int, list(range(0, 101, 10))), |
| 303 | + } |
| 304 | + |
282 | 305 | @classmethod |
283 | 306 | def COMM_TEST(cls) -> str: |
284 | 307 | return cls.create_command_payload(cls.Command.COMM_TEST) |
@@ -321,6 +344,13 @@ class Command(IntEnum): |
321 | 344 |
|
322 | 345 | DATA: DataDict = {RED: [1], GREEN: [2], BLUE: [3], OUT: [4]} |
323 | 346 |
|
| 347 | + SETTABLE_ATTRIBUTES = { |
| 348 | + "red": SettableAttribute("rgb.0.r", int, list(range(0, 256))), |
| 349 | + "green": SettableAttribute("rgb.0.g", int, list(range(0, 256))), |
| 350 | + "blue": SettableAttribute("rgb.0.b", int, list(range(0, 256))), |
| 351 | + "brightness": SettableAttribute("rgb.0.brightness", int, list(range(0, 256))), |
| 352 | + } |
| 353 | + |
324 | 354 | @classmethod |
325 | 355 | def COMM_TEST(cls) -> str: |
326 | 356 | return cls.create_command_payload(cls.Command.COMM_TEST, 0, 0, 0, 0) |
@@ -377,6 +407,10 @@ class Command(IntEnum): |
377 | 407 | False: Command.OFF, |
378 | 408 | } |
379 | 409 |
|
| 410 | + SETTABLE_ATTRIBUTES = { |
| 411 | + "is_on": SettableAttribute("simple_relay.0.is_on", bool, [True, False]), |
| 412 | + } |
| 413 | + |
380 | 414 | @classmethod |
381 | 415 | def COMM_TEST(cls) -> str: |
382 | 416 | return cls.create_command_payload(cls.Command.COMM_TEST) |
@@ -418,6 +452,10 @@ class DT_09(CommTest): |
418 | 452 | REQUIRED_TEMP: [3], |
419 | 453 | } |
420 | 454 |
|
| 455 | + SETTABLE_ATTRIBUTES = { |
| 456 | + "required_temp": SettableAttribute("thermovalve.required", float, [x / 2 for x in range(0, 129)]), |
| 457 | + } |
| 458 | + |
421 | 459 | @staticmethod |
422 | 460 | def create_command_payload(temp_required: int) -> str: |
423 | 461 | return Formatter.format_data([0, temp_required, 0]) |
@@ -502,6 +540,11 @@ class Command(IntEnum): |
502 | 540 |
|
503 | 541 | DATA: DataDict = {OUT: [4], WHITE: [5]} |
504 | 542 |
|
| 543 | + SETTABLE_ATTRIBUTES = { |
| 544 | + "brightness": SettableAttribute("warm_light.0.brightness", int, list(range(0, 101))), |
| 545 | + "relative_ct": SettableAttribute("warm_light.0.relative_ct", int, list(range(0, 101))), |
| 546 | + } |
| 547 | + |
505 | 548 | @classmethod |
506 | 549 | def COMM_TEST(cls) -> str: |
507 | 550 | return cls.create_command_payload(cls.Command.COMM_TEST) |
@@ -710,6 +753,15 @@ class Command(IntEnum): |
710 | 753 | Shutter_state.Stop_down: Command.STOP_DOWN, |
711 | 754 | } |
712 | 755 |
|
| 756 | + SETTABLE_ATTRIBUTES = { |
| 757 | + "state": SettableAttribute( |
| 758 | + "shutters_with_pos.0.state", |
| 759 | + Shutter_state, |
| 760 | + [Shutter_state.Open, Shutter_state.Closed, Shutter_state.Stop_up, Shutter_state.Stop_down], |
| 761 | + ), |
| 762 | + "position": SettableAttribute("shutters_with_pos.0.position", int, list(range(0, 101))), |
| 763 | + } |
| 764 | + |
713 | 765 | @classmethod |
714 | 766 | def COMM_TEST(cls) -> str: |
715 | 767 | return cls.create_command_payload(cls.Command.COMM_TEST, cls.HIGH_BYTE, cls.LOW_BYTE) |
|
0 commit comments