|
@@ -32,8 +32,9 @@ class powerplug(base):
|
32
|
32
|
#
|
33
|
33
|
RX_KEYS = [KEY_OUTPUT_0, KEY_OUTPUT_1, KEY_OUTPUT_2, KEY_OUTPUT_3]
|
34
|
34
|
|
35
|
|
- def __init__(self, mqtt_client, topic):
|
36
|
|
- super().__init__(mqtt_client, topic)
|
|
35
|
+ def __state_logging__(self, inst, key, data):
|
|
36
|
+ if key in self.KEY_OUTPUT_LIST:
|
|
37
|
+ self.logger.info("State change of '%s' to '%s'", key, repr(data))
|
37
|
38
|
|
38
|
39
|
#
|
39
|
40
|
# RX
|
|
@@ -72,11 +73,9 @@ class powerplug(base):
|
72
|
73
|
self.send_command(self.KEY_OUTPUT_0, state)
|
73
|
74
|
|
74
|
75
|
def set_output_0_mcb(self, device, key, data):
|
75
|
|
- self.logger.log(logging.INFO if data != self.output_0 else logging.DEBUG, "Changing output 0 to %s", str(data))
|
76
|
76
|
self.set_output_0(data)
|
77
|
77
|
|
78
|
78
|
def toggle_output_0_mcb(self, device, key, data):
|
79
|
|
- self.logger.info("Toggeling output 0")
|
80
|
79
|
self.set_output_0(not self.output_0)
|
81
|
80
|
|
82
|
81
|
def set_output_1(self, state):
|
|
@@ -84,11 +83,9 @@ class powerplug(base):
|
84
|
83
|
self.send_command(self.KEY_OUTPUT_1, state)
|
85
|
84
|
|
86
|
85
|
def set_output_1_mcb(self, device, key, data):
|
87
|
|
- self.logger.log(logging.INFO if data != self.output_1 else logging.DEBUG, "Changing output 1 to %s", str(data))
|
88
|
86
|
self.set_output_1(data)
|
89
|
87
|
|
90
|
88
|
def toggle_output_1_mcb(self, device, key, data):
|
91
|
|
- self.logger.info("Toggeling output 1")
|
92
|
89
|
self.set_output_1(not self.output_1)
|
93
|
90
|
|
94
|
91
|
def set_output_2(self, state):
|
|
@@ -96,11 +93,9 @@ class powerplug(base):
|
96
|
93
|
self.send_command(self.KEY_OUTPUT_2, state)
|
97
|
94
|
|
98
|
95
|
def set_output_2_mcb(self, device, key, data):
|
99
|
|
- self.logger.log(logging.INFO if data != self.output_2 else logging.DEBUG, "Changing output 2 to %s", str(data))
|
100
|
96
|
self.set_output_2(data)
|
101
|
97
|
|
102
|
98
|
def toggle_output_2_mcb(self, device, key, data):
|
103
|
|
- self.logger.info("Toggeling output 2")
|
104
|
99
|
self.set_output_2(not self.output_2)
|
105
|
100
|
|
106
|
101
|
def set_output_3(self, state):
|
|
@@ -108,11 +103,9 @@ class powerplug(base):
|
108
|
103
|
self.send_command(self.KEY_OUTPUT_3, state)
|
109
|
104
|
|
110
|
105
|
def set_output_3_mcb(self, device, key, data):
|
111
|
|
- self.logger.log(logging.INFO if data != self.output_3 else logging.DEBUG, "Changing output 3 to %s", str(data))
|
112
|
106
|
self.set_output_3(data)
|
113
|
107
|
|
114
|
108
|
def toggle_output_3_mcb(self, device, key, data):
|
115
|
|
- self.logger.info("Toggeling output 3")
|
116
|
109
|
self.set_output_3(not self.output_3)
|
117
|
110
|
|
118
|
111
|
def set_output_all(self, state):
|
|
@@ -120,7 +113,6 @@ class powerplug(base):
|
120
|
113
|
self.send_command(self.KEY_OUTPUT_ALL, state)
|
121
|
114
|
|
122
|
115
|
def set_output_all_mcb(self, device, key, data):
|
123
|
|
- self.logger.info("Changing all outputs to %s", str(data))
|
124
|
116
|
self.set_output_all(data)
|
125
|
117
|
|
126
|
118
|
def all_off(self):
|
|
@@ -191,27 +183,37 @@ class remote(base):
|
191
|
183
|
#
|
192
|
184
|
RX_IGNORE_TOPICS = [KEY_CD, KEY_LINE1, KEY_LINE3, KEY_MUTE, KEY_POWER, KEY_VOLUP, KEY_VOLDOWN]
|
193
|
185
|
|
|
186
|
+ def __state_logging__(self, inst, key, data):
|
|
187
|
+ pass # This is just a TX device using self.set_*
|
|
188
|
+
|
194
|
189
|
def set_cd(self, device=None, key=None, data=None):
|
|
190
|
+ self.logger.info("Changing amplifier source to CD")
|
195
|
191
|
self.send_command(self.KEY_CD, None)
|
196
|
192
|
|
197
|
193
|
def set_line1(self, device=None, key=None, data=None):
|
|
194
|
+ self.logger.info("Changing amplifier source to LINE1")
|
198
|
195
|
self.send_command(self.KEY_LINE1, None)
|
199
|
196
|
|
200
|
197
|
def set_line3(self, device=None, key=None, data=None):
|
|
198
|
+ self.logger.info("Changing amplifier source to LINE3")
|
201
|
199
|
self.send_command(self.KEY_LINE3, None)
|
202
|
200
|
|
203
|
201
|
def set_mute(self, device=None, key=None, data=None):
|
|
202
|
+ self.logger.info("Muting / Unmuting amplifier")
|
204
|
203
|
self.send_command(self.KEY_MUTE, None)
|
205
|
204
|
|
206
|
205
|
def set_power(self, device=None, key=None, data=None):
|
|
206
|
+ self.logger.info("Power on/off amplifier")
|
207
|
207
|
self.send_command(self.KEY_POWER, None)
|
208
|
208
|
|
209
|
209
|
def set_volume_up(self, data=False):
|
210
|
210
|
"""data: [True, False]"""
|
|
211
|
+ self.logger.info("Increasing amplifier volume")
|
211
|
212
|
self.send_command(self.KEY_VOLUP, data)
|
212
|
213
|
|
213
|
214
|
def set_volume_down(self, data=False):
|
214
|
215
|
"""data: [True, False]"""
|
|
216
|
+ self.logger.info("Decreasing amplifier volume")
|
215
|
217
|
self.send_command(self.KEY_VOLDOWN, data)
|
216
|
218
|
|
217
|
219
|
def default_inc(self, device=None, key=None, data=None):
|
|
@@ -238,10 +240,13 @@ class audio_status(base):
|
238
|
240
|
#
|
239
|
241
|
RX_KEYS = [KEY_STATE, KEY_TITLE]
|
240
|
242
|
|
|
243
|
+ def __state_logging__(self, inst, key, data):
|
|
244
|
+ if key in [self.KEY_STATE, self.KEY_TITLE]:
|
|
245
|
+ self.logger.info("State change of '%s' to '%s'", key, repr(data))
|
|
246
|
+
|
241
|
247
|
def set_state(self, num, data):
|
242
|
248
|
"""data: [True, False]"""
|
243
|
249
|
self.send_command(self.KEY_STATE + "/" + str(num), data)
|
244
|
250
|
|
245
|
251
|
def set_state_mcb(self, device, key, data):
|
246
|
|
- self.logger.info("Changing state to %s", str(data))
|
247
|
252
|
self.set_state(data)
|