Skip to content

Fix MQTT binary switch #18389

Merged
amelchio merged 1 commit intohome-assistant:devfrom
dgomes:off_delay_cancel
Nov 12, 2018
Merged

Fix MQTT binary switch #18389
amelchio merged 1 commit intohome-assistant:devfrom
dgomes:off_delay_cancel

Conversation

@dgomes
Copy link
Copy Markdown
Contributor

@dgomes dgomes commented Nov 12, 2018

Description:

I was getting this in my log files:

2018-11-12 00:21:26 WARNING (MainThread) [homeassistant.core] Unable to remove unknown listener <function async_track_point_in_utc_time.<locals>.point_in_time_listener at 0x102948378>

After some analysis I reached binary_sensor/mqtt line 157 where an async callback was supposed to be called in order to cancel an evt.async_call_later.

The proper fix would have been to await for self._delay_listener() but we are outside async function.

This patch fixes the warning, but I'm not sure if it is the right approach 😞

Related issue (if applicable): fixes #

Pull request in home-assistant.io with documentation (if applicable): home-assistant/home-assistant.io#<home-assistant.io PR number goes here>

Example entry for configuration.yaml (if applicable):

binary_sensor:
  - platform: mqtt
    state_topic: "test/1"
    payload_on: 1
    payload_off: 0
    name: test_mqtt_delay_off
    device_class: motion
    off_delay: 5
mosquitto_pub -h 192.168.1.100 -t test/1 -m 1 && mosquitto_pub -h 192.168.1.100 -t test/1 -m 0

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New or updated dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.

@ghost ghost assigned dgomes Nov 12, 2018
@ghost ghost added the in progress label Nov 12, 2018
@amelchio amelchio added this to the 0.82.1 milestone Nov 12, 2018
@amelchio
Copy link
Copy Markdown
Contributor

That looks right, the await sounds wrong :)

@amelchio amelchio merged commit 0ab81b0 into home-assistant:dev Nov 12, 2018
@ghost ghost removed the in progress label Nov 12, 2018
@dgomes
Copy link
Copy Markdown
Contributor Author

dgomes commented Nov 12, 2018

but setting the callback to None was part of the callback. 🤷‍♂️

It does work 😄 Tks!

@amelchio
Copy link
Copy Markdown
Contributor

It sounds like you are mixing up self._delay_listener() and self.off_delay_listener(). The latter is not called when you manually call the former.

balloob pushed a commit that referenced this pull request Nov 15, 2018
@balloob balloob mentioned this pull request Nov 15, 2018
@dgomes dgomes deleted the off_delay_cancel branch April 7, 2022 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants