Python LimitlessLED via RF

Diff
Login

Diff

Differences From Artifact [f3be2e4306]:

To Artifact [79e827bccc]:


48
49
50
51
52
53
54
55
56


57
58
59
60
61
62
63
48
49
50
51
52
53
54


55
56
57
58
59
60
61
62
63







-
-
+
+







				'speed_down': 0x0C,
				'change_color_mode': 0x0D,
				'zone_set_brightness': 0x0E,
				'zone_set_color':  0x0F
			}
		},
		'cct': {
			'retries':  10,
			'delay':    0.2,
			'retries':  3,
			'delay':    0.11,
			'channels': [4, 39, 74],
			'syncword': [0x55AA, 0x050A],
			'brightness_range': [0, 9],
			'temperature_output_range': [0, 9],
			'temperature_input_range':  [6500, 3000],
			'zones': [1, 2, 3, 4],
			'features': [
91
92
93
94
95
96
97
98

99
100
101
102
103
104
105

106
107
108
109
110
111
112
91
92
93
94
95
96
97

98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113







-
+







+







				'brightness_up':    0x0C,
				'brightness_down':  0x04,
				'temperature_up':   0x0E,
				'temperature_down': 0x0F
			}
		},
		'lyh_cct': {
			'retries':  50,
			'retries':  70,
			'delay':    0.2,
			'channels': [24],
			'syncword': [0x6F67, 0xA118],
			'message_length': 13,
			'format_config': {
				'crc_enabled': 0,
				'packet_length_encoded': 0,
				'auto_ack': 1,
				'auto_term_tx': 0
			},
			'brightness_range': [0, 9],
			'temperature_output_range': [0, 9],
			'temperature_input_range':  [6500, 3000],
			'zones': [1, 2, 3],
			'features': [
551
552
553
554
555
556
557
558

559
560
561

562

563
564
565
566
567
568
569
552
553
554
555
556
557
558

559
560
561
562
563

564
565
566
567
568
569
570
571







-
+



+
-
+







				'zone': zone
			}

		message['brightness'] = brightness

		return self._send_button(message)

	def _step_value(self, target_value, target_range_min, target_range_max, button_prefix, zone):
	def _step_value(self, target_value, target_range_min, target_range_max, button_prefix, zone, midpoint = None):
		# Step all the way to the nearest extreme before moving it to
		# where it should be
		target_range = target_range_max - target_range_min + 1
		if midpoint is None:
		midpoint = (target_range / 2) + target_range_min
			midpoint = (target_range / 2) + target_range_min

		# Move to the "initial" value where we force the value
		# to the extreme, then move it to its final value
		initial_steps = target_range
		if target_value < midpoint:
			initial_direction = 'down'
			final_direction = 'up'
604
605
606
607
608
609
610






611

612
613
614
615
616
617
618
606
607
608
609
610
611
612
613
614
615
616
617
618

619
620
621
622
623
624
625
626







+
+
+
+
+
+
-
+







		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):
		# For setting the brightness, set a change-overpoint at around
		# 75%, where below this value we will go to the dimmest and
		# step up and above this point it will go to the brightest
		# and step down.  This is to avoid getting bright then dimming
		# which is much more jarring than getting dim and brightening.
		brightness_changeover = ((brightness_max - brightness_min) * 0.75) + brightness_min;
		return self._step_value(brightness, brightness_min, brightness_max, 'brightness', zone)
		return self._step_value(brightness, brightness_min, brightness_max, 'brightness', zone, midpoint = brightness_changeover)

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

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