ELK M1 Interface

I think this probably covers everything for helpers:

Outputs : you already added on / off / toggle, should be all that’s needed
Lights : on / off / toggle / brightness (for brightness, I realized last night I’m not 100% sure how this should work - X10 is weird about setting brightness and I’m not sure how Elk is mapping that to other systems - so we can table that for now if need by)
Areas : arm/disarm (pass in user code to use via argument)
Thermostats : set cool / heat setpoints, set fan mode (auto/on), set operation mode (off/cool/heat/auto/aux), set hold mode
Counters / Settings : set value
Tasks : Activate

For Tasks, also need to catch TC messages and somehow flag that a task has been activated so that an Elk task can trigger something in HASS - in my lib I both updated a ‘last_activated’ attribute that stored a timestamp and make a callback to HASS.

Will also need to catch IC messages and try to correlate them to arm/disarm/access - in my lib when a keypad was the source of an IC I updated it as well as it’s associated area, and again used timestamps. There’s no direct tie between an IC message and any arm/disarm messages, so you just have to assume that if you get an arm/disarm message very shortly after IC that it was used for it. ‘Access’ is IC without a corresponding arm/disarm following.

Thx! I will pluck away on these. By the way, you need to pull the latest if you are trying to use the Outputs helpers that I added. I messed them up but have fixed just seconds ago.

Added helpers for lights, areas, counters, tasks, thermostat. Add IC handler.

I think that is everything.

Hi trying to get this component setup. I am running home assitsant in a docker on my Synology NAS. There was no components or custom_components folder in the root, so I made both and tried copying the files/folders from ha-elkm1-0.2.0 into first the components folder and did not get anywhere, then made the custom_components folder and then get this in the logfile:

WARNING (MainThread) [homeassistant.setup] Setup of config is taking over 10 seconds.
2018-04-15 16:37:59 ERROR (MainThread) [homeassistant.setup] Error during setup of component elkm1
Traceback (most recent call last):
File “/usr/src/app/homeassistant/setup.py”, line 145, in _async_setup_component
component.setup, hass, processed_config)
File “/usr/local/lib/python3.6/concurrent/futures/thread.py”, line 56, in run
result = self.fn(*self.args, **self.kwargs)
File “/config/custom_components/elkm1.py”, line 163, in setup
import PyElk
ModuleNotFoundError: No module named ‘PyElk’

Any help getting this setup would be appreciated. I have an Elk M1 with the M1XEP interface.

Thanks

What is happening is that the PyElk module is not installed. I don’t know why though as Hass usually installs dependencies for you.

You can try pip install PyElk==0.2.0.dev20 which is the dependency for the latest Hass Elk code.

It looks like it was installed to the following directory:

/docker/HomeAssistant/deps/lib/python3.6/site-packages/PyElk

/docker/HomeAssistant/deps/lib/python3.6/site-packages/PyElk-0.2.0.dev20.dist-info
Do I need to make a manual pointer to this directory somewhere else. Maybe becuase it sit is living in docker it can’t find it?

Thanks

That’s where it should be installed, assuming that /docker/HomeAssistant is mounted into the docker container at /config (I’m assuming it is since it got installed there). Not sure why you’re getting an error that it can’t be found.

Yes, it was installed into /config via docker, but now I am getting a different error, maybe it took time to download the dependencies and I tried before it finished downloading. Looks like I need to verify the ports that the M1 is configured for, not sure if the default 2101 is correct, I’ll check later today. Thanks

2018-04-16 11:52:50 ERROR (MainThread) [homeassistant.setup] Error during setup of component elkm1
Traceback (most recent call last):
File “/config/deps/lib/python3.6/site-packages/serial/urlhandler/protocol_socket.py”, line 61, in open
self._socket = socket.create_connection(self.from_url(self.portstr), timeout=POLL_TIMEOUT)
File “/usr/local/lib/python3.6/socket.py”, line 724, in create_connection
raise err
File “/usr/local/lib/python3.6/socket.py”, line 713, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/src/app/homeassistant/setup.py”, line 145, in _async_setup_component
component.setup, hass, processed_config)
File “/usr/local/lib/python3.6/concurrent/futures/thread.py”, line 56, in run
result = self.fn(*self.args, **self.kwargs)
File “/config/custom_components/elkm1.py”, line 193, in setup
pyelk_instance.connect()
File “/config/deps/lib/python3.6/site-packages/PyElk/Elk.py”, line 380, in connect
self._connection.connect(self, self._config[‘host’], ratelimit)
File “/config/deps/lib/python3.6/site-packages/PyElk/Connection/init.py”, line 138, in connect
self._connection = serial.serial_for_url(path, timeout=1, **options_flat)
File “/config/deps/lib/python3.6/site-packages/serial/init.py”, line 88, in serial_for_url
instance.open()
File “/config/deps/lib/python3.6/site-packages/serial/urlhandler/protocol_socket.py”, line 64, in open
raise SerialException(“Could not open port {}: {}”.format(self.portstr, msg))
serial.serialutil.SerialException: Could not open port socket://192.168.50.50:2101: [Errno 111] Connection refused

