I came across this post: https://github.com/cyberjunky/home-assistant-p2000
(This project is not working any more as the scraper data P2000 stopped working)
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!
Hoi ,
Weet je of onderstaande ook mogelijk is ?
Weet iemand of je de output van een p2000 sensor kan aanpassen als je deze wilt laten uitspsreken op bv een google mini bv deze output:
“A2 (DIA: ja) AMBU 17132 Steenplaats 3131PX Vlaardingen VLAARD bon 121722″ nu worden ook de getallen uitgesproken en dat is niet echt nodig zou zoiets kunnen zijn als dit ” Ambulance met gepaste spoed naar Steenplaats” of als het een A1 is “met spoed”
Hi Henk,
Jou zou een beetje met de template editor moeten spelen.
Je kan namelijk met een value template wel eea voor elkaar krijgen.
Als je dus met Google in de data_template message zoiets zegt:
{% if 'AMBU' in states.sensor.p2000_sensor.state %}
Ambulance naar {%endif%}{{states.sensor.p2000_sensor.state.split(" ")[3] }} in {{states.sensor.p2000_sensor.state.split(" ")[5] }}
En wellicht wil je nog iets met een ‘elif’ en ‘else’ doen voor brandweer e.d
Suc6