ELK M1 Interface

I think I’m quoting the JSON correctly:

{
  "entity_id": "alarm_control_panel.home",
  "line1": "Mist",
  "line2": "65.8 deg F",
  "clear": 2,
  "beep": 0,
  "timeout": 0
}

Here’s the code I used to generate it, if it helps

entity_id = "alarm_control_panel.home"
line1 = msg.payload.weather
line2 = Number.parseFloat(msg.payload.tempc * 9/5 + 32).toFixed(1) + " deg F"
clear = 2
beep = 0
timeout = 0
var newMsg = { "payload": {"entity_id": entity_id, "line1": line1, "line2": line2, "clear": clear, "beep": beep, "timeout": timeout }}
return newMsg;

I’m not sure what to suggest; I just am not that familiar with Node Red for specific suggestions. Take a look at the Home Assistant log and see if it’s complaining about the service calls.

At the risk of sending you way off into the weeds, you can monitor the Home Assistant event bus and see the service calls happening. One way that I do this using hass-cli at the shell like this:

hass-cli event watch call_service

which will produce stuff like this as output:

event_type: call_service
data:
    domain: light
    service: turn_on
    service_data:
        effect: None
        brightness: 255
        entity_id:
           -  light.nightlight2
origin: LOCAL
time_fired: '2020-12-25T03:45:29.727348+00:00'
context:
    id: ae4b57bf05cf523d53f18fd6a7f0c00c
    parent_id:
    user_id: fe4dbd3e9ffe4f868250319aab00bc8f

event_type: call_service
data:
    domain: mqtt
    service: publish
    service_data:
        topic: 19916/nightlight2/light/light/command
        qos: 1
        retain: false
        payload: '{"state": "ON", "brightness": 255, "effect": "None"}'
origin: LOCAL
time_fired: '2020-12-25T03:45:29.728548+00:00'
context:
    id: ef9e9e0838ec50c0dfdea201939ae0eb
    parent_id:
    user_id:

which could show you how the service calls land in Home Assistant.

EDIT: Oh, it looks like this same sort of thing is available on the Developer Event tab there at the bottom! How about that… No need install the python CLI client just for this…

I fear this now more a Node Red question than an Elk question; perhaps there’s another category focused on Node Red where you could reach those with more expertise? I’m sure this is probably something simple…

I figured it out. It was a matter of me not fully understanding node-red. The trick was to create the payload just like I was. No problems with the function node. But in the call service node, the trick was to fill out the fields like this:

Domain: elkm1
Service: alarm_display_message
Entity ID: alarm_control_panel.home
Data:

{
  "line1": "{{payload.line1}}",
  "line2": "{{payload.line2}}",
  "clear": "{{payload.clear}}",
  "beep": "{{payload.beep}}",
  "timeout": "{{payload.timeout}}"
}

Thanks for the help!!!

Here’s the whole flow, if anyone wants it.

[{"id":"950a7e3b.2f98c","type":"api-call-service","z":"f261dcc3.e0057","name":"Display the weather","server":"3e7f7522.9e5aea","version":1,"debugenabled":true,"service_domain":"elkm1","service":"alarm_display_message","entityId":"alarm_control_panel.home","data":"{   \"line1\": \"{{payload.line1}}\",   \"line2\": \"{{payload.line2}}\",   \"clear\": \"{{payload.clear}}\",   \"beep\": \"{{payload.beep}}\",   \"timeout\": \"{{payload.timeout}}\" }","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":530,"y":340,"wires":[["9a6475a3.0b8e98"]]},{"id":"3e7f7522.9e5aea","type":"server","name":"Home Assistant","addon":true}]
1 Like

Just a couple days into this. Trying to add the missing “Arm Night Mode” which strangely is not present in the UI. There are “services” to set this mode, but in Developer Tools when I try to use these services, they just error out with “Unknown error”. It seems like maybe it is missing an entity id, but the Developer Tools doesn’t indicate that. Obviously, I don’t know what I’m doing.

Once I call a service, I assume somehow I’ll be able to add a button to the Dashboard or use an Automation to confirm arm night with an actionable notification at say 8pm. Anyway, the big question is how to call things like alarm_control_panel.alarm_arm_home or elkm1.alarm_arm_night_instant without errors and then how to invoke that from the dashboard?

Welcome to the community @jword. Here’s an automation I used to automatically arm the alarm at night when the reading light is turned off. Maybe you are missing the required “code” to arm?

- id: arm_alarm_night_lamp_off
  alias: "Arm the alarm at night when reading lamp turns off"
  
  trigger:
    platform: event
    event_type: isy994_control
    event_data:
      entity_id: light.controllinc_4
      control: 'DOF'
  condition:
    - condition: time
      after: "21:00:00"
      before: "02:00:00"
    - condition: template
      value_template: '{{ is_state_attr("alarm_control_panel.home","arm_up_state", "ready_to_arm") }}'
  action:
    - service: alarm_control_panel.alarm_arm_night
      entity_id: alarm_control_panel.home 
      data:
        code: !secret elk_pin

As a follow-up, I want to know if the alarm wasn’t able to automatically arm using this automation:

- id: warn_unable_arm_alarm
  alias: "Warn if unable to arm the alarm at night"
  
  trigger:
    platform: event
    event_type: isy994_control
    event_data:
      entity_id: light.controllinc_4
      control: 'DOF'
  condition:
    - condition: time
      after: "21:00:00"
      before: "02:00:00"
    - condition: template
      value_template: '{{ is_state_attr("alarm_control_panel.home","arm_up_state", "not_ready_to_arm") }}'
  action:
    - service: tts.google_translate_say
      entity_id:
        - media_player.bedroom_speaker
      data_template:
        message: 'Unable to arm the alarm. The {% for entity_id in states.group.alarm_zones.attributes.entity_id if is_state(entity_id, "Violated") %}{% if loop.first and loop.last %}{{ state_attr(entity_id, "friendly_name") }} is still open.{% else %}{% if loop.last %} and {% elif loop.first %}{% else %}, {% endif %}{{ state_attr(entity_id, "friendly_name") }}{{ " are still open" if loop.last }}{% endif %}{% endfor %}'