Currently it only supports insecure (non SSL, no username/password) which by default is on port 2101. If you have disabled that mode, you’ll need to enable it for the current release of code to work with it. A future release will support SSL and username/password. If it’s on another port, you can just change the socket://... accordingly.

Thanks, got further along tonight, had to turn port 2101 back on in the M1XEP as it was disabled. Now I see the sensors and switch outputs all named and ready to go. Looks interesting, I will play with it further. Thanks for the assistance.

Question for everyone. I want to tiger an automation when the elk alarm is going off. The entity for the elk: alarm_control_panel.elk_area_1 does not say anything except “triggered.” It says this when the count down is happening after triggering the alarm, so that wont work. I just want the automation to tiger when the alarm is set off. What I want is to look at the state attribute “Alarm.” I want the automation to trigger when “Alarm”: “Burglar Alarm”.

How do I do this?

So far, the port of HASS code to use @gwww 's library is mostly done (though there may be a few finer details not yet implemented). Just need to do the alarm_control_panel platform.

The adventurous can check out the https://github.com/BioSehnsucht/ha-elkm1/tree/gwww-elkm1-lib branch, but if you’re actually using the existing ha-elkm1 version I wouldn’t switch to it yet (unless you have a testing instance of HASS to test it with).

You’ll currently lose some features, like the ability to include/exclude devices is not currently implemented (instead, everything is populated at the moment and devices with default (unchanged) names in Elk are hidden). Also, no Omni2 support yet (though an Omni2 will work like a regular thermostat, you won’t get any additional information from it), and as of yet no support for real serial ports, just unsecured.

@matthewjohn I had looked into this before, and I’ll double check it once I get the alarm_control_panel code updated to use the new library. I thought I had fixed this, but that might have been on my local copy before I switched to using gwww’s library. I’ll make sure useful status is being reported for the next version.

And in the lib I will have to handle get the alarm state. Once we decide the best approach the code should be able to quickly follow.

The basics should all work (hopefully) now on the new branch. Still need to port over some details, and clean up some things, and there’s a few minor features not yet implemented, so I would still not suggest switching your live HASS instance to it…

Progress update:

It’s untested, but in theory the new branch can now speak to Elk using serial, insecure TCP socket, and secure TCP socket (new!). The underlying library from @gwww has been tested to work, just haven’t tested HASS using modes other than insecure TCP socket.

Still have a few old features to reimplement, but getting close. Notably is Omnistat support for extra sensors (it will work as a thermostat, just no outside temp / 3rd / 4th sensor yet), but there’s a few other little things to sort.

Once I get things “shippable” I’m not going to hold out for Omnistat extra sensor support as that’s a nice to have but not truly necessary.

Also have one or two bugs that were not related to the underlying library to hunt down, such as the Recorder error about object not being JSON serializable (I have no idea why it’s a good idea to try serializing all data on an entity including the “private” data … )

borat.gif Great Success! I have solved the Recorder problem. Fix actually has to go in the library so pulling my current HASS code will still be broken, once the library is updated and my HASS code is updated to the new version, that will be solved.

gwww-elkm1-lib branch now will work without breaking Recorder.

1 Like

Trying the new branch (https://github.com/BioSehnsucht/ha-elkm1/tree/gwww-elkm1-lib).

For some reason, it doesn’t like my configuration.yaml:

elkm1:
  host: socket://192.168.0.100:2101
  area:
    exclude: 2-8

2018-05-06 16:39:39 ERROR (MainThread) [homeassistant.config] Invalid config for [elkm1]: expected list for dictionary value @ data[‘elkm1’][‘area’][‘exclude’]. Got ‘2-8’. (See /config/configuration.yaml, line 185).

For host try:
elk://192.168.0.100

(you can add :2101 if you like, but it defaults)

Configuration format has changed a bit on the new branch.

elkm1:
  host: elk://192.168.0.100:2101
  area:
    exclude:
      - 2-8

Changing from socket to elk wasn’t the only change, it now uses YAML lists to be consistent with other HASS configuration stuff, rather than CSV.