DSC Alarm integration

So i went ahead and put extra error handling into version 3.9 of pyenvisalink. Right now hass is not using that, however. I have a pull request in to HASS and I’ll respond once they merge that in dev.
The behavior i’m shooting for is… i’ll look for that error being thrown when i write, and if i see it i’ll close the connection myself and reconnect after 30 seconds.

Great! Unfortunately I can’t force the error to occur, as I’m not sure what triggers the loss of the connection. However, it seems that every few days it happens. I know this makes testing very difficult, but not sure what else to do about it.

Is there some way to test the code besides setting up a new dev instance of HA? I can replace the affected files locally on my hass.io instance if that would work. I’ve been unsuccessful in setting up a separate dev instance in the past, plus with the difficulty in testing this I think my best scenario would be to put the update on my main system and use it to find out if it fails over the next week or so.

Yeah it is possible- you’d have to grab the pyenvisalink files and replace them within our python home directory within the site-packages/pyenvisalink folder. I’m not near a computer at the moment to help point you closer than that but if you’re still looking for help in a few days I’ll see if I can find the exact folder path.

I have to say mine’s been solid over the past month.

Hello:
Just start to use Envisalink with HASS, and so far it looks perfect.
Before i use Envisalink (DSC) with Openhab and have the possibility to see which user that arm/disarm the house.
This was perfect to see when the kids get home :slight_smile:
Is it possible to do the same with Envisalink on HASS, or would it be possible to add the functionality ?

Regards

Andreas

Duh. I initially posted code for ZWave keypad on the door. Here’s the Envisalink version.

I do this (I’m user 40 so I don’t notify myself when I disarm the alarm):

- alias: Alarm Disarmed
  trigger: 
    - platform: state
      entity_id: sensor.home_alarm_keypad
      to: 'Disarmed'
  condition: 
    # filter myself out
    condition: template
    value_template: "{{not(states.binary_sensor.scott_home.state == 'on' and states.sensor.home_alarm_keypad.attributes.last_disarmed_by_user == 40)}}"
  action:
    - service: notify.scott_notifier
      data: 
        title: "Alarm"
        data:
          priority: 0
      data_template:
        message: >
          {% if states.sensor.home_alarm_keypad.attributes.last_disarmed_by_user %}{{ ["Name user in position 1","Name user in position 2","Name user in position 3","Name user in position 4"][states.sensor.home_alarm_keypad.attributes.last_disarmed_by_user - 1] }}{% else %}Someone{% endif %} disarmed the alarm

Extend that list at the end if you have more than 4 codes defined that you want to track names for…

So you want to be notified when the kids get home? That’s normally done via presence detection. Install an app on their phones, like Life360, and monitor it with this excellent Life360 custom component. Then, in addition to being notified, you can then automatically disarm the security system if you want. It’s also great to keep track of where they are in general.

Also, if you have a smart lock for entry, each kid can have their own key code to unlock the door, identify them, and then also automatically disarm the security and notify you. I think this is close to what @ih8gates was describing in his reply.

Is Envisalink still not supporting the Neo panel?

Hello I am having some difficulty connecting my Home Assistant to EVL-4.

envisalink:
host: 192.168.0.XXX
panel_type: DSC
code: ‘1234’
user_name: user
password: user
evl_version: 4
zones:
1:
name: ‘Zone 1’
type: ‘opening’

partitions:
1:
name: ‘Home Alarm’

I have migrated from my Vera controller that could connect to the EVL-4 and ensured Vera was disconnected before trying this. My Envisalink webpage does show TPI connected, but when I check my HA home-assistant.log, it gives me this and also does not show up in my HA Panel.

2019-05-24 18:02:47 ERROR (MainThread) [homeassistant.components.envisalink] Could not establish a connection with the Envisalink

2019-05-24 18:02:47 ERROR (MainThread) [homeassistant.setup] Setup failed for envisalink: Component failed to initialize.

Would appreciate any help. I am running the latest Home Assistant also 0.93.1
Envisalink FW version is Firmware Version: 01.02.130

Thanks!

Blockquote

My config looks slightly different than yours, but not much:

envisalink:
host: dscserver
panel_type: DSC
user_name: user
password: user
code: ‘XXXX’
port: 4025
evl_version: 3
keepalive_interval: 60
zonedump_interval: 0
panic_type: Police
zones:
1:
name: ‘Kitchen Door’
type: ‘door’

