Python LimitlessLED via RF

Diff
Login

Diff

Differences From Artifact [5f657e4ec6]:

To Artifact [a379ee4165]:


1
2
3
4
5
6
7
8
9
10
11
12

13
14
15
16
17
18
19
1
2
3
4
5
6
7
8
9
10
11

12
13
14
15
16
17
18
19











-
+







#! /usr/bin/env python3

import random
import time

class Remote:
	_remote_type_alias_map = {
		'fut089': 'rgb+cct'
	}
	_remote_type_parameters_map = {
		'rgbw': {
			'retries':  10,
			'retries':  5,
			'delay':    0.05,
			'channels': [9, 40, 71],
			'syncword': [0x258B, 0x147A],
			'features': [
				'can_set_brightness',
				'has_brightness',
				'has_white',
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
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







-
+











-
+

-
+








		# Determine zone, default to all
		zone = button_info.get('zone', 0)

		# Some buttons need to be converted to zones
		button_name = button_info['button']
		if button_name in ['zone_on', 'zone_off', 'zone_max', 'zone_night']:
			button_name = button_name + ':' + str(zone)
			button_name = "{}:{}".format(button_name, zone)

		# Look up the button
		button_id = self._config['button_map'][button_name]

		# Compute message body
		body = [zone, button_id, message_id]

		# Compute the whole message so far
		message = header + body

		# Compute message trailer
		## Include a CRC, for good measure ?
		## Include a CRC, for good measure
		crc = len(message) + 1
		for byte in header + body:
		for byte in message:
			crc = crc + byte
		crc = crc & 0xff
		trailer = [crc]

		message = message + trailer

		return message
373
374
375
376
377
378
379

380
381
382
383
384
385
386
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387







+







	def _get_next_message_id(self):
		# Determine next message ID
		self._message_id = (self._message_id + 1) & 0xff
		return self._message_id

	def _send_button(self, button_info):
		# Include the remote ID unless one was supplied
		button_info = button_info.copy()
		if 'remote_id' not in button_info:
			button_info['remote_id'] = self._id

			# Get the next message ID for this remote
			if 'message_id' not in button_info:
				message_id = self._get_next_message_id()
				button_info['message_id'] = message_id
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
468
469
470
471
472
473
474

475
476
477

478
479
480
481
482
483
484







-



-







		for step in range(final_steps):
			self._debug("[FINAL] Stepping {} {}".format(button_prefix, final_direction))
			self._send_button(step_command)

		return True

	def _step_brightness(self, brightness, brightness_min, brightness_max, zone = None):
		self.on(zone)
		return self._step_value(brightness, brightness_min, brightness_max, 'brightness', zone)

	def _step_temperature(self, temperature, temperature_min, temperature_max, zone = None):
		self.on(zone)
		return self._step_value(temperature, temperature_min, temperature_max, 'temperature', zone)

	def _max_brightness(self, zone = None):
		if zone is None:
			message = {'button': 'max'}
		else:
			message = {