gluap / pyduofern

GNU General Public License v2.0
40 stars 11 forks source link

Error when sending command in Home Assistant 0.90.2 #2

Open nodomain opened 5 years ago

nodomain commented 5 years ago

Hi,

I managed to get the new version running but when I send a command, this error shows up

2019-04-08 06:52:35 INFO (Thread-3) [/srv/homeassistant/lib/python3.6/site-packages/pyduofern/duofern_stick.py] sending 0D01070100000000000000000000006f301140106e00 from write queue, 0 msgs left in queue
2019-04-08 06:52:35 ERROR (Thread-3) [/srv/homeassistant/lib/python3.6/site-packages/pyduofern/duofern_stick.py] 'id'
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.6/site-packages/pyduofern/duofern_stick.py", line 577, in run
    self.process_message(in_data)
  File "/srv/homeassistant/lib/python3.6/site-packages/pyduofern/duofern_stick.py", line 227, in process_message
    self.duofern_parser.parse(message)
  File "/srv/homeassistant/lib/python3.6/site-packages/pyduofern/duofern.py", line 521, in parse
    chan = msg[sensorMsg['id']['chan'] * 2 + 2:sensorMsg['id']['chan'] * 2 + 4]
KeyError: 'id'

Config

duofern:
  serial_port: /dev/cuaU2
  code: !secret duofern_code

Any clue? :D

nodomain commented 5 years ago

I assume this is the source for the GUI not being updated. The cover opened but cannot be closed again via the GUI.

gluap commented 5 years ago

@nodomain: Am I right in guessing that you use one of "Wandtaster, Funksender UP, Handsender, Sensoren"? I think I spotted the issue and tried to add a fix in the latest commit. Unfortunately I can't test it for lack of these devices. Could you check if you still get the same error message after upgrading your custom component?

Basically what happened on your end was that the thread processing messages from duofern tried to process a message from one of the devices and encountered an exception. After that, no duofern functions were available any more.

Disclaimer: currently I only have evidence that remote power switches and roller shutters work. These are also the only ones that have been implemented for homeassistant. Still I would want the code to work also in the presence of unknown devices.

PS: Sorry this reply took so long, I only now found out that I must accidentally have unwatched this repository so I wasn't getting any e-mail notifications.