/
commands.py
1295 lines (982 loc) · 27.4 KB
/
commands.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
from enum import Enum
from .command import Command
from .fields import (Enum as EnumField, Int, IntHL, Bool, Str, Time12H, Time,
DateTime, Bitmask, IPAddress, VideoWallModel)
from .utils import parse_enum_bitmask
class SERIAL_NUMBER(Command):
CMD = 0x0B
GET, SET = True, False
DATA = [Str('SERIAL_NUMBER')]
class ERROR_STATUS(Command):
CMD = 0x0D
GET, SET = True, False
class LAMP_ERROR_STATE(Enum):
NORMAL = 0x00
ERROR = 0x01
class TEMPERATURE_ERROR_STATE(Enum):
NORMAL = 0x00
ERROR = 0x01
class BRIGHTNESS_SENSOR_ERROR_STATE(Enum):
NONE = 0x00
ERROR = 0x01
NORMAL = 0x02
class INPUT_SOURCE_ERROR_STATE(Enum):
"""
No_Sync Error
Note: Invalid status will be replied with app source selected state.
Error status will be replied with input signal of not supported
resolution or no signal.
"""
NORMAL = 0x00
ERROR = 0x01
INVALID = 0x02
class FAN_ERROR_STATE(Enum):
NORMAL = 0x00
ERROR = 0x01
NONE = 0x02 # Fan is not supported
DATA = [
LAMP_ERROR_STATE,
TEMPERATURE_ERROR_STATE,
BRIGHTNESS_SENSOR_ERROR_STATE,
INPUT_SOURCE_ERROR_STATE,
Int('TEMPERATURE'),
FAN_ERROR_STATE,
]
class SOFTWARE_VERSION(Command):
CMD = 0x0E
GET, SET = True, False
DATA = [Str('SOFTWARE_VERSION')]
class MODEL_NUMBER(Command):
CMD = 0x10
GET, SET = True, False
class MODEL_SPECIES(Enum):
PDP = 0x01
LCD = 0x02
DLP = 0x03
LED = 0x04
CRT = 0x05
OLED = 0x06
class TV_SUPPORT(Enum):
SUPPORTED = 0x00
NOT_SUPPORTED = 0x01
# NOTE: Actually there is list of MODEL_CODE in specification,
# but it's TOO long, and it's TOO old (newer models gets new code)
DATA = [MODEL_SPECIES, Int('MODEL_CODE'), TV_SUPPORT]
class POWER(Command):
CMD = 0x11
GET, SET = True, True
class POWER_STATE(Enum):
OFF = 0x00
ON = 0x01
REBOOT = 0x02
DATA = [POWER_STATE]
class VOLUME(Command):
CMD = 0x12
GET, SET = True, True
VOLUME = Int('VOLUME', range(101))
DATA = [VOLUME]
class MUTE(Command):
CMD = 0x13
GET, SET = True, True
class MUTE_STATE(Enum):
OFF = 0x00
ON = 0x01
NONE = 0x255 # Unavailable
DATA = [MUTE_STATE]
class INPUT_SOURCE(Command):
"""
Get/Set the device source which is shown on the screen.
DVI_VIDEO, HDMI1_PC, HDMI2_PC, HDMI3_PC, HDMI4_PC: get only.
URL_LAUNCHER, MAGIC_INFO, TV or some ports require support by model.
On TIMER functions, Do not use WIDI_SCREEN_MIRRORING.
"""
CMD = 0x14
GET, SET = True, True
class INPUT_SOURCE_STATE(Enum):
# not a valid value for INPUT_SOURCE, but valid for auto_source
NONE = 0x00
S_VIDEO = 0x04
COMPONENT = 0x08
AV = 0x0C
AV2 = 0x0D
SCART1 = 0x0E
DVI = 0x18
PC = 0x14
BNC = 0x1E
DVI_VIDEO = 0x1F # get only
MAGIC_INFO = 0x20
HDMI1 = 0x21
HDMI1_PC = 0x22 # get only
HDMI2 = 0x23
HDMI2_PC = 0x24 # get only
DISPLAY_PORT_1 = 0x25
DISPLAY_PORT_2 = 0x26
DISPLAY_PORT_3 = 0x27
RF_TV = 0x30 # deprecated
HDMI3 = 0x31
HDMI3_PC = 0x32 # get only
HDMI4 = 0x33
HDMI4_PC = 0x34 # get only
TV_DTV = 0x40
PLUG_IN_MODE = 0x50
HD_BASE_T = 0x55
OCM = 0x56
MEDIA_MAGIC_INFO_S = 0x60
WIDI_SCREEN_MIRRORING = 0x61
INTERNAL_USB = 0x62
URL_LAUNCHER = 0x63
IWB = 0x64
WEB_BROWSER = 0x65
REMOTE_WORKSPACE = 0x66
DATA = [INPUT_SOURCE_STATE]
class PICTURE_ASPECT(Command):
"""
Get/Set the device picture size (aspect ratio).
Working Condition:
Will not work with VIDEO_WALL_STATE is ON.
Note:
Some of the image sizes are not supported depending on input signals.
"""
CMD = 0x15
GET, SET = True, True
class PICTURE_ASPECT_STATE(Enum):
PC_16_9 = 0x10
PC_4_3 = 0x18
PC_ORIGINAL_RATIO = 0x20
PC_21_9 = 0x21
PC_CUSTOM = 0x22
VIDEO_AUTO_WIDE = 0x00
VIDEO_16_9 = 0x01
VIDEO_ZOOM = 0x04
VIDEO_ZOOM_1 = 0x05
VIDEO_ZOOM_2 = 0x06
VIDEO_SCREEN_FIT = 0x09
VIDEO_4_3 = 0x0B
VIDEO_WIDE_FIT = 0x0C
VIDEO_CUSTOM = 0x0D
VIDEO_SMART_VIEW_1 = 0x0E
VIDEO_SMART_VIEW_2 = 0x0F
VIDEO_WIDE_ZOOM = 0x31
VIDEO_21_9 = 0x32
DATA = [PICTURE_ASPECT_STATE]
class SCREEN_MODE(Command):
CMD = 0x18
GET, SET = True, True
class SCREEN_MODE_STATE(Enum):
MODE_16_9 = 0x01
MODE_ZOOM = 0x04
MODE_4_3 = 0x0B
MODE_WIDE_ZOOM = 0x31
DATA = [SCREEN_MODE_STATE]
class SCREEN_SIZE(Command):
CMD = 0x19
GET, SET = True, False
DATA = [Int('INCHES', range(256))]
class NETWORK_CONFIGURATION(Command):
CMD = 0x1B
SUBCMD = 0x82
GET, SET = True, True
DATA = [
IPAddress('IP_ADDRESS'),
IPAddress('SUBNET_MASK'),
IPAddress('GATEWAY_ADDRESS'),
IPAddress('DNS_SERVER_ADDRESS'),
]
class NETWORK_MODE(Command):
CMD = 0x1B
SUBCMD = 0x85
GET, SET = True, True
class NETWORK_MODE_STATE(Enum):
DYNAMIC = 0x00
STATIC = 0x01
DATA = [NETWORK_MODE_STATE]
class WEEKLY_RESTART(Command):
CMD = 0x1B
SUBCMD = 0xA2
GET, SET = True, True
class WEEKDAY(Enum):
# NOTE: codes differs from TIMER_15.WEEKDAY
SUN = 0x00
SAT = 0x01
FRI = 0x02
THU = 0x03
WED = 0x04
TUE = 0x05
MON = 0x06
DATA = [Bitmask(WEEKDAY), Time()]
class MAGICINFO_SERVER(Command):
"""
MagicInfo Server URL.
Example: "http://example.com:80"
"""
CMD = 0x1C
SUBCMD = 0x82
GET, SET = True, True
DATA = [Str('MAGICINFO_SERVER_URL')]
class MDC_CONNECTION(Command):
"""
Note: Depends on the product specification,
if it is set as RJ45 then serial MDC will not work.
"""
CMD = 0x1D
GET, SET = True, True
class MDC_CONNECTION_TYPE(Enum):
RS232C = 0x00
RJ45 = 0x01
DATA = [MDC_CONNECTION_TYPE]
class CONTRAST(Command):
CMD = 0x24
GET, SET = True, True
DATA = [Int('CONTRAST', range(101))]
class BRIGHTNESS(Command):
CMD = 0x25
GET, SET = True, True
DATA = [Int('BRIGHTNESS', range(101))]
class SHARPNESS(Command):
CMD = 0x26
GET, SET = True, True
DATA = [Int('SHARPNESS', range(101))]
class COLOR(Command):
CMD = 0x27
GET, SET = True, True
DATA = [Int('COLOR', range(101))]
class TINT(Command):
"""
Control the device tint. Adjust the ratio of green to red tint level.
Red: TINT value, Green: ( 100 - TINT ) value.
Note: Tint could only be set in 50 Steps (0, 2, 4, 6... 100).
"""
CMD = 0x28
GET, SET = True, True
DATA = [Int('TINT', range(101))]
class H_POSITION(Command):
CMD = 0x31
GET, SET = False, True
class H_POSITION_MOVE_TO(Enum):
LEFT = 0x00
RIGHT = 0x01
DATA = [H_POSITION_MOVE_TO]
class V_POSITION(Command):
CMD = 0x32
GET, SET = False, True
class V_POSITION_MOVE_TO(Enum):
UP = 0x00
DOWN = 0x01
DATA = [V_POSITION_MOVE_TO]
class AUTO_POWER(Command):
CMD = 0x33
GET, SET = True, True
class AUTO_POWER_STATE(Enum):
OFF = 0x00
ON = 0x01
DATA = [AUTO_POWER_STATE]
class CLEAR_MENU(Command):
CMD = 0x34
SUBCMD = 0x00
GET, SET = False, True
DATA = []
class IR_STATE(Command):
"""
Enables/disables IR (Infrared) receiving function (Remote Control).
Working Condition:
* Can operate regardless of whether power is ON/OFF.
(If DPMS Situation in LFD, it operate Remocon regardless of set value).
"""
CMD = 0x36
GET, SET = True, True
class IR_STATE(Enum):
DISABLED = 0x00
ENABLED = 0x01
DATA = [IR_STATE]
class RGB_CONTRAST(Command):
CMD = 0x37
GET, SET = True, True
DATA = [Int('CONTRAST', range(101))]
class RGB_BRIGHTNESS(Command):
CMD = 0x38
GET, SET = True, True
DATA = [Int('BRIGHTNESS', range(101))]
class AUTO_ADJUSTMENT_ON(Command):
CMD = 0x3D
SUBCMD = 0x00
GET, SET = False, True
DATA = []
class COLOR_TONE(Command):
CMD = 0x3E
GET, SET = True, True
class COLOR_TONE_STATE(Enum):
COOL_2 = 0x00
COOL_1 = 0x01
NORMAL = 0x02
WARM_1 = 0x03
WARM_2 = 0x04
OFF = 0x50
DATA = [COLOR_TONE_STATE]
class COLOR_TEMPERATURE(Command):
"""
Color temperature function.
Unit is hectoKelvin (hK) (x*100 Kelvin) (example: 28 = 2800K).
Supported values - 28, 30, 35, 40... 160.
For older models: 0-10=(x*100K + 5000K), 253=2800K, 254=3000K, 255=4000K
"""
CMD = 0x3F
GET, SET = True, True
DATA = [Int('HECTO_KELVIN')]
class STANDBY(Command):
CMD = 0x4A
GET, SET = True, True
class STANDBY_STATE(Enum):
OFF = 0x00
ON = 0x01
AUTO = 0x02
DATA = [STANDBY_STATE]
class AUTO_LAMP(Command):
"""
Auto Lamp function (backlight).
Note: When Manual Lamp Control is on,
Auto Lamp Control will automatically turn off.
"""
CMD = 0x57
GET, SET = True, True
DATA = [
Time12H('MAX_TIME'),
Int('MAX_LAMP_VALUE', range(101)),
Time12H('MIN_TIME'),
Int('MIN_LAMP_VALUE', range(101)),
]
class MANUAL_LAMP(Command):
"""
Manual Lamp function (backlight).
Note: When Auto Lamp Control is on,
Manual Lamp Control will automatically turn off.
"""
CMD = 0x58
GET, SET = True, True
DATA = [Int('LAMP_VALUE', range(101))]
class INVERSE(Command):
CMD = 0x5A
GET, SET = True, True
class INVERSE_STATE(Enum):
OFF = 0x00
ON = 0x01
DATA = [INVERSE_STATE]
class SAFETY_LOCK(Command):
CMD = 0x5D
GET, SET = True, True
class LOCK_STATE(Enum):
OFF = 0x00
ON = 0x01
DATA = [LOCK_STATE]
class PANEL_LOCK(Command):
CMD = 0x5F
GET, SET = True, True
class LOCK_STATE(Enum):
OFF = 0x00
ON = 0x01
DATA = [LOCK_STATE]
class CHANNEL_CHANGE(Command):
CMD = 0x61
GET, SET = False, True
class CHANGE_TO(Enum):
UP = 0x00
DOWN = 0x01
DATA = [CHANGE_TO]
class VOLUME_CHANGE(Command):
CMD = 0x62
GET, SET = False, True
class CHANGE_TO(Enum):
UP = 0x00
DOWN = 0x01
DATA = [CHANGE_TO]
class TICKER(Command):
"""
Get/Set the device ticker. (Show text message overlay on the screen)
Note: POS_HORIZ or POS_VERT are NONE in GET response
if unsupported by the display.
"""
CMD = 0x63
GET, SET = True, True
class POS_HORIZ(Enum):
CENTER = 0x00
LEFT = 0x01
RIGHT = 0x02
NONE = 0xFF
class POS_VERTI(Enum):
MIDDLE = 0x00
TOP = 0x01
BOTTOM = 0x02
NONE = 0xFF
class MOTION_DIR(Enum):
LEFT = 0x00
RIGHT = 0x01
UP = 0x02
DOWN = 0x03
class MOTION_SPEED(Enum):
NORMAL = 0x00
SLOW = 0x01
FAST = 0x02
class FONT_SIZE(Enum):
STANDARD = 0x00
SMALL = 0x01
LARGE = 0x02
class FOREGROUND_COLOR(Enum):
BLACK = 0x00
WHITE = 0x01
RED = 0x02
GREEN = 0x03
BLUE = 0x04
YELLOW = 0x05
MAGENTA = 0x06
CYAN = 0x07
class BACKGROUND_COLOR(Enum):
BLACK = 0x00
WHITE = 0x01
RED = 0x02
GREEN = 0x03
BLUE = 0x04
YELLOW = 0x05
MAGENTA = 0x06
CYAN = 0x07
class FOREGROUND_OPACITY(Enum):
FLASHING = 0x03
FLASH_ALL = 0x04
OFF = 0x05
class BACKGROUND_OPACITY(Enum):
SOLID = 0x00
TRANSPARENT = 0x01
TRANSLUCENT = 0x02
UNKNOWN = 0x03
DATA = [
Bool('ON_OFF'),
Time12H('START_TIME'),
Time12H('END_TIME'),
POS_HORIZ,
POS_VERTI,
Bool('MOTION_ON_OFF'),
MOTION_DIR,
MOTION_SPEED,
FONT_SIZE,
FOREGROUND_COLOR,
BACKGROUND_COLOR,
FOREGROUND_OPACITY,
BACKGROUND_OPACITY,
Str('MESSAGE')
]
class DEVICE_NAME(Command):
"""
It reads the device name which user set up in network.
Shows the information about entered device name.
"""
CMD = 0x67
GET, SET = True, False
DATA = [Str('DEVICE_NAME')]
class OSD(Command):
"""
Turns OSD (On-screen display) on/off.
"""
CMD = 0x70
GET, SET = True, True
DATA = [Bool('OSD_ENABLED')]
class PICTURE_MODE(Command):
CMD = 0x71
GET, SET = True, True
class PICTURE_MODE_STATE(Enum):
DYNAMIC = 0x00
STANDARD = 0x01
MOVIE = 0x02
CUSTOM_TV = 0x03
NATURAL = 0x04
CALIBRATION_TV = 0x05
ENTERTAIN = 0x10
INTERNET = 0x11
TEXT = 0x12
CUSTOM = 0x13
ADVERTISEMENT = 0x14
INFORMATION = 0x15
CALIBRATION = 0x16
SHOP_MALL_VIDEO = 0x20
SHOP_MALL_TEXT = 0x21
OFFICE_SCHOOL_VIDEO = 0x22
OFFICE_SCHOOL_TEXT = 0x23
TERMINAL_STATION_VIDEO = 0x24
TERMINAL_STATION_TEXT = 0x25
VIDEO_WALL_VIDEO = 0x26
VIDEO_WALL_TEXT = 0x27
HDR_PLUS = 0x30
OFF = 0x50
RESERVED_OTHER = 0x90
DATA = [PICTURE_MODE_STATE]
class SOUND_MODE(Command):
CMD = 0x72
GET, SET = True, True
class SOUND_MODE_STATE(Enum):
STANDARD = 0x00
MUSIC = 0x01
MOVIE = 0x02
SPEECH = 0x03
CUSTOM = 0x04
AMPLIFY = 0x05
OPTIMIZED = 0x06
DATA = [SOUND_MODE_STATE]
class ALL_KEYS_LOCK(Command):
"""
Turns both REMOCON and Panel Key Lock function on/off.
Note: Can operate regardless of whether power is on/off.
"""
# TODO: REMOCON? Remote Control?
CMD = 0x77
GET, SET = True, True
class LOCK_STATE(Enum):
OFF = 0x00
ON = 0x01
DATA = [LOCK_STATE]
class MODEL_NAME(Command):
CMD = 0x8A
GET, SET = True, False
DATA = [Str('MODEL_NAME')]
class PANEL_ON_TIME(Command):
"""
Get the device panel on total time.
Return value increased every 10 mins. To get hours use "MIN10 / 6".
"""
CMD = 0x83
GET, SET = True, False
DATA = [IntHL('MIN10')]
@classmethod
def parse_response_data(cls, data):
return super().parse_response_data(data)[0]
class ENERGY_SAVING(Command):
CMD = 0x92
GET, SET = True, True
class ENERGY_SAVING_STATE(Enum):
OFF = 0x00
LOW = 0x01
MEDIUM = 0x02
HIGH = 0x03
PICTURE_OFF = 0x04
DATA = [ENERGY_SAVING_STATE]
class RESET(Command):
CMD = 0x9F
GET, SET = False, True
class RESET_TARGET(Enum):
PICTURE = 0x00
SOUND = 0x01
SETUP = 0x02 # (System reset)
ALL = 0x03
SCREEN_DISPLAY = 0x04
DATA = [RESET_TARGET]
class OSD_TYPE(Command):
"""
Turns OSD (On-screen display) specific message types on/off.
"""
CMD = 0xA3
GET, SET = True, True
class OSD_TYPE(Enum):
SOURCE = 0x00
NOT_OPTIMUM_MODE = 0x01
NO_SIGNAL = 0x02
MDC = 0x03
SCHEDULE_CHANNEL = 0x04
DATA = [OSD_TYPE, Bool('OSD_ENABLED')]
@classmethod
def parse_response_data(cls, data):
return parse_enum_bitmask(cls.OSD_TYPE, data[0])
class TIMER_15(Command):
"""
Integrated timer function (15 data-length version).
Note: This depends on product and will not work on older versions.
ON_TIME/OFF_TIME: turn ON/OFF display at specific time of day
ON_ACTIVE/OFF_ACTIVE: if timer is not active, values are ignored,
so there may be only OFF timer, ON timer, or both.
REPEAT: On which day timer is enabled
(combined with HOLIDAY_APPLY and MANUAL_WEEKDAY)
"""
CMD = Int('TIMER_ID', range(1, 8))
_TIMER_ID_CMD = [0xA4, 0xA5, 0xA6, 0xAB, 0xAC, 0xAD, 0xAE]
GET, SET = True, True
class TIMER_REPEAT(Enum):
ONCE = 0x00
EVERYDAY = 0x01
MON_FRI = 0x02
MON_SAT = 0x03
SAT_SUN = 0x04
MANUAL_WEEKDAY = 0x05
class WEEKDAY(Enum):
SUN = 0x00
MON = 0x01
TUE = 0x02
WED = 0x03
THU = 0x04
FRI = 0x05
SAT = 0x06
# ignore_bit_7 = 7
class HOLIDAY_APPLY(Enum):
DONT_APPLY_BOTH = 0x00
APPLY_BOTH = 0x01
ON_TIMER_ONLY_APPLY = 0x02
OFF_TIMER_ONLY_APPLY = 0x03
DATA = [
Time12H('ON_TIME'),
Bool('ON_ENABLED'),
Time12H('OFF_TIME'),
Bool('OFF_ENABLED'),
EnumField(TIMER_REPEAT, 'ON_REPEAT'),
Bitmask(WEEKDAY, 'ON_MANUAL_WEEKDAY'),
EnumField(TIMER_REPEAT, 'OFF_REPEAT'),
Bitmask(WEEKDAY, 'OFF_MANUAL_WEEKDAY'),
VOLUME.VOLUME,
INPUT_SOURCE.INPUT_SOURCE_STATE,
HOLIDAY_APPLY,
]
async def __call__(self, connection, display_id, timer_id, data):
cmd = self._TIMER_ID_CMD[timer_id - 1]
data = self.parse_response(
await connection.send(
cmd, display_id,
self.pack_payload_data(data) if data else []
),
)
return self.parse_response_data(data)
@classmethod
def parse_response_data(cls, data, *args, _timer_version_check=True,
**kwargs):
if _timer_version_check and len(data) == 13:
raise RuntimeError('13 data-length version of timer received, '
'use timer_13 instead')
return super().parse_response_data(data, *args, **kwargs)
@classmethod
def get_order(cls):
return (0xA4, cls.name)
class TIMER_13(TIMER_15):
"""
Integrated timer function (13 data-length version).
Note: This depends on product and will not work on newer versions.
"""
DATA = [
Time12H('ON_TIME'),
Bool('ON_ENABLED'),
Time12H('OFF_TIME'),
Bool('OFF_ENABLED'),
EnumField(TIMER_15.TIMER_REPEAT, 'REPEAT'),
Bitmask(TIMER_15.WEEKDAY, 'MANUAL_WEEKDAY'),
VOLUME.VOLUME,
INPUT_SOURCE.INPUT_SOURCE_STATE,
TIMER_15.HOLIDAY_APPLY,
]
@classmethod
def parse_response_data(cls, data, *args, **kwargs):
if len(data) == 15:
raise RuntimeError('15 data-length version of timer received, '
'use timer_15 instead')
return super().parse_response_data(
data, *args, _timer_version_check=False, **kwargs)
class CLOCK_S(Command):
"""
Current time function (second precision).
Note: This is for models developed after 2013.
For older models see CLOCK_M function (minute precision).
"""
GET, SET = True, True
CMD = 0xC5
DATA = [DateTime()]
class CLOCK_M(CLOCK_S):
"""
Current time function (minute precision).
Note: This is for models developed until 2013.
For newer models see CLOCK_S function (seconds precision).
"""
CMD = 0xA7
DATA = [DateTime(seconds=False)]
class HOLIDAY_SET(Command):
"""
Add/Delete the device holiday schedule with the holiday schedule itself
start month/day and end month/day.
Note: On DELETE_ALL all parameters should be 0x00.
"""
CMD = 0xA8
GET, SET = False, True
class HOLIDAY_MANAGE(Enum):
ADD = 0x00
DELETE = 0x01
DELETE_ALL = 0x02
DATA = [
HOLIDAY_MANAGE,
Int('START_MONTH', range(13)),
Int('START_DAY', range(32)),
Int('END_MONTH', range(13)),
Int('END_DAY', range(32)),
]
class HOLIDAY_GET(Command):
"""
Get the device holiday schedule.
If INDEX is not specified, returns total number of Holiday Information.
"""
CMD = 0xA9
GET, SET = True, True
DATA = [
Int('INDEX'),
]
RESPONSE_EXTRA = [
Int('START_MONTH'),
Int('START_DAY'),
Int('END_MONTH'),
Int('END_DAY'),
]
@classmethod
def parse_response_data(cls, data):
if data[1:] == bytes([0, 0, 0, 0]):
return [int(data[0])]
return super().parse_response_data(data)
class VIRTUAL_REMOTE(Command):
"""
This function support that MDC command can work same as remote control.
Note: In a certain model, 0x79 CONTENT key works as HOME
and 0x1F DISPLAY key works as INFO.
"""
CMD = 0xB0
GET, SET = False, True
class KEY_CODE(Enum):
KEY_SOURCE = 0x01
KEY_POWER = 0x02
KEY_1 = 0x04
KEY_2 = 0x05
KEY_3 = 0x06
KEY_VOLUME_UP = 0x07
KEY_4 = 0x08
KEY_5 = 0x09
KEY_6 = 0x0A
KEY_VOLUME_DOWN = 0x0B
KEY_7 = 0x0C
KEY_8 = 0x0D
KEY_9 = 0x0E
KEY_MUTE = 0x0F
KEY_CHANNEL_DOWN = 0x10
KEY_0 = 0x11