RFLink gateway on HASS.io on a NUC (solved)

I would like to get an RFLink gateway working with HASS running on a NUC (a Gigabyte Brix GB-BXBT-1900) and Ubuntu server. I can muddle my way through getting HASS running but am stumped about how to get the RFLink working so would appreciate any pointers, please.

I have built and loaded the firmware onto the Arduino Mega and tested it using RFLinkLoader.

When I connect it to the NUC running HASS nothing seems to happen so I’m unsure how to make it work or even debug the problem.

Thanks.

Richard

I should have added that I’ve followed this page https://www.home-assistant.io/components/rflink/ but it still appeared to not see the RFLink board.

Alternatively, can anyone recommend the approach using an ESP8266 and esp-link?

I’m using this on a RPI3/hass.io config for the moment. I’ll move to NUC soon.

What is your config on the NUC? hass.io, ubuntu, …

What did you set in configuration.yaml? Mine is:

rflink:
  port: /dev/ttyACM0

switch:
  - platform: rflink
    device_defaults:
      fire_event: true
      signal_repetitions: 2

sensor:
  - platform: rflink
    automatic_add: true

light:
  - platform: rflink
    automatic_add: true

i have got nearly the same configuration. My config looks like this:

rflink:
  port: /dev/ttyUSB0

I think you must ssh to the console on your host to determine the right usb-port. Or perhaps this page shows the available serial ports
http://yourhassip:8123/hassio/system click on the hardware button.

a while ago i made this to translate rflink to mqtt GitHub - lubeda/RFLink-to-FHEM-via-MQTT but this only translates the serialdata to mqtt it is no high level integration.

Thanks, Adorem - I’ll compare that to mine but in the mean time, I built the NUC using this guide https://gist.github.com/frenck/32b4f74919ca6b95b30c66f85976ec58 It was easy to follow and worked, even for me.

Thanks, @lubeda - I had not even realised that screen was there so I ran it once, then connected the RFLink and ran it again. Compared the output and /dev/ttyACM0 had appeared (which is the same as @Adorem listed above) so it seems I’m on the right track. I added that to the configuration.yaml, as well as the entries @Adorem used.

Restarted HASS but can’t see any indications it has connected - or errors in the logs.

Run out of time tonight so will continue tomorrow.

Well, tomorrow became next week but I have got back to it!

The HASS NUC now seems to at least recognise that there is a RFLink attached - it has this in the error log. I’ve no idea currently what it means and how to fix it, though, so that is my next challenge! :wink:

Log Details (ERROR)
Thu Jun 20 2019 22:03:01 GMT+0100 (British Summer Time)
Error doing job: Exception in callback <bound method SerialTransport._read_ready of SerialTransport(<uvloop.Loop running=True closed=False debug=False>, <rflink.protocol.RflinkProtocol object at 0x7f76dbb00eb8>, Serial<id=0x7f76dbb0c048, open=True>(port='/dev/ttyACM0', baudrate=57600, bytesize=8, parity='N', stopbits=1, timeout=0, xonxoff=False, rtscts=False, dsrdtr=False))>
Traceback (most recent call last):
  File "uvloop/cbhandles.pyx", line 66, in uvloop.loop.Handle._run
  File "/usr/local/lib/python3.7/site-packages/serial_asyncio/__init__.py", line 106, in _read_ready
    self._protocol.data_received(data)
  File "/usr/local/lib/python3.7/site-packages/rflink/protocol.py", line 46, in data_received
    data = data.decode()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x98 in position 2: invalid start byte

And Logviewer is reporting this so it looks like python issue but I’m now totally out of my depth!

  File "/usr/local/lib/python3.7/site-packages/serial_asyncio/__init__.py", line 106, in _read_ready
    self._protocol.data_received(data)
  File "/usr/local/lib/python3.7/site-packages/rflink/protocol.py", line 46, in data_received
    data = data.decode()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte
2019-06-20 22:37:09 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback <bound method SerialTransport._read_ready of SerialTransport(<uvloop.Loop running=True closed=False debug=False>, <rflink.protocol.RflinkProtocol object at 0x7f7db5840d68>, Serial<id=0x7f7db5840cc0, open=True>(port='/dev/ttyACM0', baudrate=57600, bytesize=8, parity='N', stopbits=1, timeout=0, xonxoff=False, rtscts=False, dsrdtr=False))>
Traceback (most recent call last):
  File "uvloop/cbhandles.pyx", line 66, in uvloop.loop.Handle._run
  File "/usr/local/lib/python3.7/site-packages/serial_asyncio/__init__.py", line 106, in _read_ready
    self._protocol.data_received(data)
  File "/usr/local/lib/python3.7/site-packages/rflink/protocol.py", line 46, in data_received
    data = data.decode()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x98 in position 2: invalid start byte
