ELK M1 Interface

Ah, I forgot, I haven’t committed code with counter and setting as sensors yet to Github. It’s in PyElk, just not exposed to HASS yet.

Ok that makes sense why I don’t see it.
I’ll keep playing with what’s available for the meantime.

Thank you so much again.

Still trying to wrap my head around how this all works together. I realize how updating the ha-elkm1 component works (thx for the answer earlier!), but how do we go about updating PyElk? I cannot find it in my .homeassistant directory at all, so I’m just not sure how the whole dependency thing works.

Thanks!

I think you should keep all external temperature sensors connected to the thermostat as separate sensors, for example, this is the behavior with ecobee. The main thermostat + a separate sensor for each external thermostat.

PyElk is automatically installed by HASS at (config directory)/deps/lib/…/PyElk/. The code in ha-elkm1 specifies the version to use, and HASS will make sure that is the version installed.

Gotcha - found it. And just to make sure I’m clear, are you saying that an upgrade of ha-elkm1 is required in order to specify that a new version of PyElk is to be used, or that we can force ha-elkm1 to use the new version of PyElk by manually updating the version?

The correct version (and there is only one correct version for any given version of ha-elkm1) of PyElk is specified in the ha-elkm1 code, so that HASS always ensures it is the version installed. So you never need to worry about PyElk. You could manually overwrite it behind HASS’ back (if you replace the files under config/deps it won’t know the difference), but that’s just likely to break things as the PyElk API is constantly evolving (and when I release ha-elkm1 updates they are updated to use the new version of PyElk). At the moment it will guaranteed break things, in the future this will hopefully settle down to just bug fixes for PyElk and not major changes to how it works, but until then manually updating PyElk without ha-elkm1 is going to lead to things figuratively catching on fire.

1 Like

Progress update. Getting close.

Untested : Setting serial port settings (baud rate, etc), configuring fast loading from previous saved state (saved states have been tested, just hard coded on/off)

Hopefully fixed but couldn’t reproduce originally : loss of connection in HASS to elk when android app connects to elk, HASS not updating to show armed state when area is armed, _convert_for_display thermostat error

To do : ensure thermostat state updates on startup (currently, temp appears and the UI appears to know the state when clicking on the state card but it doesn’t reflect this in the overview until something is changed), selectable Celcius/Fahrenheit for thermostat and temp sensors

Future, not going to get into the upcoming release : SSL connection support and connecting to Elk with username/password

3 Likes

Can’t wait for the update! My log has lots of these errors:

NameError: name 'STATE_ALARM_PENDING' is not defined
2018-03-06 17:36:13 ERROR (MainThread) [homeassistant.helpers.entity] Update for alarm_control_panel.elk_area_1 fails
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/helpers/entity.py", line 204, in async_update_ha_state
    yield from self.async_device_update()
  File "/usr/src/app/homeassistant/helpers/entity.py", line 327, in async_device_update
    yield from self.hass.async_add_job(self.update)
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 327, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 250, in _wakeup
    future.result()
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 243, in result
    raise self._exception
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/app/homeassistant/components/alarm_control_panel/elkm1.py", line 126, in update
    self._state = STATE_ALARM_TRIGGERED
NameError: name 'STATE_ALARM_TRIGGERED' is not defined

And this one:

2018-03-06 17:36:33 ERROR (Thread-3) [PyElk.Elk] elk_queue_process - removing stale event: 'EM'

The Traceback error about STATE_ALARM_TRIGGERED should be fixed in next release.

The “ERROR” about removing stale event ‘EM’ isn’t really an error it’s just classified as one so that it’s visible in the logs (it’s really debugging output but by default debug output isn’t logged). The ‘EM’ event is triggered when the Elk tells the M1XEP / C1M1 to send an email. I haven’t yet added any kind of handling for it, but I’ll add it to the to-do list so that if nothing else it gets discarded instead of ignored (so you don’t see these warnings).