I noticed your firmware version is quite a bit behind. I’m at 01.12.193, but I’m on an EVL3. Is your EVL connected to the internet to get firmware updates? You should see on the TPI page for the EVL, what IP is connected to it. Is that IP the IP of your HA server? Also I assume you have the right username and password for the EVL configured in HA. Can you ping from the HA machine to the EVL?

Hi thank you for the reply. The firmware version that I have is the latest … The EVL3 has been around longer and so it has more revision releases … (I checked around and it’s pretty consistently higher numbers). I believe it automatically updates, but I could be wrong. I can ping and get a reply. User name and password are indeed correct. As I mentioned before, I connected my Vera controller to it and have no issues (and yes I did disable the Vera and reboot the EVL-4 before trying with HA). Thanks … If you or anyone else has any more suggestions or diagnostics I can run, I would appreciate it.

So I decided to try this multiple times on a dedicated virtual machine running Hassio on a Mac experiment. I made the following observations:

envisalink:
host: 192.168.0.XXX
panel_type: DSC
code: ‘1234’
user_name: user
password: user
evl_version: 4
zones:
1:
name: ‘Zone 1’
type: ‘opening’

partitions:
1:
name: ‘Home Alarm’

is broken. When it is broken, the server just hangs and Home Assistant does not come up at all. There is no time out. I tried varying the timeout variable but it just hangs there.

envisalink:
__host: 192.168.0.XXX
__panel_type: DSC
__code: ‘1234’
__user_name: user
__password: user
__evl_version: 4
__partitions:
___1:
____name: ‘Home Alarm’
__zones:
___1:
____name: ‘Zone 1’
____type: ‘opening’

appears to work. I had to move the partitions above and delete any empty lines. I am not sure why, but this seemed to work. I added “_” to represent spaces, since this the editor here doesn’t allow for spaces.

  1. I had been also experimenting with trying to connect to a DSC server that connects to the Envisalink card. It basically Relays the command back and forth between the Envisalink and devices that want to connect by TPI. The Envisalink does not allow multiple TPI connections unfortunately. The Vera controller I have seems to be able to connect just fine and works with the DSC Server, but Home Assistant doesn’t want to connect. I get connection failures.

  2. When I connect directly to the Envisalink and not through the server, it seems to work. I get the arm/disarm buttons and a couple of sensors for each zone. However, It does not connect consistently.
    I often get this:

2019-05-29 11:57:20 ERROR (MainThread) [homeassistant.components.envisalink] Could not establish a connection with the Envisalink

2019-05-29 11:57:20 ERROR (MainThread) [homeassistant.setup] Setup failed for envisalink: Component failed to initialize.

2019-05-29 11:57:20 ERROR (MainThread) [pyenvisalink.envisalink_base_client] The server closed the connection. Reconnecting…

The reconnection appears successful on the Envisalink side showing my client is connected. The Home Assistant side, the alarm panel doesn’t show up again. I have tried a couple of times now and can’t seem to get it to connect again after the first few tries. Not sure what is going on. Is there a verbose mode somewhere that I can do more debug on this? Not sure why HA is not connecting now. Hope someone can offer some help here.

Well, I messed around with it some more … The only way I can get HA to connect successfully to Envisalink is to restart HA from the Configuration->General-Server Management menu and Click Restart. If I restart using sudo reboot, it does not want to connect for some reason. It’s not a very good workaround and makes me wonder how I can make it better … for example, if I have a power outage this most likely would not work. One thing I might try is to migrate everything to virtual machine on an always on Mac Mini that I have. The reboot time is super fast compared to my Raspberry Pi.

I’m actually using a dscserver to proxy my envisalink also. Obviously the dscserver is the only TPI connection to the envisalink and everything else goes through it. I run hass.io on a rpi 3. I’ve had a few stability issues with the dsc integration but a restart like you described always clears it. I’ve never been able to pinpoint the cause and it might be self inflicted. I’ve honestly considered setting up a nightly reboot as I suspect I’d have no issues after that but that just goes against everything I believe in.

This might be an idea instead of a scheduled restart.

I have used an envisalink for 4 years with HA and early on had connection problems. I resolved it by moving HA from a mac to a pi for the envisalink component. Not sure why that helped but it did. Also, I made sure only one connection is to the envisalink. If the connection is broken from HA unexpectedly, envisalink still doesn’t accept new connection for a time, I had to sometime log into envisalink website and caused it to reboot and HA then can log in ok.

