Refactor rfxtrx#9117
Conversation
|
@Danielhiversen, thanks for your PR! By analyzing the history of the files in this pull request, we identified @fabaff, @badele and @turbokongen to be potential reviewers. |
pvizeli
left a comment
There was a problem hiding this comment.
We have 2 Options:
- Add the device callback subscription to
async_added_to_hass - Run all device communication (update) on
EVENT_HOMEASSISTANT_START
| @asyncio.coroutine | ||
| def async_added_to_hass(self): | ||
| """Register callbacks.""" | ||
| self._added_to_hass = True |
There was a problem hiding this comment.
Add your device call back subscription on that pleace like sonos
There was a problem hiding this comment.
The device call back subscription is done only once for all the switches (and the same for lights and sensors), and should not be done for each switch.
So do not know how to solve that?
There was a problem hiding this comment.
You can also subscribe that on EVENT_HOMEASSISTANT_START
|
You need work like |
| For more details about this component, please refer to the documentation at | ||
| https://home-assistant.io/components/rfxtrx/ | ||
| """ | ||
| import asyncio |
|
Last point is to remove global and use |
|
By the way #9058 was my first component and I do the same at the moment :) |
| elif command == "stop_roll": | ||
| for _ in range(self.signal_repetitions): | ||
| self._event.device.send_stop(RFXOBJECT.transport) | ||
| self._event.device.send_stop(self.hass.data[RFXOBJECT].transport) |
There was a problem hiding this comment.
line too long (81 > 79 characters)
| elif command == "roll_down": | ||
| for _ in range(self.signal_repetitions): | ||
| self._event.device.send_close(RFXOBJECT.transport) | ||
| self._event.device.send_close(self.hass.data[RFXOBJECT].transport) |
There was a problem hiding this comment.
line too long (82 > 79 characters)
| elif command == "roll_up": | ||
| for _ in range(self.signal_repetitions): | ||
| self._event.device.send_open(RFXOBJECT.transport) | ||
| self._event.device.send_open(self.hass.data[RFXOBJECT].transport) |
There was a problem hiding this comment.
line too long (81 > 79 characters)
| elif command == 'turn_off': | ||
| for _ in range(self.signal_repetitions): | ||
| self._event.device.send_off(RFXOBJECT.transport) | ||
| self._event.device.send_off(self.hass.data[RFXOBJECT].transport) |
There was a problem hiding this comment.
line too long (80 > 79 characters)
| elif command == "dim": | ||
| for _ in range(self.signal_repetitions): | ||
| self._event.device.send_dim(RFXOBJECT.transport, | ||
| self._event.device.send_dim(self.hass.data[RFXOBJECT].transport, |
There was a problem hiding this comment.
line too long (80 > 79 characters)
|
@pvizeli Is this fine now? |
|
Looks good 👍 Small improvment for future. Get the device object from |
* upstream/dev: (113 commits) Fix fitbit error when trying to access token after upgrade. (home-assistant#9183) Upgrade sendgrid to 5.0.1 (home-assistant#9215) Upgrade pyasn1 to 0.3.3 and pyasn1-modules to 0.1.1 (home-assistant#9216) directv: extended discovery via REST api, bug fix (home-assistant#8800) Bayesian Binary Sensor (home-assistant#8810) Add cloud auth support (home-assistant#9208) Abode push events and lock, cover, and switch components (home-assistant#9095) Lint Sonarr tests Upgrade pymysensors to 0.11.1 (home-assistant#9212) Refactor rfxtrx (home-assistant#9117) Issue home-assistant#6893 in rfxtrx (home-assistant#9130) Support for season sensor (home-assistant#8958) Add counter component (home-assistant#9146) Fix and optimize digitalloggers platform (home-assistant#9203) Prevent error when no forecast data was available (home-assistant#9176) Add "status" to Sonarr sensor (home-assistant#9204) fix worldtidesinfo home-assistant#9184 (home-assistant#9201) Update pushbullet.py (home-assistant#9200) Fix dht22 when no data was read initially home-assistant#8976 (home-assistant#9198) Prevent iCloud exceptions in logfile (home-assistant#9179) ...
Description:
@pvizeli : Could you have look at this?
For reference: #6844 (comment)