You are probably aware, but just in case I also see traceback errors for:

STATE_ALARM_PENDING
STATUS_ARMED_STAY_INSTANT

I also see this one alot:

2018-03-07 06:31:08 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 180, in _step
    result = coro.send(None)
  File "/usr/src/app/homeassistant/helpers/entity.py", line 222, in async_update_ha_state
    attr = self.state_attributes or {}
  File "/usr/src/app/homeassistant/components/climate/__init__.py", line 502, in state_attributes
    supported_features = self.supported_features
  File "/usr/src/app/homeassistant/components/climate/__init__.py", line 785, in supported_features
    raise NotImplementedError()
NotImplementedError

Those should all be fixed, but just to be sure they’re the same ones I’ve seen before, can you post the Tracebacks for the other two (STATE_ALARM_PENDING / STATUS_ARMED_STAY_INSTANT) too?

Hey, Thank you for the work on this.

I have just installed this on a new Hass.io installatoin, and after a second restart the service comes up
The configuration i am using is as follow’s

elkm1:
  host: socket://172.16.1.253:2101
  area:
    include: 1
    exclude: 2-8
  counter:
   enabled: false
   exclude: 1-64
  zone:
    enabled: true
  output:
    exclude: 1-32, 41-208
  x10:
    enabled: false
    exclude: a1-p16
  task:
    enabled: false
    exclude: 1-32
  thermostat:
    enabled: false
    exclude: 1-16

But - the enabled flag, and some of the ranges are being ignored, or causing the service to fail…

2018-03-09 17:36:32 INFO (MainThread) [homeassistant.core] Bus:Handling <Event system_log_event[L]: timestamp=1520616992.5604997, level=ERROR, message=Elk config : OrderedDict([('host', 'socket://172.16.1.253:2101'), ('area', OrderedDict([('include', [1]), ('exclude', ['2-8']), ('enabled', True), ('autohide', True)])), ('counter', OrderedDict([('enabled', False), ('exclude', ['1-64']), ('include', ['1-64']), ('autohide', True)])), ('zone', OrderedDict([('enabled', True), ('exclude', []), ('include', ['1-208']), ('autohide', True)])), ('output', OrderedDict([('exclude', ['1-32', '41-208']), ('include', ['1-208']), ('enabled', True), ('autohide', True)])), ('x10', OrderedDict([('enabled', False), ('exclude', ['a1-p16']), ('include', ['a1-p16']), ('autohide', True)])), ('task', OrderedDict([('enabled', False), ('exclude', ['1-32']), ('include', ['1-32']), ('autohide', True)])), ('thermostat', OrderedDict([('enabled', False), ('exclude', ['1-16']), ('include', ['1-16']), ('autohide', True)])), ('keypad', {'exclude': [], 'include': ['1-16'], 'enabled': True, 'autohide': True}), ('value', {'exclude': [], 'include': ['1-20'], 'enabled': True, 'autohide': True})]), exception=, source=custom_components/elkm1.py>
2018-03-09 17:36:33 ERROR (MainThread) [homeassistant.setup] Error during setup of component elkm1
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/homeassistant/setup.py", line 148, in _async_setup_component
    component.setup, hass, processed_config)
  File "/usr/lib/python3.6/asyncio/futures.py", line 332, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.6/asyncio/tasks.py", line 250, in _wakeup
    future.result()
  File "/usr/lib/python3.6/asyncio/futures.py", line 245, in result
    raise self._exception
  File "/usr/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 147, in setup
    pyelk_instance = PyElk.Elk(elk_config, log=_LOGGER)
  File "/config/deps/lib/python3.6/site-packages/PyElk/Elk.py", line 182, in __init__
    include_range = self._list_from_ranges(self._config[device_class]['include'])
  File "/config/deps/lib/python3.6/site-packages/PyElk/Elk.py", line 804, in _list_from_ranges
    if '-' in ranges:
TypeError: argument of type 'int' is not iterable