Hope that helps!

entity: alarm_control_panel.area_001
states:
  - arm_night
  - arm_home
  - arm_away
type: alarm-panel

Check your card config to see if the state you want is configured

Hey @bdraco hoping you can help me here. I just noticed that disarm is no longer working for me (2021.8.8 version). I’ve tested the elkm1-lib and its working fine. Something about the integration not working that doesn’t make sense to me. When in lovelace I enter my 4 digit code then click disarm I get this:

Logger: homeassistant.components.websocket_api.http.connection
Source: components/elkm1/alarm_control_panel.py:225
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 19:06:10 (2 occurrences)
Last logged: 19:06:34

[140569385421360] int() argument must be a string, a bytes-like object or a number, not 'NoneType'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 185, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1491, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1526, in _execute_service
    await handler.job.target(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
    await self.hass.helpers.service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 658, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 856, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 695, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/elkm1/alarm_control_panel.py", line 225, in async_alarm_disarm
    self._element.disarm(int(code))
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

Which, to me, means that the code is not getting down to my service call, which further means that the problem is upstream from there, and that’s above my pay grade :wink:

Any wisdom? Anyone else not being able to disarm? Arming works form me, only tried away mode.

False “alarm”??? Today disarm works as it should. This is my production system so everything from released HA code. Odd. It happened repeatedly yesterday.

If anyone else sees this please post here.

It looks like the code wasn’t being passed to the service from the UI. Maybe some type of caching issue on the frontend that resolved when you reloaded today?

I’m definitely a noob to Home Assistant but got the M1 interface working for a number of features (motion sensors triggering events, controlling M1 outputs, etc). I’m trying to figure out how to get the armed state to interact with Home Assistant. I tried adding a counter that was set to a specific value based on the state, but I am not seeing the value change. Any suggestions? Docs to read?

Welcome to Home Assistant. You should have an entity named something like: alarm_control_panel.area_001

You can set up automations for values equal to:

armed_home
armed_night
armed_away
disarmed

And probably some more. I use Node Red for this, but automations in HASS will work as well.

Also, FWIW, things that are super critical (like closing the water valve in case of flood) I try to do in the ELK automations so they will happen even if my HASS is down.

2 Likes

Great information Richard.
@iprowell, It can be a bit confusing if you’re just getting started with HA (HomeAssistant), but it is simple enough you can pick it up quickly. Just remember one thing as you begin, as it will make your life much easier in the long run. Always build into your devices (plugs, ELK M1G, etc) their own logic, and only use Home Assistant to enhance it.
What I mean by that is make your devices completely usable without Home Assistant, or at least as much as you can, then use Home Assistant to combine their functionality and make them better.
If you rely on any external systems to make things run properly (HA, Alexa< Google Assistant), and one of them is down, your devices will suffer as well.
Enjoy!!

1 Like

Has anyone animated the icons associated with their ELK M1 sensors? For example: a door sensor that has a door icon that shows closed when the sensor is normal, open when violated, red when trouble, something else for bypassed. I think the Template integration is an option but wanted to know if anyone has an example or used another way to do this.

You shouldn’t need to use a template sensor (or switch, etc.) to do this. This is just a UI thing, and within the Lovelace UI in Home Assistant, there area bunch of ways to customized the dashboards that you can build. I’ve not spent much time doing this myself, so I do not have specific advice for you. Mostly, I just wanted to point you towards the right direction, rather than going off into the weeds needlessly.

The Lovelace UI ecosystem is large and flexible. This is both a powerful option to have, as well as a curse.

For example, there’s a third-party “custom button” card which is a jack of all trades and gives you lots of options to customize aspects of it based on the state of an entity. Different icons, or application of CSS styles conditionally. I’m not suggesting this is the best path for you, just to illustrate one possibility.

You might poke around in the Lovelace & Frontend category for some ideas. There may be less complex ways of having the UI elements use variable icons depending on the state of the entity.

Thanks very much for the suggestions.

Thanks for the pointers. I am stumbling my way through and making what I think is good progress. I’m trying to keep as much as possible strictly on the Elk and use HA to extend things. It looks like the generic alarm interface combined with the Elk-specific components creates the functionality I am looking for. I will try to post more information once I get things stable.

Where can I find a list of values for the alarm_state attribute? Just trying to trigger a few specific automations in the cases of interior alarm and fire alarm but not wanting to just use a template to report the alarm_state value. Sorry if this is posted already–have been searching for a while and haven’t found it yet. Or is there a better way to trigger for each of these events?

The states and statuses are the lower case of these: elkm1/const.py at e84865b6b3a6d4ba1d062eefcada44c123180b9a · gwww/elkm1 · GitHub

Is there any way to send information back to the ELK? Such as, I have wired contacts on all my doors. One has failed, so as an interim solution I have a wireless switch monitored by HA. I would like to send the ‘chime’ signal when that door is open.
Suggestions?

There is no way to do this with the protocol that talks to the ElkM1. What you could play with though is an automation on the Elk itself… say when Task “x” is activated then beep keypad. I don’t know how good that automation is on the Elk as the automation options are to “start beeping” and “stop beeping”. That may not be fine grained enough to get the beep length that you want.

If you can make the automation on the Elk work as you please you can trigger the automation from HA with “activate scene”.

Let us know what you discover!