Mon-Sun : 9.00 AM – 5.00 PM

1170 Weston Road

Toronto, Canada

Have Any Question

(647) 873 8175

Send Your Mail

info@sharednotification.com

Procedure for Adding Shared-Notification to Home Assistant

Share This :

The first step to adding Neighbourhood Monitoring Centre to Home Assistant is to decide type of neighbourhood watch group/network.

With an API-Key and NID (optional), posting your alert to Shared-Notification server is very simple. For example, the server assigned you the following information:

NID: 1682389630392-42177

API-Key: 66c5b8a0-e30c-11ed-bc4f-053451ed971b

HID: 1682706990354-17286

You’ll also need to choose a broadcast name, address, and a non-specific address. This information will be display to your neighbours so care should be taken when choosing it.  Non-Specific Address are used in communities where retaliation is a strong possibility.

Broadcast Name (bcname): ELZINIE

Address (from): 123 Evergreen Terrace

Non-Specific Address (ns_address): 100 – 140 Evergreen Terrace

An example of how to share a PANIC alert with your community, create an automation where the automation is triggered when the panic button is a long_press. There is no condition on this automation.

The actions will be to execute a script to share this press with sharednotification.com, notify all devices, and turn_on siren for a specific duration and audio level.

The script uses the above information from the Share-Notification to communicate with it.

script.yaml
==================================================================================================

execute_sensor_alert:
  alias: Transmit SENSOR alert to SharedNotification server
  sequence:
  - service: rest_command.send_sensor_alert
    data:
      PAYLOAD_TYPE: SENSOR
      PAYLOAD_BCNAME: ELZINIE
      PAYLOAD_MSG: Sensor Alert Triggered
      PAYLOAD_TT: '{{ now().timestamp() | timestamp_custom(''%a %m-%d-%Y %-I:%M %p'')}}'
      PAYLOAD_HID: 1689789583296-98503
      PAYLOAD_LATITUDE: 43.788013441318974
      PAYLOAD_LONGITUDE: -79.66491194227804
      API_KEY: 66c5b8a0-e30c-11ed-bc4f-053451ed971b
  mode: single
 

scripts.yaml
==================================================================================================

execute_panic_alert:
  alias: 'Transmit PANIC alert to server'
  sequence:
  - service: rest_command.post_panic_request    
    data: 
      {"PAYLOAD_TYPE": PANIC, 
      "PAYLOAD_BCNAME": ELZINIE, 
      "PAYLOAD_MSG": Panic Alert Triggered, 
      "PAYLOAD_TT": "{{ now().timestamp() | timestamp_custom('%a %m-%d-%Y %-I:%M %p') }}",
      "PAYLOAD_HID": 1689789583296-98503, 
      "PAYLOAD_LATITUDE": 43.788013441318974, 
      "PAYLOAD_LONGITUDE": -79.66491194227804,
      "API-KEY": 66c5b8a0-e30c-11ed-bc4f-053451ed971b} 
  mode: single

automations.yaml
==================================================================================================

- id: '1689090843657'
  alias: handle_panic_button
  description: Send PANIC Alert to Shared-Notification server
  trigger:
  - device_id: 091f77a709485d572fbdcd2c8b2bab1b
    domain: zha
    platform: device
    type: remote_button_long_press
    subtype: button
  condition: []
  action:
  - service: siren.turn_on
    data:
      volume_level: 0.45
      duration: '60'
    target:
      device_id: 15ed99c05b3ffe4c768541d5e5246c1a
  - service: notify.mobile_app_mani_iphone
    data:
      message: Panic Alert was triggered - 44 Oklahoma Drive
      title: Neighbourhood Watch (ELZINIE) 
  - service: notify.mobile_app_noahs_iphone
    data:
      title: Neighbourhood Watch (ELZINIE)
      message: Panic Alert was triggered - 44 Oklahoma Drive
  - service: script.execute_panic_alert
    data:
      title: Neighbourhood Watch (ELZINIE)
      message: Panic Alert was triggered - 44 Oklahoma Drive
  - type: turn_off
    device_id: 49accc88f383f1ce7b6903b07e3f2a07
    entity_id: bf4aab00641bd93a005977e35f8b73b6
    domain: light
  mode: single
 

To receive updates from Shared-Notification server, you can either periodically request updates or the server can push updates to you when it’s available.   Updates are alerts from your neighbours who are in your neighbourhood network. You have the option to block update from any neighbour if desire.

For Shared-Notification to push updates to you, you need to create a webhook automation with HID be the webhook ID (webhook_id).

Automations.yaml
==================================================================================================

- alias: sharednotification will send neighbourhood alerts to this webhook
  trigger:
  - platform: webhook
    webhook_id: 1682706990354-17286
    allowed_methods:
    - POST
    local_only: true
  action:
  - service: notify.persistent_notification
    data:
      title: Neighbourhood Watch - {{ trigger.json.bcname }}
      message: '{{ trigger.json.msg }} - {{ trigger.json.from }}'
  - service: notify.mobile_app_mani_iphone
    data:
      title: Neighbourhood Watch - {{ trigger.json.bcname }}
      message: '{{ trigger.json.msg }} - {{ trigger.json.from }}'
  - service: siren.turn_on
    data:
      volume_level: 0.45
      duration: '15'
    target:
      device_id: 15ed99c05b3ffe4c768541d5e5246c1a

  id: 2465443cf382444f9e8d3a7dace8616d

For periodically requesting updates, you need to create a REST sensor with a long scan interval (scan_interval). This example uses a 1-year interval (31557600 seconds) and uses automation to force the periodical request for updates. Home Assistant uses homeassistant.update_entity to force reset.

automations.yaml
==================================================================================================

- alias: update_request
  trigger:
  - platform: time_pattern
    minutes: /1
  action:
  - service: homeassistant.update_entity
    entity_id: sensor.sharednotification
  - service: notify.mobile_app_mani_iphone
    data:
      message: '{{ state_attr(''sensor.sharednotification'',''msg'') }}'
      title: '{{ state_attr(''sensor.sharednotification'',''bcname'') }}'
  - service: persistent_notification.create
    data:
      message: '{{ state_attr(''sensor.sharednotification'',''msg'') }}'
      title: '{{ state_attr(''sensor.sharednotification'',''bcname'') }}'
  id: 45360775688a4f9ab39865aaa8f9ff9f 

sensor.yaml
==================================================================================================

- platform: rest
  name: sharednotification
  scan_interval: 31557600
  resource_template: "http://sharednotification.com/api/inbox/gethidanddelete?hid=1689789583296-98503&apikey=66c5b8a0-e30c-11ed-bc4f-053451ed971b"
  json_attributes:
      - bcname
      - message
      - from
      - msg
    value_template: '{{ value_json }}'