home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.6k stars 30.76k forks source link

RFLink: Autoadd not working and getting wierd UnicodeEncodeError #7179

Closed JohanLeirnes closed 7 years ago

JohanLeirnes commented 7 years ago

Make sure you are running the latest version of Home Assistant before reporting an issue.

You should only file an issue if you found a bug. Feature and enhancement requests should go in the Feature Requests section of our community forum:

Home Assistant release (hass --version): 0.42.4

Python release (python3 --version): Python 3.6.1

Component/platform: RFlink/HASS running on Imac with macOS Sierra

Description of problem:

Getting errors on some sensors, and the auto add function does not work.

Expected:

Problem-relevant configuration.yaml entries and steps to reproduce:

rflink:
  port: /dev/tty.usbmodemFA131

Connect RFLink device (homemade Arduino Mega 2560 with FS1000A) to Imac Add RFLink settings to configuration.yaml Check log

Traceback (if applicable):

17-04-19 14:50:22 DEBUG (MainThread) [rflink.protocol] received data: 2
17-04-19 14:50:22 DEBUG (MainThread) [rflink.protocol] received data: 0;04;Xiron;ID=2D01;TEMP=
17-04-19 14:50:22 DEBUG (MainThread) [rflink.protocol] received data: 0066;HUM=19;BAT=OK;
17-04-19 14:50:22 DEBUG (MainThread) [rflink.protocol] got packet: 20;04;Xiron;ID=2D01;TEMP=0066;HUM=19;BAT=OK;
17-04-19 14:50:22 DEBUG (MainThread) [homeassistant.components.rflink] device_id not known, adding new device
17-04-19 14:50:22 DEBUG (MainThread) [rflink.protocol] got event: {'id': 'xiron_2d01_hum', 'sensor': 'humidity', 'value': 19, 'unit': '%'}
17-04-19 14:50:22 DEBUG (MainThread) [homeassistant.components.rflink] event of type sensor: {'id': 'xiron_2d01_hum', 'sensor': 'humidity', 'value': 19, 'unit': '%'}
17-04-19 14:50:22 DEBUG (MainThread) [homeassistant.components.rflink] device_id not known, adding new device
17-04-19 14:50:22 DEBUG (MainThread) [rflink.protocol] got event: {'id': 'xiron_2d01_bat', 'sensor': 'battery', 'value': 'ok', 'unit': None}
17-04-19 14:50:22 DEBUG (MainThread) [homeassistant.components.rflink] event of type sensor: {'id': 'xiron_2d01_bat', 'sensor': 'battery', 'value': 'ok', 'unit': None}
17-04-19 14:50:22 DEBUG (MainThread) [homeassistant.components.rflink] device_id not known, adding new device
17-04-19 14:50:22 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback SerialTransport._read_ready()
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/events.py", line 127, in _run
    self._callback(*self._args)
  File "/Users/h-server/.homeassistant/deps/serial_asyncio/__init__.py", line 106, in _read_ready
    self._protocol.data_received(data)
  File "/Users/h-server/.homeassistant/deps/rflink/protocol.py", line 49, in data_received
    self.handle_lines()
  File "/Users/h-server/.homeassistant/deps/rflink/protocol.py", line 56, in handle_lines
    self.handle_raw_packet(line)
  File "/Users/h-server/.homeassistant/deps/rflink/protocol.py", line 111, in handle_raw_packet
    self.handle_packet(packet)
  File "/Users/h-server/.homeassistant/deps/rflink/protocol.py", line 234, in handle_packet
    super().handle_packet(packet)
  File "/Users/h-server/.homeassistant/deps/rflink/protocol.py", line 121, in handle_packet
    print('packet', packet)
UnicodeEncodeError: 'ascii' codec can't encode character '\xb0' in position 97: ordinal not in range(128)

Additional info:

aequitas commented 7 years ago

Maybe it is due to the baudrate or other serial settings being slightly off causing invalid data. Could you try using the python-rflink library directly to see if the same error occurs?

For the problem of devices not being added. From the logging I can see new devices are recognized. Maybe the error causes them to not be added as the task is broken? Otherwise could you reduce the config to the minimum required to run Rflink, test it and post the complete config and results?

aequitas commented 7 years ago

I found a small bug because of this (https://github.com/home-assistant/home-assistant/pull/7492). The change might not solve your problem at the core but at least it should prevent the code which caused the exception to be called.

If you copy this (https://raw.githubusercontent.com/aequitas/home-assistant/56c0a45a658ac441ee56224515dad10518148575/homeassistant/components/rflink.py) file into your custom_components you should be able to test it.

MacDennis76 commented 7 years ago

@aequitas I also noticed a lot of UnicodeEncodeError recently. I can confirm that the new rflink.py file works. No errors anymore.

Will the fix be part of the next HASS release?

aequitas commented 7 years ago

It has been accepted into the dev branch so I expect it will be in the next release.

balloobbot commented 7 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.

Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment :+1:

balloobbot commented 7 years ago

This issue will be auto-closed because there hasn't been any activity for a few months. Feel free to open a new one if you still experience this problem 👍