Control alarm with http postd

Good Day community.
I am new to HA, I am a software developer by profession, so I was hoping I would pick up HA quickly. However, I have really been struggling so far, everything I have tried to do I have not come right. My Ezviz cameras won’t login, I cant find a sonoff integration, my victron solar I can’t get to work with the energy dashboard. It really not intuitive and everything is config files.

Anyway I assume there is just a steep learning curve, so I thought let me start with some thing simple.

What I am looking to do is integrate our security alarm system with HA. So the alarm has an Http API.

So I can call:

  • post: http:// alarmapi/disarm/{id}
  • post: http:// alarmapi/awayaway/{id}
  • post: http:// alarmapi/stayarm/{id}
  • Get: http:// alarmapi/status

How would I start out getting this integration done?

Just with a simple button on a dashboard? That makes that call.

You can use a restful switch.

Regarding Sonoff.
I use HACS and Sonoff LAN.

Thanks for this, This is a good start,

Can you help me understand layout wise?

How do I make an entity called alarms that has actions?

So

Alarm{
Actions: {
ArmAway
ArmStay
Disarm}

Status: {armedAway, disarmed, armedStay

}

switch:      # only if it doesn't exist already in your config
  - platform: rest
    resource: http://alarmapi/disarm/{id}
    name: "Alarm disarm"

  - platform: rest
    resource: http://alarmapi/awayaway/{id}
    name: "Alarm arm_away"

I believe this should work.
But I guess there is some auth parameters you need to add also

1 Like

Good day,

I believe I have eventually managed to map some sort of a request:

here it is:

switch:
  # Sprinkler-1
  - platform: rest
    name: "Sprinkler-1"
    resource: https://api.relay/execute
    method: POST
    username: "{username}"
    password: "{password}"
    body_on: '{"SerialNumber":"1234","RelayNumber":1,"RelayCommand":1}'
    body_off: '{"SerialNumber":"1234","RelayNumber":1,"RelayCommand":0}'
    headers:
      Content-Type: application/json
    verify_ssl: true

image
I then made a button on the dashboard.

How can I debug this? When I click the button nothing happens, Where Can I see the response or the HTTP error code etc?a

Probably in the log.

I’m not seeing anything there. Which is super odd.

If I put this exact request into post man it works fine.