Alarm Decoder stops working after a couple days

I cant help with the rror, but I was running into similar issues. I use a AD2USB and could not get it to work correctly directly within HA with USB setup only. So I Installed ser2sock (https://github.com/nutechsoftware/ser2sock) This worked like a charm. It is much easier to get working and integrated. Also use these instructions https://github.com/nutechsoftware/ser2sock#installation after you clone the repo.

Can you also try the latest version of HA 0.50.2?

  • Upgrade the alarmdecoder dependency library from 0.12.1 to 0.12.3. (#8542)

I believe the changes in alarmdecoder delt with timeouts.

I know the

Even on 0.50.2 it happens. ser2sock is not really an options unless it becomes an addon package for Hass.io.

Again, latest (0.50.2).

2017-08-07 03:58:54 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/alarmdecoder/devices.py", line 807, in write
    self._device.write(data)
  File "/usr/lib/python3.6/site-packages/serial/serialposix.py", line 497, in write
    raise portNotOpenError
serial.serialutil.SerialException: Attempting to use a port that is not open
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/lib/python3.6/asyncio/tasks.py", line 179, in _step
    result = coro.send(None)
  File "/usr/lib/python3.6/site-packages/homeassistant/core.py", line 1025, in _event_to_service_call
    yield from service_handler.func(service_call)
  File "/usr/lib/python3.6/site-packages/homeassistant/components/alarm_control_panel/__init__.py", line 114, in async_alarm_service_handler
    yield from getattr(alarm, method)(code)
  File "/usr/lib/python3.6/asyncio/coroutines.py", line 210, in coro
    res = func(*args, **kw)
  File "/usr/lib/python3.6/site-packages/homeassistant/components/alarm_control_panel/alarmdecoder.py", line 116, in async_alarm_arm_home
    self.hass.data[DATA_AD].send("{!s}3".format(code))
  File "/usr/lib/python3.6/site-packages/alarmdecoder/decoder.py", line 261, in send
    self._device.write(data)
  File "/usr/lib/python3.6/site-packages/alarmdecoder/devices.py", line 813, in write
    raise CommError('Error writing to device.', err)
alarmdecoder.util.CommError: ('Error writing to device.', SerialException('Attempting to use a port that is not open',))

According to the docs, this is supported functionality. There is obviously a bug in the Alarm Decoder implementation that needs to be resolved. Let me know if I can provide any more logs.

Note: I’m using Hass.io. Simply using ser2sock is not a viable option unless it is released as a package to install within Hass.io. If serial isn’t supported due to bugs, then it should be removed from the official documentation as a supported method until it is fixed.

Do you have the panel_display enabled? Is it updating or are you getting notification about sensors toggling state?

I am curious if the read side of the connection is still working since the write side seems broken.

I wonder if there is a connection idle timeout from either the AlarmDecoder python package or the Serial python package.

Next time the alarm goes into a bad state, I will do some testing on the read side of things and let you know. I’ve never looking into that part very closely.

@hawk259 Just had it happen. It’s completely dead, can’t set the alarm, can’t get status updates from any of the sensors. Same error in the logs.

I am not sure if two things can open the serial device at the same time, so this test might require either disabling AlarmDecoder in HA or not running HA.

Can you run examples/serialport.py for a while and see what happens? I am curious if it has the same issue as HA where it just stop working after a while. Since we know it happens to both the read and write sides, if the reads stop working then we know it is a issue in the alarm decoder python package.

I cannot run that. Even if I clone the Git repo and try to run it, I always get:

./serialport.py: line 1: import: not found
./serialport.py: line 2: from: not found
./serialport.py: line 3: from: not found
./serialport.py: line 6: SERIAL_DEVICE: not found
./serialport.py: line 7: BAUDRATE: not found
./serialport.py: line 9: syntax error: unexpected "("

Currently, my alarm is not working, so if there is any troubleshooting I can do right now while in error state, I will leave it broken for the day.

That is weird as pyserial should be installed already and I believe that is where those are defined.

You might try:

python3 ./serialport.py

Also test python35 and python36. Do those work?

I’m experiencing the same thing as @goyney using the AD2USB in homeassistant (currently v0.55.0), configured as:

alarmdecoder:
  device:
    type: serial
  panel_display: On

At first I thought it was a fluke but it seems to happen with some regular cadence and the only remedy is to stop and start home assistant to get it working again, until after some time and then it just stops emitting or responding.

1 Like

What do we need to do to get this fixed? It’s been months without any update or progress. It is very disheartening to not have any faith that if my alarm is triggered, I may not get the notification.

Not sure but isn’t this related Stability of HA
Where other components just fail as well if HA is not restarted for 4-5 days? So maybe the problem is deep in the core

Have you been able to get the serialport.py script working?

Need to figure out if this is a HA or a AD issue. By using the serialport.py script this removes HA out of the pictures and if serialport.py has the same issues, then it is a AD problem and not something HA can fix.

I am using socket and am experiencing the same issue. It happened today and I just ran a modified version of the script and it is able to connect. I am going to setup a script to monitor tcpdump to that host/port and try to correlate the time with an error in the log. It stops trying to make any attempts to connect when the issue occurs. I’d like to see this resolved so I will be available to provide any assistance needed.

1 Like

Were you able to get anything useful out of that script? Still have issues here.

I’m starting to wonder if there is some stability stuff that could be added to the serial control of Home Assistant so that it automatically tries to reconnect to a serial port if it is not open, rather then just fail blindly.

I’m reporting in here about my continued issues with Alarm Decoder and Home Assistant. Since I am running Hass.io, it has always been out of my reach to try running ser2sock to verify that this problem is not just a serial device issue.

Over the past week or so, I got caught up on writing Hass.io add-ons and created one for ser2sock. I have reconfigured Home Assistant to now use a socket interface instead. I have full control over my alarm using this method.

I have now noticed that Home Assistant looses connection to my alarm quicker than when directly using the serial interface. When Home Assistant cannot communicate with my alarm, I see this log in Home Assistant’s logs:

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/lib/python3.6/site-packages/alarmdecoder/devices.py”, line 1124, in write
data_sent = self._device.send(data)
OSError: [Errno 9] Bad file descriptor

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/lib/python3.6/asyncio/tasks.py”, line 179, in _step
result = coro.send(None)
File “/usr/lib/python3.6/site-packages/homeassistant/core.py”, line 1031, in _event_to_service_call
yield from service_handler.func(service_call)
File “/usr/lib/python3.6/site-packages/homeassistant/components/alarm_control_panel/init.py”, line 142, in async_alarm_service_handler
yield from getattr(alarm, method)(code)
File “/usr/lib/python3.6/asyncio/coroutines.py”, line 210, in coro
res = func(*args, **kw)
File “/usr/lib/python3.6/site-packages/homeassistant/components/alarm_control_panel/alarmdecoder.py”, line 116, in async_alarm_arm_home
self.hass.data[DATA_AD].send(“{!s}3”.format(code))
File “/usr/lib/python3.6/site-packages/alarmdecoder/decoder.py”, line 261, in send
self._device.write(data)
File “/usr/lib/python3.6/site-packages/alarmdecoder/devices.py”, line 1132, in write
raise CommError(‘Error writing to device.’, err)
alarmdecoder.util.CommError: (‘Error writing to device.’, OSError(9, ‘Bad file descriptor’))

When the problem is occurring, I can directly hit the socket interface and control my alarm, so it is most definitely Home Assistant that is the problem. Restarting Home Assistant restores the connection.

This now leads me to believe that there is something fundamentally flawed with how Home Assistant, or Home Assistant’s implementation of alarm control panels, communicates and retains connections to serial AND socket devices.

I have now opened up an issue on GitHub: Alarm Decoder connections via socket or serial stop responding randomly · Issue #11157 · home-assistant/core · GitHub

What version of the firmware is running on your AD?

I am running firmware version 2.2a.8.8.

Ok, I might get brave over this weekend and upgrade to 2.2a.8.8. Right now I am running a 2.2a.8.5g and I still have that .hex file if I need to downgrade.

That should remove the firmware being the issue.