Python LimitlessLED via RF

Check-in [989cbde578]
Login

Check-in [989cbde578]

Overview
Comment:Further improved delays
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 989cbde57887bb30056fad32c7d8c29f83e03dffcdeba662d1b71884a595755d
User & Date: rkeene on 2020-04-28 18:20:33
Other Links: manifest | tags
Context
2020-04-28
18:46
Added README with limited documentation check-in: c50aa58a64 user: rkeene tags: trunk
18:20
Further improved delays check-in: 989cbde578 user: rkeene tags: trunk
17:38
Improved speed and moved unimplemented types out of the main map check-in: f43fef83ae user: rkeene tags: trunk
Changes

Modified __init__.py from [ee4a04daf8] to [42d9b40b13].

446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
			self._send_button({'button': "{}_{}".format(button_prefix, final_direction)})

		return True

	def _step_brightness(self, brightness, brightness_min, brightness_max, zone = None):
		# Select the appropriate zone before sending the steps
		# to ensure they reach the correct bulbs
		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):
		# Select the appropriate zone before sending the steps
		# to ensure they reach the correct bulbs
		self.on(zone)
		return self._step_value(temperature, temperature_min, temperature_max, 'temperature', zone)

	def _rgb_to_hue(self, r, g, b):
		r = r / 255.0
		g = g / 255.0
		b = b / 255.0








|





|







446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
			self._send_button({'button': "{}_{}".format(button_prefix, final_direction)})

		return True

	def _step_brightness(self, brightness, brightness_min, brightness_max, zone = None):
		# Select the appropriate zone before sending the steps
		# to ensure they reach the correct bulbs
		self.on(zone, try_hard = False)
		return self._step_value(brightness, brightness_min, brightness_max, 'brightness', zone)

	def _step_temperature(self, temperature, temperature_min, temperature_max, zone = None):
		# Select the appropriate zone before sending the steps
		# to ensure they reach the correct bulbs
		self.on(zone, try_hard = False)
		return self._step_value(temperature, temperature_min, temperature_max, 'temperature', zone)

	def _rgb_to_hue(self, r, g, b):
		r = r / 255.0
		g = g / 255.0
		b = b / 255.0

557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
				return False

		# If the bulbs do not support color, nothing needs to be done
		if 'has_color' not in self._config['features']:
			return False

		# Turn on the appropriate zone to select it
		self.on(zone)

		# Press the button
		return self._send_button({'button': 'set_color', 'color': value})

	def set_temperature(self, kelvins, zone = None):
		if 'has_temperature' not in self._config['features']:
			return False







|







557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
				return False

		# If the bulbs do not support color, nothing needs to be done
		if 'has_color' not in self._config['features']:
			return False

		# Turn on the appropriate zone to select it
		self.on(zone, try_hard = False)

		# Press the button
		return self._send_button({'button': 'set_color', 'color': value})

	def set_temperature(self, kelvins, zone = None):
		if 'has_temperature' not in self._config['features']:
			return False
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
		temperature = self._scale_int(kelvins, temperature_input_low, temperature_input_high, temperature_output_low, temperature_output_high)

		if 'can_set_temperature' in self._config['features']:
			return self._set_temperature(temperature, zone)
		else:
			return self._step_temperature(temperature, temperature_output_low, temperature_output_high, zone)

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

		# Increase retries and delay for on/off to ensure
		# that these important messages are delivered

		message['retries'] = self._config['retries'] * 2
		message['delay'] = self._config['delay'] * 2

		return self._send_button(message)

	def off(self, zone = None, dim = True):
		# Dim the bulbs so that when turned on they are not bright
		if dim:
			self.set_brightness(1, zone)

		if zone is None:
			message = {
				'button': 'off',
			}
		else:
			message = {
				'button': 'zone_off',
				'zone': zone
			}

		# Increase retries and delay for on/off to ensure
		# that these important messages are delivered

		message['retries'] = self._config['retries'] * 2
		message['delay'] = self._config['delay'] * 2

		return self._send_button(message)

	def max_brightness(self, zone = None):
		if 'has_max_brightness' not in self._config['features']:
			return self.set_brightness(255, zone)
			







|










>
|
|



|
















>
|
|







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
		temperature = self._scale_int(kelvins, temperature_input_low, temperature_input_high, temperature_output_low, temperature_output_high)

		if 'can_set_temperature' in self._config['features']:
			return self._set_temperature(temperature, zone)
		else:
			return self._step_temperature(temperature, temperature_output_low, temperature_output_high, zone)

	def on(self, zone = None, try_hard = False):
		if zone is None:
			message = {'button': 'on'}
		else:
			message = {
				'button': 'zone_on',
				'zone': zone
			}

		# Increase retries and delay for on/off to ensure
		# that these important messages are delivered
		if try_hard:
			message['retries'] = self._config['retries'] * 2
			message['delay'] = self._config['delay'] * 2

		return self._send_button(message)

	def off(self, zone = None, dim = True, try_hard = False):
		# Dim the bulbs so that when turned on they are not bright
		if dim:
			self.set_brightness(1, zone)

		if zone is None:
			message = {
				'button': 'off',
			}
		else:
			message = {
				'button': 'zone_off',
				'zone': zone
			}

		# Increase retries and delay for on/off to ensure
		# that these important messages are delivered
		if try_hard:
			message['retries'] = self._config['retries'] * 2
			message['delay'] = self._config['delay'] * 2

		return self._send_button(message)

	def max_brightness(self, zone = None):
		if 'has_max_brightness' not in self._config['features']:
			return self.set_brightness(255, zone)