Traceback (most recent call last):
  File "uvloop/cbhandles.pyx", line 66, in uvloop.loop.Handle._run
  File "/usr/local/lib/python3.7/site-packages/serial_asyncio/__init__.py", line 106, in _read_ready
    self._protocol.data_received(data)
  File "/usr/local/lib/python3.7/site-packages/rflink/protocol.py", line 46, in data_received
    data = data.decode()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x98 in position 5: invalid start byte
Traceback (most recent call last):
  File "uvloop/cbhandles.pyx", line 66, in uvloop.loop.Handle._run
  File "/usr/local/lib/python3.7/site-packages/serial_asyncio/__init__.py", line 106, in _read_ready
    self._protocol.data_received(data)
  File "/usr/local/lib/python3.7/site-packages/rflink/protocol.py", line 46, in data_received
    data = data.decode()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x98 in position 0: invalid start byte
Traceback (most recent call last):
  File "uvloop/cbhandles.pyx", line 66, in uvloop.loop.Handle._run
  File "/usr/local/lib/python3.7/site-packages/serial_asyncio/__init__.py", line 106, in _read_ready
    self._protocol.data_received(data)
  File "/usr/local/lib/python3.7/site-packages/rflink/protocol.py", line 46, in data_received
    data = data.decode()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x98 in position 1: invalid start byte

But I know Hass is seeing the signals from RFlink - pushing the Somfy remote button gives the following in logviewer:

2019-06-20 22:41:11 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback <bound method SerialTransport._read_ready of SerialTransport(<uvloop.Loop running=True closed=False debug=False>, <rflink.protocol.RflinkProtocol object at 0x7f7db5840d68>, Serial<id=0x7f7db5840cc0, open=True>(port='/dev/ttyACM0', baudrate=57600, bytesize=8, parity='N', stopbits=1, timeout=0, xonxoff=False, rtscts=False, dsrdtr=False))>
Traceback (most recent call last):
  File "uvloop/cbhandles.pyx", line 66, in uvloop.loop.Handle._run
  File "/usr/local/lib/python3.7/site-packages/serial_asyncio/__init__.py", line 106, in _read_ready
    self._protocol.data_received(data)
  File "/usr/local/lib/python3.7/site-packages/rflink/protocol.py", line 46, in data_received
    data = data.decode()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x98 in position 2: invalid start byte
Traceback (most recent call last):
  File "uvloop/cbhandles.pyx", line 66, in uvloop.loop.Handle._run
  File "/usr/local/lib/python3.7/site-packages/serial_asyncio/__init__.py", line 106, in _read_ready
    self._protocol.data_received(data)
  File "/usr/local/lib/python3.7/site-packages/rflink/protocol.py", line 46, in data_received
    data = data.decode()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe6 in position 1: invalid continuation byte
Traceback (most recent call last):
  File "uvloop/cbhandles.pyx", line 66, in uvloop.loop.Handle._run
  File "/usr/local/lib/python3.7/site-packages/serial_asyncio/__init__.py", line 106, in _read_ready
    self._protocol.data_received(data)
  File "/usr/local/lib/python3.7/site-packages/rflink/protocol.py", line 46, in data_received
    data = data.decode()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 3: invalid start byte
Traceback (most recent call last):
  File "uvloop/cbhandles.pyx", line 66, in uvloop.loop.Handle._run
  File "/usr/local/lib/python3.7/site-packages/serial_asyncio/__init__.py", line 106, in _read_ready
    self._protocol.data_received(data)
  File "/usr/local/lib/python3.7/site-packages/rflink/protocol.py", line 46, in data_received
    data = data.decode()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x86 in position 0: invalid start byte

I think that your problem is related with:

Thank you, @javicalle - that looks like the problem.

I have ordered an ESP expansion board that should allow me to connect via WiFi to get around this issue. I will report back. Thanks again.

OK, well the ESP expansion board worked but was flaky and kept failing to work. I’m not entirely sure what the issue was but it was primarily dropping off the WiFi and then HA could not find it.

I decided to try a different approach after finding this post about the problem and a possible solution.

I configured a Raspberry Pi as the gateway, using LAN (not WiFi) as this is always preferable to me.

It now seems rock solid and I’ll be using the unused CPU cycles on the Pi to do proximity detection etc. so I’m happy and can recommend this option.

Has anyone managed to have a slave instance of hassio run the RFlink? As its now broken on my NUC I wanted to connect via TCP to a slave Pi running hassio+RFLink but can’t get it to work. If anyone could share their experience/config that would be great

@mathewtaylor2007 my post above is exactly that - it works just fine. The links I used are in the post - I just followed those.

Thanks Richard, but I need to do it with hass.io being the O/S on the pi as I have other sensors I want to use. Will it work with that too? Thanks!

Ah, I misunderstood, sorry. No idea - I’m no expert on this. I experimented with serial2net before getting to my final solution - that may be an option possibly?

1 Like

Yeh thanks I might have to try this if I can’t get it to work, last night I tried reconfiguring my rflink on my NUC and it went into a crazy loop, filing the log with thousands of lines of errors and bringing down hassio, and everything else on the NUC for many hours. nightmare!

Check my bugreport above for a possible solution