Olarm integration

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.

That would be great if you can share. I just fumbled this together so if there is a better way, easier way or just a different way it would be great to see.

Thanks

HI Jason,

Can you maybe do a start to your of your process. I can see my full file view a curl command, but the sensors created from your earlier mail don’t pick up any data.

I’m not programmer, but I can see the logic in the way you query the json file, but I get no data. Your script should be easily moifyable to pick up almost all if I I coudl see my erro?

Any help appreciated from all parties,

Regards,
James

Using curl https://apiv4.olarm.co/api/v4/devices?accessToken=api_ACCESS_TOKEN provides the following output file (slighly sanistised).

{
    "page": 1,
    "pageLength": 40,
    "pageCount": 1,
    "search": "",
    "data": [{
        "deviceId": "XXXX-XXXX-XXXX-XXXX-XXXX",
        "deviceName": "Home",
        "deviceSerial": "AAANAN",
        "deviceAlarmType": "paradox",
        "deviceAlarmTypeDetail": null,
        "deviceTimestamp": 9999,
        "deviceStatus": "online",
        "deviceState": {
            "timestamp": 1675979853713,
            "cmdRecv": 0,
            "type": "",
            "areas": ["stay"],
            "areasDetail": [""],
            "areasStamp": [9999],
            "zones": ["c", "c", "c", "c", "c", "c", "c", "c", "c", "c", "c", "c", "c", "c", "c", "c"],
            "zonesStamp": [9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999],
            "pgm": ["c", "c", "c", "c", "c", "c", "c", "c"],
            "pgmOb": ["c", "c"],
            "ukeys": [],
            "power": {
                "AC": "1",
                "Batt": "1"
            }
        },
        "deviceProfile": {
            "areasLimit": 2,
            "areasLabels": ["House", "Garden"],
            "zonesLimit": 16,
            "zonesLabels": ["PIR", "PIR", "BEAM", "ROOM", "BEAM", "PIR", "PIR", "PIR", "BEAM", "BEAM", "DOOR", "Zone12", "Zone13", "Zone14", "Zone15", "Zone16", "Zone17", "Zone18", "Zone19", "Zone 20", "Zone 21", "Zone 22", "Zone 23", "Zone 24", "Zone 25", "Zone 26", "Zone 27", "Zone 28", "Zone 29", "Zone 30", "Zone 31"],
            "zonesTypes": [20, 20, 21, 20, 21, 20, 20, 20, 21, 21, 10, "", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            "pgmLimit": 8,
            "pgmLabels": ["Panic Radio", "Burglary Radio", "Status LED", "OpenClose Radio", "Output 05", "Output 06", "Output 07", "Output 08"],
            "pgmControl": ["000", "000", "000", "000", "000", "000", "000", ""],
            "pgmObLimit": 2,
            "pgmObLabels": ["", ""],
            "pgmObControl": ["000", "000"],
            "ukeysLimit": 4,
            "ukeysLabels": ["", "", "", ""],
            "ukeysControl": [0, 0, 0, 0]
        },
        "deviceTriggers": {
            "ver": 1,
            "lastCheck": 9999,
            "areasRemind": [
                [99, 9999],
                [0, 0]
            ],
            "zonesIdle": [0, 0],
            "zonesWatch": [
                [12, 0]
            ]
        },
        "deviceTimezone": "Africa/Harare",
        "deviceFirmware": "999.999"
    }]
}

I’m interested.

1 Like

Morning,

Have you created your sensors in HA as per my original post? Could you post a copy of that section in your configuration.yaml so we can take a look.

You an also browse to that URL instead of using curl and you will be able to see the actual numbering of your zones to make sure they are matching what is in your configuration.yaml.

A previous post in this thread mentioned issues with the sensors and after clearing up their configuration.yaml file things started working so you also need to make sure the format etc. of your file is correct and there are no issues.

Unfortunately I am also not a programmer so this has all been done through many hours of searching and reading many many posts and piecing things together but I can definitely try and help as best I can.

I am also interested in your solution Tim :grinning:

HI Jason,

configuration.yaml with your sensors is as follows:

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:
# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# http:
# base_url: X.X.X.X:8123

# Text to speech
tts:
  - platform: google_translate
#    language: 'en'

##### YAML File Locations ##################################
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
sensor: !include sensors.yaml


#########################################################
# OLARM INTEGRATION TRIAL
#########################################################
#### Olarm Data ####
rest:
  - resource: https://apiv4.olarm.co/api/v4/devices
    method: GET
    headers:
      Authorization: Bearer !secret olarm_api
    scan_interval: 5

    sensor:
    - name: OlarmName
      value_template: "{{ value_json.deviceName }}"
      unique_id: UniqueID-XXXX
    - name: getolarmstatus

      value_template: "{{ value_json.data[0].deviceState.areas[0] }}"

    - name: get-olarm-status
      value_template: "{{ value_json.data[1] }}"
    - name: OlarmStatus
      unique_id: UniqueID-XXXX-OlarmStatus
      value_template: "{{ value_json.data[7] }}"

#      value_template: "{{ value_json.data[0].deviceState.areas[0] }}"
#      value_template: >
#        {% if states('switch.upstairs_cam_motion_detection') == "On" %}
#          Motion Detected
#        {% else %}
#          No Motion Detected
#        {% endif %}  

    - name: Zone 01 - Olarm - BackdoorBeam
      value_template: "{{ value_json.data[0].deviceState.zones[0] }}"
      unique_id: XXXX-Zone01

    - name: Zone 02 - Olarm - Bedroom
      value_template: "{{ value_json.data[0].deviceState.zones[1] }}"

    - name: Zone 03 - Olarm - PoolBeam
      value_template: "{{ value_json.data[0].deviceState.zones[2] }}"

    - name: Zone 04
      value_template: "{{ value_json.data[0].deviceState.zones[3] }}"

    - name: Zone 05
      value_template: "{{ value_json.data[0].deviceState.zones[4] }}"

    - name: Zone 06
      value_template: "{{ value_json.data[0].deviceState.zones[5] }}"

    - name: Zone 07
      value_template: "{{ value_json.data[0].deviceState.zones[6] }}"

    - name: Zone 08
      value_template: "{{ value_json.data[0].deviceState.zones[7] }}"

    - name: Zone 09
      value_template: "{{ value_json.data[0].deviceState.zones[8] }}"

    - name: Zone 10
      value_template: "{{ value_json.data[0].deviceState.zones[9] }}"

    - name: Zone 11
      value_template: "{{ value_json.data[0].deviceState.zones[10] }}"

    - name: Zone 12
      value_template: "{{ value_json.data[0].deviceState.zones[11] }}"

    - name: Zone 13
      value_template: "{{ value_json.data[0].deviceState.zones[12] }}"

    - name: Zone 14
      value_template: "{{ value_json.data[0].deviceState.zones[13] }}"

    - name: Zone 15
      value_template: "{{ value_json.data[0].deviceState.zones[14] }}"

    - name: Zone 16
      value_template: "{{ value_json.data[0].deviceState.zones[15] }}"

#########################################################
## CAMERA SETTINGS
#########################################################
stream:
ffmpeg:

#########################################################
# SONOFF GENERIC CAMERA
#########################################################

camera:
  - platform: generic
    name: Sonoff_Camera
    still_image_url: http://192.168.20.30/jpg/image.jpg
    stream_source: rtsp://rtsp:[email protected]:554/av_stream/ch0

Balance is camera related and not causing errors.
I’m a real novice on this, so just can’t see the errors.

In states I see as below:

In settings entities, I get

image

Driving me insane.

and finally, blank sensor
image

Very interested Tim.