More than happy to clone over a dev branch and help debug this; first looks and i dont think the enable code is present in the vast majority of modes

thx

Some more time, and edits; the config is loading, but despite trying to set enabled to false, and exclude to the full range, i am for example still observing Temperatures in the dev tools

elkm1:
  host: socket://172.16.1.253:2101
  area:
    exclude: 2-8
  zone:
    enabled: true
  output:
    exclude: 1-32, 41-208
  task:
    exclude: 1-32
  x10:
    exclude: a1-p16
  thermostat:
    exclude: 1-16
#  counter:
#   exclude: 1-64

In the logs, i am also seeing notimplemented errors around tasks.

regards
Damian

2018-03-09 17:30:06 ERROR (MainThread) [homeassistant.helpers.entity] Update for alarm_control_panel.elk_area_1 fails
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/helpers/entity.py", line 204, in async_update_ha_state
    yield from self.async_device_update()
  File "/usr/src/app/homeassistant/helpers/entity.py", line 327, in async_device_update
    yield from self.hass.async_add_job(self.update)
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 327, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 250, in _wakeup
    future.result()
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 243, in result
    raise self._exception
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/app/homeassistant/components/alarm_control_panel/elkm1.py", line 123, in update
    self._state = STATE_ALARM_PENDING
NameError: name 'STATE_ALARM_PENDING' is not defined
2018-03-09 17:30:06 ERROR (MainThread) [homeassistant.helpers.entity] Update for alarm_control_panel.elk_area_1 fails
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/helpers/entity.py", line 204, in async_update_ha_state
    yield from self.async_device_update()
  File "/usr/src/app/homeassistant/helpers/entity.py", line 327, in async_device_update
    yield from self.hass.async_add_job(self.update)
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 327, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 250, in _wakeup
    future.result()
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 243, in result
    raise self._exception
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/app/homeassistant/components/alarm_control_panel/elkm1.py", line 126, in update
    self._state = STATE_ALARM_TRIGGERED
NameError: name 'STATE_ALARM_TRIGGERED' is not defined
018-03-09 15:21:15 ERROR (MainThread) [homeassistant.helpers.entity] Update for alarm_control_panel.elk_area_1 fails
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/helpers/entity.py", line 204, in async_update_ha_state
    yield from self.async_device_update()
  File "/usr/src/app/homeassistant/helpers/entity.py", line 327, in async_device_update
    yield from self.hass.async_add_job(self.update)
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 327, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 250, in _wakeup
    future.result()
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 243, in result
    raise self._exception
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/app/homeassistant/components/alarm_control_panel/elkm1.py", line 113, in update
    elif (self._device._state == self._device.STATUS_ARMED_STAY_INSTANT):
AttributeError: 'Area' object has no attribute '_state'

Most of the issues you’ve seen are due to things fixed for the next release, but the last release was quite some time ago… I hadn’t considered whether someone would pass a single number to ‘include’ before so I’ll have to adjust that code to handle that as it’s not unreasonable especially for areas. The things showing in dev tools is expected for the current release, the new version that isn’t yet released tries harder to not even create entities for things that are not included (versus merely hiding them).

Thanks for the Tracebacks. Two of the three I’m certain are fixed, I’ll have to double check the one about STATE_ALARM_PENDING with actual testing but I think all three are already fixed.

Is any of this why the attribute of “Alarm” under the entity alarm_control_panel.elk_area_1 never seems to update? I was trying to use this attribute to determine if the alarm is sounding, but it seems to stay at “No Alarm Active” even when the alarm is going off.

1 Like

Most likely the cause.

@BioSehnsucht Just checking to see if you happen to have your dev code in a branch or repo, that i could validate on my Instance, and potentially assist with code/debugging. I have created an ELKM1 driver in C# and also in Node; for other platforms, so very comfortable with the protocol.
My Python is day 1 stuff i am afraid, but i am sure i can manage that

Damian