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.67k stars 30.8k forks source link

Parsing error in Rflink #43687

Closed siggy2 closed 3 years ago

siggy2 commented 3 years ago

The problem

The current version of the Rflink integration will not accept devices with the following protocol: mertik_gv60_038527_13

Environment

Home Assistant 0.118.4 rflink 0.54 HA running natively on Raspberry Pi 3

Problem-relevant configuration.yaml


switch:
- platform: rflink
devices:
mertik_gv60_038527_13:
fire_event: true
signal_repetitions: 2
aliases:

Traceback/Error logs

2020-11-16 19:19:16 DEBUG (MainThread) [homeassistant.components.rflink] Sending command: on to Rflink device: mertik_gv60_038527_13 2020-11-16 19:19:16 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.2824163560] Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 135, in handle_call_service await hass.services.async_call( File "/usr/src/homeassistant/homeassistant/core.py", line 1448, in async_call task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1483, in _execute_service await handler.job.target(service_call) File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 204, in handle_service await self.hass.helpers.service.entity_service_call( File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 482, in entity_service_call future.result() # pop exception if have File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 664, in async_request_call await coro File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 519, in _handle_entity_call await result File "/usr/src/homeassistant/homeassistant/components/rflink/init.py", line 561, in async_turn_on await self._async_handle_command("turn_on") File "/usr/src/homeassistant/homeassistant/components/rflink/init.py", line 498, in _async_handle_command await self._async_send_command(cmd, self._signal_repetitions) File "/usr/src/homeassistant/homeassistant/components/rflink/init.py", line 524, in _async_send_command await self._protocol.send_command_ack(self._device_id, cmd) File "/usr/local/lib/python3.8/site-packages/rflink/protocol.py", line 223, in send_command_ack self.send_command(device_id, action) File "/usr/local/lib/python3.8/site-packages/rflink/protocol.py", line 186, in send_command command = deserialize_packet_id(device_id) File "/usr/local/lib/python3.8/site-packages/rflink/parser.py", line 476, in deserialize_packet_id assert len(id_switch) < 3 AssertionError

Additional information

javicalle commented 3 years ago

As soon as I find free time I create the PR.

Greetings.

siggy2 commented 3 years ago

Thanks @javicalle

javicalle commented 3 years ago

@siggy2, if you want to go down through the rabbit hole, this is a good place to start:

Once you get your development environment running, it will be easy to contribute.

Cheers.

javicalle commented 3 years ago

@siggy2 once the PR is merged, it will be included in the next HA version release, around December 13th.

siggy2 commented 3 years ago

That's great. Thanks so much for the support. I'll try to read up on the documentation sent so hopefully can contribute in the future On Nov 28, 2020 1:43 PM, javicalle notifications@github.com wrote: @siggy2 once the PR is merged, it will be included in the next HA version release, around December 13th.

—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or unsubscribe.

siggy2 commented 3 years ago

@javicalle Very excited to have updated HA today. The parsing error seems to have disappeared, however my fireplace is still not responding. I wonder if you can help me still. Here is the log; Note that the first read is from the remote, when I used the off switch. The send command is from me triggering the 'on' command from the button in my HA. Any idea what is wrong?

2020-12-14 20:19:25 DEBUG (MainThread) [rflink.protocol] received data: 20;02;Mertik_GV60;ID=038527;SWIT 2020-12-14 20:19:25 DEBUG (MainThread) [rflink.protocol] received data: CH=11;CMD=OFF; 2020-12-14 20:19:25 DEBUG (MainThread) [rflink.protocol] got packet: 20;02;Mertik_GV60;ID=038527;SWITCH=11;CMD=OFF; 2020-12-14 20:19:25 DEBUG (MainThread) [rflink.protocol] decoded packet: {'node': 'gateway', 'protocol': 'mertik_gv60', 'id': '038527', 'switch': '11', 'command': 'off'} 2020-12-14 20:19:25 DEBUG (MainThread) [rflink.protocol] got event: {'id': 'mertik_gv60_038527_11', 'command': 'off'} 2020-12-14 20:19:25 DEBUG (MainThread) [homeassistant.components.rflink] event of type command: {'id': 'mertik_gv60_038527_11', 'command': 'off'} 2020-12-14 20:19:25 DEBUG (MainThread) [homeassistant.components.rflink] entity_ids: ['light.mertik_gv60_038527_11'] 2020-12-14 20:19:25 DEBUG (MainThread) [homeassistant.components.rflink] device_id not known, adding new device 2020-12-14 20:19:47 ERROR (MainThread) [homeassistant.components.ipp] Error fetching ipp data: Invalid response from API: Error occurred while communicating with IPP server. 2020-12-14 20:19:56 DEBUG (MainThread) [homeassistant.components.rflink] Sending command: on to Rflink device: mertik_gv60_038527_11 2020-12-14 20:19:56 DEBUG (MainThread) [rflink.protocol] sending command: {'protocol': 'mertik_gv60', 'id': '038527', 'switch': '11', 'command': 'on'} 2020-12-14 20:19:56 DEBUG (MainThread) [rflink.protocol] writing data: '10;mertik_gv60;038527;11;on;\r\n' 2020-12-14 20:19:56 DEBUG (MainThread) [rflink.protocol] waiting for acknowledgement 2020-12-14 20:19:57 DEBUG (MainThread) [rflink.protocol] received data: 20;03;OK; 2020-12-14 20:19:57 DEBUG (MainThread) [rflink.protocol] got packet: 20;03;OK; 2020-12-14 20:19:57 DEBUG (MainThread) [rflink.protocol] decoded packet: {'node': 'gateway', 'protocol': 'unknown', 'ok': True} 2020-12-14 20:19:57 DEBUG (MainThread) [rflink.protocol] command response: {'node': 'gateway', 'protocol': 'unknown', 'ok': True} 2020-12-14 20:19:57 DEBUG (MainThread) [rflink.protocol] packet acknowledged

javicalle commented 3 years ago

The only thing I see strange is that in your initial configuration the device ID was mertik_gv60_038527_13 (from an on command). Sometimes the on and the off commands do not send the same ID.

Have you tried if you can turn off the fireplace from HA with this device?

siggy2 commented 3 years ago

as you can see from below, the IDs are different for the on/off commands and up/down commands from the remote. I've tried to send both off/on and up/down to both ids but there is no response. Find it weird as it seems the commands are going through. Does the protocol (10 vs. 20) have any bearing?

2020-12-14 22:17:33 DEBUG (MainThread) [rflink.protocol] received data: 20;01;Mertik_GV60;ID=038527;SWIT 2020-12-14 22:17:33 DEBUG (MainThread) [rflink.protocol] received data: CH=13;CMD=DOWN; 2020-12-14 22:17:33 DEBUG (MainThread) [rflink.protocol] got packet: 20;01;Mertik_GV60;ID=038527;SWITCH=13;CMD=DOWN; 2020-12-14 22:17:33 DEBUG (MainThread) [rflink.protocol] decoded packet: {'node': 'gateway', 'protocol': 'mertik_gv60', 'id': '038527', 'switch': '13', 'command': 'down'} 2020-12-14 22:17:33 DEBUG (MainThread) [rflink.protocol] got event: {'id': 'mertik_gv60_038527_13', 'command': 'down'} 2020-12-14 22:17:33 DEBUG (MainThread) [homeassistant.components.rflink] event of type command: {'id': 'mertik_gv60_038527_13', 'command': 'down'} 2020-12-14 22:17:33 DEBUG (MainThread) [homeassistant.components.rflink] entity_ids: ['light.mertik_gv60_038527_13'] 2020-12-14 22:17:33 DEBUG (MainThread) [homeassistant.components.rflink] device_id not known, adding new device 2020-12-14 22:17:34 DEBUG (MainThread) [rflink.protocol] received data: 20;02;Mertik_GV60;ID=038527;SWIT 2020-12-14 22:17:34 DEBUG (MainThread) [rflink.protocol] received data: CH=13;CMD=UP; 2020-12-14 22:17:34 DEBUG (MainThread) [rflink.protocol] got packet: 20;02;Mertik_GV60;ID=038527;SWITCH=13;CMD=UP; 2020-12-14 22:17:34 DEBUG (MainThread) [rflink.protocol] decoded packet: {'node': 'gateway', 'protocol': 'mertik_gv60', 'id': '038527', 'switch': '13', 'command': 'up'} 2020-12-14 22:17:34 DEBUG (MainThread) [rflink.protocol] got event: {'id': 'mertik_gv60_038527_13', 'command': 'up'} 2020-12-14 22:17:34 DEBUG (MainThread) [homeassistant.components.rflink] event of type command: {'id': 'mertik_gv60_038527_13', 'command': 'up'} 2020-12-14 22:17:34 DEBUG (MainThread) [homeassistant.components.rflink] entity_ids: ['light.mertik_gv60_038527_13'] 2020-12-14 22:17:34 DEBUG (MainThread) [homeassistant.components.rflink] passing event to light.mertik_gv60_038527_13 2020-12-14 22:17:37 DEBUG (MainThread) [rflink.protocol] received data: 20;03;Mertik_GV60;ID=038527;SWITCH=13;CMD=DOWN; 2020-12-14 22:17:37 DEBUG (MainThread) [rflink.protocol] got packet: 20;03;Mertik_GV60;ID=038527;SWITCH=13;CMD=DOWN; 2020-12-14 22:17:37 DEBUG (MainThread) [rflink.protocol] decoded packet: {'node': 'gateway', 'protocol': 'mertik_gv60', 'id': '038527', 'switch': '13', 'command': 'down'} 2020-12-14 22:17:37 DEBUG (MainThread) [rflink.protocol] got event: {'id': 'mertik_gv60_038527_13', 'command': 'down'} 2020-12-14 22:17:37 DEBUG (MainThread) [homeassistant.components.rflink] event of type command: {'id': 'mertik_gv60_038527_13', 'command': 'down'} 2020-12-14 22:17:37 DEBUG (MainThread) [homeassistant.components.rflink] entity_ids: ['light.mertik_gv60_038527_13'] 2020-12-14 22:17:37 DEBUG (MainThread) [homeassistant.components.rflink] passing event to light.mertik_gv60_038527_13 2020-12-14 22:17:53 ERROR (MainThread) [homeassistant.components.ipp] Error fetching ipp data: Invalid response from API: Error occurred while communicating with IPP server. 2020-12-14 22:18:36 ERROR (MainThread) [homeassistant.components.ipp] Error fetching ipp data: Invalid response from API: Error occurred while communicating with IPP server. 2020-12-14 22:18:44 DEBUG (MainThread) [rflink.protocol] received data: 20;04;Mertik_GV60;ID=038527;SWIT 2020-12-14 22:18:44 DEBUG (MainThread) [rflink.protocol] received data: CH=11;CMD=OFF; 2020-12-14 22:18:44 DEBUG (MainThread) [rflink.protocol] got packet: 20;04;Mertik_GV60;ID=038527;SWITCH=11;CMD=OFF; 2020-12-14 22:18:44 DEBUG (MainThread) [rflink.protocol] decoded packet: {'node': 'gateway', 'protocol': 'mertik_gv60', 'id': '038527', 'switch': '11', 'command': 'off'} 2020-12-14 22:18:44 DEBUG (MainThread) [rflink.protocol] got event: {'id': 'mertik_gv60_038527_11', 'command': 'off'} 2020-12-14 22:18:44 DEBUG (MainThread) [homeassistant.components.rflink] event of type command: {'id': 'mertik_gv60_038527_11', 'command': 'off'} 2020-12-14 22:18:44 DEBUG (MainThread) [homeassistant.components.rflink] entity_ids: ['light.mertik_gv60_038527_11'] 2020-12-14 22:18:44 DEBUG (MainThread) [homeassistant.components.rflink] device_id not known, adding new device 2020-12-14 22:19:19 DEBUG (MainThread) [rflink.protocol] received data: 20;05;Mertik_GV60;ID=038527;SWIT 2020-12-14 22:19:19 DEBUG (MainThread) [rflink.protocol] received data: CH=11;CMD=OFF; 2020-12-14 22:19:19 DEBUG (MainThread) [rflink.protocol] got packet: 20;05;Mertik_GV60;ID=038527;SWITCH=11;CMD=OFF; 2020-12-14 22:19:19 DEBUG (MainThread) [rflink.protocol] decoded packet: {'node': 'gateway', 'protocol': 'mertik_gv60', 'id': '038527', 'switch': '11', 'command': 'off'} 2020-12-14 22:19:19 DEBUG (MainThread) [rflink.protocol] got event: {'id': 'mertik_gv60_038527_11', 'command': 'off'} 2020-12-14 22:19:19 DEBUG (MainThread) [homeassistant.components.rflink] event of type command: {'id': 'mertik_gv60_038527_11', 'command': 'off'} 2020-12-14 22:19:19 DEBUG (MainThread) [homeassistant.components.rflink] entity_ids: ['light.mertik_gv60_038527_11'] 2020-12-14 22:19:19 DEBUG (MainThread) [homeassistant.components.rflink] passing event to light.mertik_gv60_038527_11

javicalle commented 3 years ago

I see (from the letscontrolit forum) that you have different fireplaces and I also see different commands.

What I would do is write down the different commands that you can read from the remote (from HA logs), and then try to send the same commands from HA. To do this, it is best from the developer tools (https://hassio.local:8123/developer-tools/service) invoke the rflink.send_command service and as data try the different commands (on, off, up, down...), for example:

device_id: mertik_gv60_038527_11
command: 'down'
javicalle commented 3 years ago

Does the protocol (10 vs. 20) have any bearing?

No, the 20 is for signals readings and 10 for sending:

javicalle commented 3 years ago

Let's recap all the information. Your remote is using 2 diferents deviceId:

From what I understand, your fireplace is not reacting to any of the signals. This can be for various reasons, so let's go through the usual suspects:

siggy2 commented 3 years ago

Thanks for not giving up on me.

To your questions : I am controlling my blinds with rflink and that works perfectly, so rflink is working on my setup. I tried changing location of the rflink unit and even standing just besides the fireplace - there is no reaction. As to the model, the supported remote on rflink's homepage is mertik G6R H4T1, while my remote has a slight variation to the model number g6r-h4tv21 z22. Now, since it correctly identified the commands from the remote I assumed it would be able to send the same string correctly back? If you think this could be a reason, is there a way to test / rectify this? (based on this thread, it seems to be subtypes of the same model: https://community.home-assistant.io/t/gas-fireplace-mertik-maxitrol-with-rfxtrx/36027 )

I have tried with command combinations in the developer tool without any luck. Any other things to try? 

javicalle commented 3 years ago

So your RFLink is working correctly and signal streng is not a problem. If also with developer tools you don't get any positive response, all the signs points to RFLink and the protocol.

Is not unusual that RFLink detects badly a protocol. I have also seen that the Mertik G6R H4T1 was supported in RFLink, but for some reason it seems like can not decode your remote properly. I find it strange because RFXCom seems to treat them as the same protocol:

From here, there is little more I can do on my part. My recommendation is that you go back to the start line and ask for help in the letscontrolit forum. You can send them the debug traces of your remote and request help, they have documented how to do it on the RFLink website:

Hope you can make it work..

siggy2 commented 3 years ago

I just realized that each remote has a unique code / identifier that the receiver learns when you set it up. I wonder if that is the problem? I've reset the receiver and tried to have it learn from the rflink, but it didn't work either unfortunately. According to the manual, the remote picks a unique identifier that the receiver learns which then separates it from other remotes. Not sure if this is the root of the problem or there is something else wrong with the integration. I'll see if I can get the debug logs recorded and sent in on the RFLINK website. Thanks for bearing with me!

I'll update here if or when I get a response from the rflink people.

javicalle commented 3 years ago

Normally with RFLink there are 2 ways to proceed with a new device:

  1. use the same ID as the remote. In this case the target device (the fireplace in your case) would have no way to distinguish between HA and the remote (because of the same ID)
  2. use a new ID. In this case, to operate the target device it is usually necessary to pair the new ID. That way you could control the device with 2 'remotes' (the physical one and the HA)

Why hasn't it worked for you? I really do not know. I think it must be a problem with the protocol that RFLink must be detecting incorrectly or incompletely, but in that part I cannot help you. I think it's best to get in touch with the RFLink team to see if they can help you.

But... one last thing you could try would be the RFLink learning mechanism. I have not tried it and am not sure how it works. There are even some reports that it does not work very well or is very reliable: