cyberjunky / home-assistant-p2000

:fire_engine: This component tracks P2000 emergency events in The Netherlands.
MIT License
55 stars 9 forks source link
custom-component emergency hacs home-assistant homeassistant p2000 python

hacs_badge made-with-python Donate

P2000 Sensor Component

NOTE:

We now use a new RSS feed service provided by Erwin from http://p2000.brandweer-berkel-enschot.nl/ thanks! Hence this version is in beta state.

P2000 Sensor Component

This is a Custom Component for Home-Assistant (https://home-assistant.io) that tracks P2000 emergency events in The Netherlands.

About

This component queries http://p2000.brandweer-berkel-enschot.nl/ at the configured interval and applies filters for range (if lat/lon is available), discipline(s) and regio(s) set.

When events are found the P2000 sensor state gets set, which you can use to trigger automation, display sensor data, and even plot location on the map.

Installation

HACS - Recommended

Manual

Usage

To use this component in your installation, add the following to your configuration.yaml file:

# Example configuration.yaml entries

sensor:
  - platform: p2000
    scan_interval: 20
    capcodes: 1403001,1403003
    icon: mdi:fire-truck
    nolocation: true

  - platform: p2000
    name: Amsterdam
    regios: 13
    disciplines: Politiediensten
    radius: 10000
    scan_interval: 10
    latitude: 52.3680
    longitude: 4.9036

Configuration variables:

NOTE: Regarding capcodes; Make sure you specify the correct matching regio(s) in your config and remove leading 0's ie. capcode 0100001 is received as 100001

You can use a state trigger event to send push notifications like this:

# Example automation.yaml entry

automation:
  - alias: 'P2000 Bericht'
    trigger:
      platform: state
      entity_id: sensor.p2000
    condition:
      alias: "Time 07~23"
      condition: time
      after: "07:00:00"
      before: "23:00:00"
    action:
      - service_template: notify.html5
        data_template:
          title: P2000 Bericht - {{ state_attr('sensor.p2000', 'discipline') }}
          message: >
            {{ states('sensor.p2000') }} (Capcode: {{ state_attr('sensor.p2000', 'capcode') }})
          data:
            # iOS URL
            url: "https://www.google.com/maps/search/?api=1&query={{ state_attr('sensor.p2000', 'latitude') }},{{ state_attr('sensor.p2000', 'longitude') }}"
            # Android URL
            clickAction: "https://www.google.com/maps/search/?api=1&query={{ state_attr('sensor.p2000', 'latitude') }},{{ state_attr('sensor.p2000', 'longitude') }}"

Above is for html5 notify, you can click the notify message to open google maps with the lat/lon location if available in the P2000 message.

Screenshots

alt text alt text alt text

Lovelace card example:

cards:
      - entity: sensor.p2000
        name: P2000 Dordrecht
        type: sensor
      - entity: sensor.amsterdam
        icon: 'mdi:fire-truck'
        name: P2000 Amsterdam
        type: sensor
      - default_zoom: 7
        entities:
          - entity: sensor.p2000
          - entity: zone.home
          - entity: sensor.amsterdam
        title: P2000 Dordrecht & Amsterdam
        type: map

Debugging

If you experience unexpected output, please create an issue. Share your configuration and post some debug log info. You can obtain this by adding this line to your config and restart homeassistant.

logger:
  default: info
  logs:
      custom_components.p2000: debug

Donation

Donate