Thanks for the reply. Could you tell me how you set up your dscserver? Do you have it on a separate machine from the HA server?
My DSCServer is setup on the same Raspberry Pi as my primary HA. My Vera Z-Wave controller can communicate with the DSCServer with no issues. However, I get connection errors and HA hangs and the Web UI does not come up when I try to connect to the DSC server either from my Raspberry Pi instance or my Virtual machine instance so I cannot even do a soft reboot from the web interface. Perhaps I am missing a setup step?

Thank you … actually I had forgotten the step that I had to reboot the Envisalink from the WebUI also and soft start HA to finally get the HA to connect directly. I have not repeated all these steps with my DSCServer setup. Perhaps I should try that. Good suggestion on the monitoring home-assistant.log file. I will have to figure out how to do that as a work around for now.

I’ve never had ANY stability problems with the dscserver or it’s connection to envisalink. My dscserver runs on an old Android phone though. Quite a few years ago I bought an old net10 prepaid phone refurb online for $5 and it’s been running fine ever since. I never reboot the dscserver phone other than occasionally if my WiFi is down for some reason the older version of Android on the phone doesn’t reconnect to wifi when it comes back up but that’s an issue with Android and not the phone. I don’t have any experience with the Java version of dscserver although my understanding is that is runs from the same code base as the Android version. It might be worth purchasing a cheap phone or pulling one from a drawer if you have one and running dscserver on it. I know mikep (dscserver developer) runs his on a phone so I assume that is the more tested code base.

Thanks … I don’t think I have a single android device in the house except my car head unit. So perhaps I will try to make or download an android virtual machine first on one of my macs and get the android app. If it works, then I may buy a dedicated device. But I think one of my primary issues is connection with the Envisalink itself from HA. Even when I connect directly, it only sometimes connects.

Hi Cinntax, I noticed again today that my Hass.io has lost connection to my envisalink again. I noticed because one of my motion sensors was constantly reporting motion when there was none. The logs are below from the past couple of days. This seems to be a similar issue to the one I experienced previously. Did the code for automatic reconnections make it into production? Could this be caused if my dscserver phone was temporarily off wifi and the pyenvisalink module just gave up and stopped trying to reconnect?

2019-06-17 20:04:37 ERROR (MainThread) [pyenvisalink.dsc_client] The envisalink asked for a code, but we have no code in our cache.
2019-06-17 21:31:35 ERROR (MainThread) [pyenvisalink.envisalink_base_client] The server closed the connection. Reconnecting…
2019-06-17 21:32:05 ERROR (MainThread) [homeassistant.components.envisalink] Could not establish a connection with the Envisalink
2019-06-18 14:03:40 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1819846256] unable to perform operation on <TCPTransport closed=True reading=False 0x707ff030>; the handler is closed
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py”, line 121, in handle_call_service
connection.context(msg))
File “/usr/src/homeassistant/homeassistant/core.py”, line 1150, in async_call
self._execute_service(handler, service_call))
File “/usr/src/homeassistant/homeassistant/core.py”, line 1172, in _execute_service
await handler.func(service_call)
File “/usr/src/homeassistant/homeassistant/helpers/entity_component.py”, line 194, in handle_service
required_features
File “/usr/src/homeassistant/homeassistant/helpers/service.py”, line 316, in entity_service_call
future.result() # pop exception if have
File “/usr/src/homeassistant/homeassistant/helpers/service.py”, line 337, in _handle_service_platform_call
await getattr(entity, func)(**data)
File “/usr/src/homeassistant/homeassistant/components/envisalink/alarm_control_panel.py”, line 143, in async_alarm_arm_away
str(self._code), self._partition_number)
File “/usr/local/lib/python3.7/site-packages/pyenvisalink/alarm_panel.py”, line 238, in arm_away_partition
self._client.arm_away_partition(code, partitionNumber)
File “/usr/local/lib/python3.7/site-packages/pyenvisalink/dsc_client.py”, line 58, in arm_away_partition
self.send_command(evl_Commands[‘ArmAway’], str(partitionNumber))
File “/usr/local/lib/python3.7/site-packages/pyenvisalink/dsc_client.py”, line 26, in send_command
self.send_data(to_send)
File “/usr/local/lib/python3.7/site-packages/pyenvisalink/envisalink_base_client.py”, line 102, in send_data
self._transport.write((data + ‘\r\n’).encode(‘ascii’))
File “uvloop/handles/stream.pyx”, line 671, in uvloop.loop.UVStream.write
File “uvloop/handles/handle.pyx”, line 159, in uvloop.loop.UVHandle._ensure_alive
RuntimeError: unable to perform operation on <TCPTransport closed=True reading=False 0x707ff030>; the handler is closed