Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFLink refactor bug with 'wait_for_ack: false' #17875

Closed
javicalle opened this issue Oct 27, 2018 · 1 comment · Fixed by #17889
Closed

RFLink refactor bug with 'wait_for_ack: false' #17875

javicalle opened this issue Oct 27, 2018 · 1 comment · Fixed by #17889

Comments

@javicalle
Copy link
Contributor

Home Assistant release with the issue:

v0.81.0

Last working Home Assistant release (if known):
v0.80.3 (before RFLink refactor)

Operating environment (Hass.io/Docker/Windows/etc.):

HASSIO 1.4.0

Component/platform:

RFLink platform (detected in switch and cover components)

Description of problem:
After the RFLink platform refactor (my thanks to @emontnemery and @MartinHjelmare for the effort) my logs are showing a error trace every time I run an HA command:

2018-10-27 15:32:44 DEBUG (MainThread) [homeassistant.components.rflink] Sending command: on to Rflink device: eurodomest_0c66f3_01
2018-10-27 15:32:44 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
AttributeError: 'NoneType' object has no attribute 'send'
.../...
2018-10-27 16:04:58 DEBUG (MainThread) [homeassistant.components.cover.rflink] set_position :: command open_cover
2018-10-27 16:04:58 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
AttributeError: 'NoneType' object has no attribute 'send'

It seems that all commands are running fine with no problem, but some kind of exception is arrising.

After some research I have found that problem it's related with the rflink config attribute 'wait_for_ack: false' and '_async_send_command' method (components/rflink.py).

Also I have benn researching the code, but my knowledge can't deal with it.

Before refactor (only relevant part):

    async def _async_send_command(self, cmd, repetitions):
        .../...
        else:
            # Puts command on outgoing buffer and returns straight away.
            # Rflink protocol/transport handles asynchronous writing of buffer
            # to serial/tcp device. Does not wait for command send
            # confirmation.
            self.hass.async_add_job(ft.partial(
                self._protocol.send_command, self._device_id, cmd))
        .../...

After:

    async def _async_send_command(self, cmd, repetitions):
        .../...
        else:
            # Puts command on outgoing buffer and returns straight away.
            # Rflink protocol/transport handles asynchronous writing of buffer
            # to serial/tcp device. Does not wait for command send
            # confirmation.
            self.hass.async_create_task(self._protocol.send_command(
                self._device_id, cmd))
        .../...

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

rflink:
  port: /dev/ttyUSB0
  wait_for_ack: false

Traceback (if applicable):


Additional information:

@MartinHjelmare
Copy link
Member

We should not create a task but just call the self._protocol.send_command method. It's a callback.

emontnemery added a commit to emontnemery/home-assistant that referenced this issue Oct 27, 2018
@ghost ghost added the in progress label Oct 27, 2018
@ghost ghost removed the in progress label Oct 28, 2018
MartinHjelmare pushed a commit that referenced this issue Oct 28, 2018
@balloob balloob mentioned this issue Nov 9, 2018
@home-assistant home-assistant locked and limited conversation to collaborators Feb 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants