Olarm integration

The zone status’ are live and shown as a c - closed, a - active on the https://apiv4.olarm.co/api/v4/devices?accessToken=YourAccessKey

From my understanding the webhook function does no polling, it only receives messages from the API and if the triggers (I see it as filters) you added are included in the message received your automation is triggered. The current state of your alarm and all its sensors and pgms are however available and can be viewed on https://apiv4.olarm.co/api/v4/devices?accessToken=YourAccessKey I however have no experience converting the data to something usable - wonder if modifying the PAI integration is possible

I was able to pull all olarm data into sensors and poll the status on a reoccurring basis and created switches that post payloads back to the api from within Node-Red. I hope someone with some experience can build us a integration one day till then my make shift solution will suffice

Would you be able to share how you did this? I have very little experience with API’s and I’m struggling.

Hey man. Epic. Would u be willing to share your node red flow? (minus any sensitive information or course)

+1

It would be great to see how you did this as I have access to the API but have very little experience using them and right now have no idea how to go from here to pulling in the data as sensors. Would also be great to see your node red flows as mentioned above :slight_smile:

Right, hopefully this will help others.

After more searching and a lot of frustration I managed to put the below together which I added to my configuration.yaml and I now have sensors in HA for each of my zones (PIR, Door Contacts etc.) which I can use with things like automation’s.

My next step is to work out how to use Node-Red to be able to do what @Ko7Ad has done to create switches so I can do things like arm, disarm etc. from within HA.

A few things to note:

  • For the sensor name give it something meaningful such as Lounge PIR or Front Door so it is easy to identify in HA. This can’t be changed on the entity in HA.

  • For authorization add your API access key generated here (Olarm - User Portal) after Bearer without the quotations “”

  • The Zone number’s in the API start from 0 instead of 1 so just remember that when adding your zones. Example: Zone 16 in your Olarm configuration will be Zone 15 in the API.

  • The default scan interval is 30sec which you can adjust using the scan_interval option BUT I am not sure what is acceptable. 30sec is not going to be enough to use PIR’s in automation’s but I did drop this to 5sec to test and I was able to trigger alerts on my phone when a PIR was activated however I am not sure if polling ever 5sec is fine?

  • .deviceState.zones gives the following states - “a” = active, “c” = closed and “b” = bypassed

  • .deviceState.areas gives the following states - “notready”, “disarm”, “arm”, “sleep”, “stay”, “alarm”, “fire”, “emergency”, “countdown” and “arm”

I am sure there is a lot more that can be done based on the documentation (Olarm - User Portal) but this was the first big step for me to be able to poll the sensors for their current state.

This is an example of what I added to my configuration.yaml

rest:
  - resource: https://apiv4.olarm.co/api/v4/devices
    method: GET
    headers:
      Authorization: Bearer "your API key here without quotations"
    scan_interval: 30
    sensor:
    - name: Zone 1
      value_template: "{{ value_json.data[0].deviceState.zones[0] }}"
    - name: Zone 2
      value_template: "{{ value_json.data[0].deviceState.zones[1] }}"
    - name: Zone 3
      value_template: "{{ value_json.data[0].deviceState.zones[2] }}"
    - name: Zone 4
      value_template: "{{ value_json.data[0].deviceState.zones[3] }}"
    - name: Zone 5
      value_template: "{{ value_json.data[0].deviceState.zones[4] }}"
    - name: Zone 6
      value_template: "{{ value_json.data[0].deviceState.zones[5] }}"
    - name: Zone 7
      value_template: "{{ value_json.data[0].deviceState.zones[6] }}"
    - name: Zone 8
      value_template: "{{ value_json.data[0].deviceState.zones[7] }}"
    - name: OlarmStatus
      value_template: "{{ value_json.data[0].deviceState.areas[0] }}"

2 Likes

Hi Jason, just want to thank you for sharing your work with us. I used your config. yaml and i also have sensors to use in automations, if you figure out how to create switches will you also be so kind to share?

HI Jason and all,

So I managed to get API access and tried the above, but HA tells me I have a configuration error?

Invalid config for [rest]: [platform] is an invalid option for [rest]. Check: rest->rest->1->platform. (See /config/configuration.yaml, line 87).

Am I missing an earlier instruction or just being doff?

Any assistance appreciated.

Hi, happy to try and assist.

Are you able to provide a copy of your config so we can see what line 87 looks like as that seems to be where the issue is.

Hi Jason,

I should have thought of that above, below is the link to that part from my configuration.yaml

Not sure if there should be anything before/after? Was going to adjust names etc after.
Sorry newb, so not sure why dashes have changed to indents. (Fixed)

rest:
  - resource: https://apiv4.olarm.co/api/v4/devices
    method: GET
    headers:
      Authorization: Bearer : API KEY
    scan_interval: 30
    sensor:
    - name: Zone 1
      value_template: "{{ value_json.data[0].deviceState.zones[0] }}"
    - name: Zone 2
      value_template: "{{ value_json.data[0].deviceState.zones[1] }}"
    - name: Zone 3
      value_template: "{{ value_json.data[0].deviceState.zones[2] }}"
    - name: Zone 4
      value_template: "{{ value_json.data[0].deviceState.zones[3] }}"
    - name: Zone 5
      value_template: "{{ value_json.data[0].deviceState.zones[4] }}"
    - name: Zone 6
      value_template: "{{ value_json.data[0].deviceState.zones[5] }}"
    - name: Zone 7
      value_template: "{{ value_json.data[0].deviceState.zones[6] }}"
    - name: Zone 8
      value_template: "{{ value_json.data[0].deviceState.zones[7] }}"
    - name: OlarmStatus
      value_template: "{{ value_json.data[0].deviceState.areas[0] }}"

Thanks, James

Hi Jason,

Just deleted most of my configuration.yaml and this now provides zone entities.
Not sure what was wrong, but better now. Thanks for the info above, now to see why I don’t get anything onto a card if I trigger the zone.

Thank you so much for sharing this. The reason I bought Olarm was because I (incorrectly) thought it integrated with HA. So damn happy this is making progress! Can’t wait to get going on this…

Anyone wanna upvote the feature-request?

2 Likes

Hi Jason

Thanks for this brilliant post.

If i may ask is there any way you perhaps could assist in providing an example on how to perform a Post command to the Olarm API?

I do have the Olarm mobile app installed but it would be genius to be able to arm / disarm / bypass zones via automatons based on certain scenario’s.

I have been trying to read the API documentation but coding is definitely not my strong point

Thanks in advance for any assistance

Charl

Right, please don’t judge as I am new to Node-RED so there is probably a better way to do this and to share what I have done but here is what I have and it works :slight_smile:

I use these buttons on my dash which is brilliant as I can bypass any zone (was a mission to create a flow for each zone but its done now), I can put the alarm into stay, arm it and disarm it from HA.

I will post some code for a button I use to put the alarm into stay that updates automatically based on the alarm status so when its ready the button activates the Stay flow and then when the alarm status is in Stay the button automatically changes to Disarm so I can disarm when I want to.

My Node-RED config:

I created a flow for each action such as bypass, arm, disarm etc. and each flow looks like this:

What each node does:

  • The trigger is just there so I can test the flow from Node-RED without having to keep jumping back into HA
  • The button is what gets created in HA to trigger this flow (I will add pictures below on how to create the button’s)
  • The function node is what creates the message to inject with the Post Command. Example of a arm function which is added to the ‘On Message’ tab of the function node. You would change the “actionCmd” & “actionNum” based on what you want to do which you will find in the API Docs:
msg.payload = {
    "actionCmd": "area-arm",
    "actionNum": 1
}
return msg;
  • The HTTP Request node then puts it al together and there are a few things that need to be added here:
  • The debug node allows you to see the confirmation message that it was successful or if there were any errors
    • Output I use is .msg payload and debug window is selected.

Once that is setup and you have deployed the flow, if you click on the square on the left of the trigger you should receive a message in the debug window with ‘action status’ - OK. To find that window click on this button (took me a while to find it :slight_smile: )

Screenshot 2023-02-09 at 12.35.20

Below is what the button node config looks like:

  • Name - I chose something that would match the button I was creating in HA (Entity config)
  • Entity config - select add new ha-entity-config and then click the pencil

This is where you create the button

  • Name - this is what it will be called in HA
  • Server - this should automatically pull through if you are using the HA Add-On
  • Device - leave this as is
  • Type - button
  • Friendly name - I kept it the same
  • Icon - your choice :slight_smile:
  • When you click update it will close this window and the new button will show in the Entity config option in the first window of the Button Config

Here is the code for the state switch button I mentioned above - this is part of a dashboard where I am using a Grid Layout which is why you see view_layout in the code.

What this does is check the state of the alarm, in my case ‘sensor.olarmstatus’ and then based on that displays the required button.

  • When the alarm is notready, which I have also set to the default state so if the alarm is showing a state not defined in the code below it will revert to this state, then the button is yellow and has no actions.

  • When the alarm is in the disarm state the button changes to green with the label Stay so that when I press it the alarm goes into Stay.

  • When the alarm is in stay state the button is orange with the label Disarm.

