/ January 30, 2020/ Articles, Home Assistant/ 0 comments

I came across this post: https://github.com/cyberjunky/home-assistant-p2000

With this github you can create sensors in Home Assistant and get Dutch emergency messages for Ambulance, Fire department and (some) police. You can set a region and use cap codes. All credits to Cyberjunky for the coding of this project. The project has made his way to HACS, so it can be easily installed, otherwise follow the instructions on the github page for manual installation.

One of the issues i had is the sensors are working, but not filtered on street level but only on radius. Now that’s ok, but i am only interesseted in messaged in my street only, or for example my work.

First let’s create the sensors:

sensors: 
## first sensor for home
  - platform: p2000
    name: p2000_myhome
    regios: 17
    disciplines: 1,2,3
    radius: 200
    scan_interval: 60
    latitude: !secret latitude_myhome
    longitude: !secret longitude_myhome
## second sensor for work
  - platform: p2000
    name: p2000_mywork
    regios: 17
    disciplines: 1,2,3
    radius: 200
    scan_interval: 60
    latitude: !secret latitude_mywork
    longitude: !secret longitude_mywork

After creating this sensors, you can create an automation to filter the street and get a push notification to your mobile phone, in my case an IOS device.

- alias: 'Notify P2000 Bericht'
    trigger:
      - platform: state
        entity_id: sensor.p2000_myhome
      - platform: state
        entity_id: sensor.p2000_mywork
    condition:
     condition: or
     conditions:
       - condition: template
         value_template: "{{ 'YourHomeStreetName' in trigger.to_state.state }}"
       - condition: template
         value_template: "{{ 'YourWorkStreetName' in trigger.to_state.state }}"
    action:
      - service_template: notify.mobile_app_youriphone
        data_template:
          title: P2000 Bericht
          message: |
            {% if 'Traumaheli' in trigger.to_state.attributes.capcodes %}
            {{ "\uD83D\uDE81" }} Traumaheli
            {% elif 'Brandweer' in trigger.to_state.attributes.capcodes %}
            {{ "\uD83D\uDE92" }} Brandweer
            {% elif 'Politie' in trigger.to_state.attributes.capcodes %}
            {{ "\uD83D\uDE93" }} Politie
            {% elif 'Ambulance' in trigger.to_state.attributes.capcodes %}
            {{ "\uD83D\uDE91" }} Ambulance
            {% endif %}
            {{ trigger.to_state.state.split('Yourcity')[0] | replace ('','') | replace ('(DIA: ja)','')| replace ('(DIA: nee)','')| replace ('AMBU','Ambulance')| replace ('bon','') }}
            {{ as_timestamp(trigger.to_state.attributes.time) | timestamp_custom('%d %B %Y %H:%M')  }}
          data:
            push:
              category: map
            action_data:
              latitude: "{{ trigger.to_state.attributes.latitude }}"
              longitude: "{{ trigger.to_state.attributes.longitude }}"

I did made some split and replace changes to make the text more cleaner in the push notification. Als you can read i also created some nice emoticons in the push notification. You can read more here about Emoticons in a push notification for IOS.

At last be aware that conditions and text are case sensitive!

Share this Post

Leave a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>
*
*

seventeen + 7 =