Skip to content

Home Assistant Integration

Luca Mazzilli edited this page Sep 27, 2021 · 5 revisions

Enable/disable discovery

To use home assistant make sure that discovery is enabled in config.json (default is true):

"hadiscovery": {
    "enabled" : true
   [...other properties]
}

Settings:

Optionally you can edit "hadiscovery" and topic structure (code, zone name prefix, icons etc) in config.json.

By changing "zones" you can define custom behaviour for devices. In this example i changed the water leak sensor (zone 16) to report a Normally Open (NO) contact type, with device class "moisture" (see HA wiki for device_class info), and i forced the sensor to use the "open" property as status for binary sensor.

    "zones": {
        "16": {
            "contactType": "NO",
            "device_class": "moisture",
            "statusProperty": "open"
        }
    }

Custom sensor (template)

every binary_sensor reports this data (example: binary_sensor.zona_1_ingresso):

alarm: false
bypass: false
fault: false
id: 1
lastChecked: '2021-02-17T16:05:49.290Z'
lowbat: false
message: OK
name: Ingresso
ok: true
open: false
problem: false
status: '0'
type: Ritardata
friendly_name: Zona 1 Ingresso
device_class: door

you can use home assistant template sensors to define a sensor o binary_sensor you may need:

binary_sensor:
  - platform: template
    sensors:
      sun_up:
        friendly_name: "Door Battery"
        value_template: >-
          {{ state_attr('binary_sensor.zona_1_door', 'lowbat')}}

Alarm last event

sensor.ialarm_last_event reports the last event (that you can check in the alarm webui http://192.168.1.x/SystemLog.htm). Usually this is a string with date that reports:

  • alarm trigger/cancel/armed/disarmed
  • sensor error (connectivity problem)
  • sensor tamper
  • sensor battery low
  • power line failure

You can use it in an automation to send the content via telegram, HA notifications, etc.

Entities card:

To check if a sensor is reporting activity (open, error, battery low, etc) you can configure on lovelace an entity-filter

card:
  show_header_toggle: false
  title: Sensors reporting OPEN
  type: entities
entities:
  - binary_sensor.zona_1_name
  - binary_sensor.zona_2_name
  - binary_sensor.zona_3_name
  - binary_sensor.zona_4_name
  - binary_sensor.zona_5_name
  - binary_sensor.zona_6_name
  - binary_sensor.zona_7_name
  - binary_sensor.zona_8_name
  - binary_sensor.zona_9_name
  - binary_sensor.zona_10_name
show_empty: false
state_filter:
  - 'on'
type: entity-filter

scripts:

you can use scripts to do stuff

cancel a triggered alarm (without removing armed state)

    ialarm_cancel:
      alias: Cancella notifica antifurto
      sequence:
          service: mqtt.publish
          data:
            topic: ialarm/alarm/set
            payload: cancel
            qos: 2

automations:

last event notification:

this sends you via notify.telegram the last event string (you can use any other kind of notification provider):

- id: eventi-antifurto
  alias: Eventi antifurto
  trigger:
     platform: state
     entity_id: sensor.ialarm_last_event
  action:
    service: notify.telegram
    data_template:
      message: >
        Notifica dall'antifurto: {{ trigger.to_state.state }}  

send some snapshots from your ip camera on alarm disarmed or triggered

script.ip_camera_snapshots is your user defined script that actually sends images, I won't describe here how to do it.

- id: allarme_disabilitato
  alias: Snapshot se Allarme disarmed/triggered
  trigger:
  - entity_id: alarm_control_panel.ialarm
    platform: state
    from: armed_away
    to: disarmed
  - entity_id: alarm_control_panel.ialarm
    platform: state
    from: armed_home
    to: disarmed    
  - entity_id: alarm_control_panel.ialarm
    platform: state
    to: triggered
  action:
    - service: script.ip_camera_snapshots