For both Stay & Disarm actions I have a confirmation so that when you press it you have to then confirm the action to avoid any accidental activation’s.

type: custom:state-switch
show_header_toggle: false
view_layout:
  grid-area: tl
entity: sensor.olarmstatus
default: notready
states:
  notready:
    type: custom:button-card
    entity: sensor.olarmstatus
    show_state: false
    show_name: false
    show_icon: true
    hold_action:
      action: none
    tap_action:
      action: none
    icon: |
      [[[
         if ( states["sensor.olarmstatus"].state == 'arm') return 'mdi:shield-home';
         if ( states["sensor.olarmstatus"].state == 'disarm') return 'mdi:shield-home';
         if ( states["sensor.olarmstatus"].state == 'stay') return 'mdi:shield-home';
         else return 'mdi:shield-home';
      ]]]
    styles:
      card:
        - height: 150px
      icon:
        - color: |
            [[[
               if ( states["sensor.olarmstatus"].state == 'arm') return 'red';
               if ( states["sensor.olarmstatus"].state == 'disarm') return 'green';
               if ( states["sensor.olarmstatus"].state == 'stay') return 'orange';
               else return 'yellow';
             ]]]
  disarm:
    type: custom:button-card
    tap_action:
      action: call-service
      service: button.press
      target:
        entity_id: button.stay_olarm
      service_data:
        entity_id: button.stay_olarm
    confirmation:
      text: Confirm STAY?
    entity: sensor.olarmstatus
    name: Stay
    show_state: false
    show_name: true
    show_icon: true
    hold_action:
      action: none
    icon: |
      [[[
         if ( states["sensor.olarmstatus"].state == 'arm') return 'mdi:shield-home';
         if ( states["sensor.olarmstatus"].state == 'disarm') return 'mdi:shield-home';
         if ( states["sensor.olarmstatus"].state == 'stay') return 'mdi:shield-home';
         else return 'mdi:shield-home';
      ]]]
    styles:
      card:
        - height: 150px
      icon:
        - color: |
            [[[
               if ( states["sensor.olarmstatus"].state == 'arm') return 'red';
               if ( states["sensor.olarmstatus"].state == 'disarm') return 'green';
               if ( states["sensor.olarmstatus"].state == 'stay') return 'orange';
               else return 'yellow';
             ]]]
  stay:
    type: custom:button-card
    tap_action:
      action: call-service
      service: button.press
      target:
        entity_id: button.disarm_olarm
      service_data:
        entity_id: button.disarm_olarm
    confirmation:
      text: Confirm DISARM?
    entity: sensor.olarmstatus
    name: Disarm
    show_state: false
    show_name: true
    show_icon: true
    hold_action:
      action: none
    icon: |
      [[[
         if ( states["sensor.olarmstatus"].state == 'arm') return 'mdi:shield-home';
         if ( states["sensor.olarmstatus"].state == 'disarm') return 'mdi:shield-home';
         if ( states["sensor.olarmstatus"].state == 'stay') return 'mdi:shield-home';
         else return 'mdi:shield-home';
      ]]]
    styles:
      card:
        - height: 150px
      icon:
        - color: |
            [[[
               if ( states["sensor.olarmstatus"].state == 'arm') return 'red';
             if ( states["sensor.olarmstatus"].state == 'disarm') return 'green';
             if ( states["sensor.olarmstatus"].state == 'stay') return 'orange';
             else return 'yellow';
            ]]]



Hi Jason hope you are well :grinning:, firstly i want to thank you again for sharing your hard work with us and always willing to help. I followed your steps but seems to get this error on my hhtp request node do you maybe know what the problem can be? The API key is it the one for Olarm.

Thank you in advance.

If anyone is interested, I have managed to get Olarm fully integrated into my HA.
I created a dashboard where I can Arm, Disarm, Stay for my areas.
I also have a dashboard showing the current states of all the zones (Closed, Active, Alarm, etc).
I also get events from Olarm (Power Failure, Alarms, etc).
So I do a bit of automation with these events.

I am happy to share my solution, not using node-red, but rather making use of templating simple sensors.

1 Like

:slight_smile: Glad I can be of some help as these forums are the only reason I have been able to make it this far so nice to be able to give back.

Yes, the API key you get from your Olarm account under the API page.

The device ID you need to her by going to

https://apiv4.olarm.co/api/v4/devices?accessToken=APIKEY

If you can show what your config for the http request node is I can try spot what the error is.