Overview
Comment: | Implemented pair/unpair |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
79fb8a5f2220d25bbf91768a9e2ae097 |
User & Date: | rkeene on 2020-04-28 17:31:07 |
Other Links: | manifest | tags |
Context
2020-04-28
| ||
17:38 | Improved speed and moved unimplemented types out of the main map check-in: f43fef83ae user: rkeene tags: trunk | |
17:31 | Implemented pair/unpair check-in: 79fb8a5f22 user: rkeene tags: trunk | |
16:58 | Ensure on/off are delivered check-in: 1b6d5a2023 user: rkeene tags: trunk | |
Changes
Modified __init__.py from [c1c96d59b0] to [c5fd7efe42].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | + + | #! /usr/bin/env python3 import random import time class remote: _remote_type_alias_map = { 'fut089': 'rgb+cct' } _remote_type_parameters_map = { 'rgbw': { 'retries': 5, 'delay': 0.02, 'channels': [9, 40, 71], 'syncword': [0x258B, 0x147A], 'features': [ 'can_set_brightness', 'has_brightness', 'has_white', 'has_color' |
︙ | |||
44 45 46 47 48 49 50 51 52 53 54 55 56 57 | 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | + + | 'speed_down': 0x0C, 'change_color_mode': 0x0D, 'zone_set_brightness': 0x0E, 'set_color': 0x0F } }, 'cct': { 'retries': 10, 'delay': 0.5, 'channels': [4, 39, 74], 'syncword': [0x55AA, 0x050A], 'brightness_range': [0, 9], 'temperature_output_range': [0, 9], 'temperature_input_range': [3000, 9000], 'features': [ 'has_max_brightness', |
︙ | |||
97 98 99 100 101 102 103 | 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | - - - | 'fut020': { 'channels': [6, 41, 76], 'syncword': [0xAA55, 0x50A0] } } def __init__(self, radio, remote_type, remote_id, message_id = None, config = None): |
︙ | |||
148 149 150 151 152 153 154 155 156 157 158 159 160 161 | 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | + + | if 'retries' not in config: config['retries'] = 3 if 'delay' not in config: config['delay'] = 0.1 setattr(self, '_compute_button_message', getattr(self, '_compute_button_message_' + remote_type)) setattr(self, '_parse_button_message', getattr(self, '_parse_button_message_' + remote_type)) setattr(self, 'pair', getattr(self, '_pair_' + remote_type)) setattr(self, 'unpair', getattr(self, '_unpair_' + remote_type)) return config def _compute_button_and_zone_from_button_id(self, button_id): button_info = {} button_info['button'] = 'unknown=' + str(button_id) for button_name, button_value in self._config['button_map'].items(): |
︙ | |||
221 222 223 224 225 226 227 228 229 230 231 232 233 234 | 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 | + + + + + + + + + + + + + + + + + + + | del button_info['zone'] # Map the button ID to a button name button_id = button_message[4] button_info.update(self._compute_button_and_zone_from_button_id(button_id)) return button_info def _pair_cct(self, zone): self._send_button({ 'button': 'zone_on', 'zone': zone }) # Ensure that the "on" button cannot be hit soon after # because it might trigger the unpair flow time.sleep(5) return True def _unpair_cct(self, zone): for retry in range(7): self._send_button({ 'button': 'zone_on', 'zone': zone }) return True def _compute_button_message_rgbw(self, button_info): remote_id = button_info['remote_id'] message_id = button_info['message_id'] # Allow setting brightness for all zones if button_info['button'] == 'set_brightness': |
︙ | |||
307 308 309 310 311 312 313 314 315 316 317 318 319 320 | 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 | + + + + + + + + + + + + + + | # Compute brightness value, there are 26 brightness steps, [16, 0][31, 23] brightness = brightness >> 3 brightness = 31 - ((brightness + 15) % 32) button_info['brightness'] = brightness return button_info def _pair_rgbw(self, zone): self._send_button({ 'button': 'zone_on', 'zone': zone }) return False def _unpair_rgbw(self, zone): self._send_button({ 'button': 'zone_white', 'zone': zone }) return False 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): |
︙ | |||
557 558 559 560 561 562 563 | 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 | - - + + - + + + + + - - + + | message = { 'button': 'zone_on', 'zone': zone } # Increase retries and delay for on/off to ensure # that these important messages are delivered |
︙ | |||
610 611 612 613 614 615 616 | 650 651 652 653 654 655 656 | - - - - - - - - | message = {'button': 'white'} else: message = { 'button': 'zone_white', 'zone': zone } return self._send_button(message) |