cyberjunky / home-assistant-p2000

:fire_engine: This component tracks P2000 emergency events in The Netherlands.
MIT License
55 stars 9 forks source link

Location missing #3

Closed Zendio closed 4 years ago

Zendio commented 4 years ago

Since the capcode update, I no longer receive the location of an event. Checked after multiple events.

Current state: longitude: 0 latitude: 0 distance: 0 capcodes: time: 2020-01-07T07:52:35 attribution: Data provided by feeds.livep2000.nl friendly_name: P2000

my sensor configuration:

Rebooting doesn't solve the issue.

cyberjunky commented 4 years ago

I will have a look with your regio setting, I just checked mine, and I still have it working with my regio. Not all messages seem to contain a location, but those are very rare. I assume you run version 1.0.5 from hacs? Screenshot from 2020-01-07 19-00-55

Zendio commented 4 years ago

Yes, I'm using the latest version.

Screenshot 2020-01-07 at 19 07 59

cyberjunky commented 4 years ago

I have it running with:

 - platform: p2000
   regios: 20
   radius: 40000

And see this in my logs:

2020-01-07 20:48:51 DEBUG (MainThread) [custom_components.p2000.sensor] New emergency event found.
2020-01-07 20:48:51 DEBUG (MainThread) [custom_components.p2000.sensor] Calculated distance 22775 meters, max. range 40000 meters
2020-01-07 20:48:51 DEBUG (MainThread) [custom_components.p2000.sensor] Text: P 2 INCI-02 Dienstverlening Amarant groep Leuvenaarstraat Breda 203151
Tue, 07 Jan 2020 20:48:54 +0100
, Time: 2020-01-07 20:48:54, Lat: 51.5887178, Long: 4.7661673, Distance: 22776
2020-01-07 20:48:51 DEBUG (MainThread) [custom_components.p2000.sensor] State updated to P 2 INCI-02 Dienstverlening Amarant groep Leuvenaarstraat Breda 203151
Tue, 07 Jan 2020 20:48:54 +0100

And got the lat/long... Screenshot from 2020-01-07 20-49-47

Can you enable debug log and see what it shows?

logger:
  default: info
  logs:
      custom_components.p2000: debug
cyberjunky commented 4 years ago

Just got one with 0 lat/long:

2020-01-07 21:05:23 DEBUG (MainThread) [custom_components.p2000.sensor] New emergency event found.
2020-01-07 21:05:23 DEBUG (MainThread) [custom_components.p2000.sensor] Calculated distance 33575 meters, max. range 40000 meters
2020-01-07 21:05:23 DEBUG (MainThread) [custom_components.p2000.sensor] New emergency event found.
2020-01-07 21:05:23 DEBUG (MainThread) [custom_components.p2000.sensor] Text: A2 : Hyssopstraat Tilburg rit: 2135 (Directe inzet: ja) eh: 20142
Tue, 07 Jan 2020 21:02:13 +0100
, Time: 2020-01-07 21:04:28, Lat: 0.0, Long: 0.0, Distance: 0
2020-01-07 21:05:23 DEBUG (MainThread) [custom_components.p2000.sensor] State updated to A2 : Hyssopstraat Tilburg rit: 2135 (Directe inzet: ja) eh: 20142
Tue, 07 Jan 2020 21:02:13 +0100

The feed shows geo data for this address, but not the one before that, maybe that is the issue. Need to check this

<item>
<title>
<![CDATA[
A2 VWS Gilze : VWS Gilze Broekakkerweg Gilze rit: 2137 eh: 20123
]]>
</title>
<link>
https://www.livep2000.nl/monitor/?SPI=2001072104280220
</link>
<pubDate>Tue, 07 Jan 2020 21:04:28 +0100</pubDate>
<description>
<![CDATA[
1220623 MKA Midden en West Brabant ( Ambulance 20-123 Breda-Noord )<br/>1220499 MKA Midden en West Brabant ( Monitorcode )<br/>
]]>
</description>
<guid>2001072104280220</guid>
<author/>
</item>
<item>
<title>
<![CDATA[
A2 : Hyssopstraat Tilburg rit: 2135 (Directe inzet: ja) eh: 20142
]]>
</title>
<link>
https://www.livep2000.nl/monitor/?SPI=2001072102130220
</link>
<pubDate>Tue, 07 Jan 2020 21:02:13 +0100</pubDate>
<description>...</description>
<guid>2001072102130220</guid>
<author/>
<geo:lat>51.5767976</geo:lat>
<geo:long>5.0332876</geo:long>
</item>
Zendio commented 4 years ago

From the last 5, 2 show lat/long data. So it still works, but not as well as it used to or maybe it's just unlucky. I'll do the debug thing as you asked.

Zendio commented 4 years ago

I'd say it's about 50/50 for showing the location. It's probably just the RSS feed I guess. I'm going to close the issue.

cyberjunky commented 4 years ago

It might be a bug, I loop through the messages, if some are received at the same time the lat/long of the previous one gets overwritten by 0,0 from the next (reset of values) I think. Need to have a closer look.

metbril commented 4 years ago

I have something similar. An update with lat/lon of 0 where the rss feed has values. The first item at 14:02:28 (last in the source) has a lat/lon and was available in HA. The next one shown is that of 14:04:16. That one had both a lat/lon of '0' (zero). There are 2 items in the feed with that timestamp. Both have the same lat/lon as the first one.

sensor:
  - platform: p2000
    name: P2000 Brandweer
    regios: 17                  # rotterdam rijnmond
    disciplines: 1              # brandweer
    radius: 30000                # meter, default 5000
    scan_interval: 60           # seconden, default 30

So 3 things to investigate why lat/lon are 0:

  1. lat/lon is the same as previous item
  2. 2 identical messages with same timestamp in feed
  3. filtered messages?
    <item>
      <title><![CDATA[P 2 Herbez./Kazern. (INCI-03) Kazerne Baan Rotterdam SK05]]></title>
      <link>https://www.livep2000.nl/monitor/?SPI=2001171405150117</link>
      <pubDate>Fri, 17 Jan 2020 14:05:15 +0100</pubDate>
      <description><![CDATA[1400999 BRW Rotterdam-Rijnmond ( Monitorcode )<br/>1400223 BRW Rotterdam-Rijnmond ( Vrijwilligers Frobenstraat )<br/>1400222 BRW Rotterdam-Rijnmond ( Bevelvoerder Post Frobenstraat )<br/>]]></description>
      <guid>2001171405150117</guid>
      <author/>
      <geo:lat>51.9132119</geo:lat>
      <geo:long>4.4804341</geo:long>
    </item>
    <item>
      <title><![CDATA[A1 AMBU 17123 Laan op Zuid 3072DB Rotterdam ROTTDM bon 8097]]></title>
      <link>https://www.livep2000.nl/monitor/?SPI=2001171404260217</link>
      <pubDate>Fri, 17 Jan 2020 14:04:26 +0100</pubDate>
      <description><![CDATA[1420999 MKA Rotterdam-Rijnmond ( Monitorcode )<br/>1420023 MKA Rotterdam-Rijnmond ( MotorAmbulance 17-323 )<br/>]]></description>
      <guid>2001171404260217</guid>
      <author/>
      <geo:lat>51.9075659</geo:lat>
      <geo:long>4.4943832</geo:long>
    </item>
    <item>
      <title><![CDATA[Op dit moment is er een opschaling binnen UW aandachtsgebied.]]></title>
      <link>https://www.livep2000.nl/monitor/?SPI=2001171404180117</link>
      <pubDate>Fri, 17 Jan 2020 14:04:18 +0100</pubDate>
      <description><![CDATA[1400887 BRW Rotterdam-Rijnmond ( Clustercommandant Maas )<br/>]]></description>
      <guid>2001171404180117</guid>
      <author/>
    </item>
    <item>
      <title><![CDATA[P 1 Gebouwbrand woning (INCI-02) (Ops Br: middel) (Etage: 5) Laan op Zuid Rotterdam 179192]]></title>
      <link>https://www.livep2000.nl/monitor/?SPI=2001171404160317</link>
      <pubDate>Fri, 17 Jan 2020 14:04:16 +0100</pubDate>
      <description><![CDATA[1430030 Politie Rotterdam-Rijnmond ( Persinformatie Brandweer )<br/>1430020 Politie Rotterdam-Rijnmond ( Persinformatie Politie )<br/>]]></description>
      <guid>2001171404160317</guid>
      <author/>
      <geo:lat>51.9070947</geo:lat>
      <geo:long>4.4962528</geo:long>
    </item>
    <item>
      <title><![CDATA[P 1 Gebouwbrand woning (INCI-02) (Ops Br: middel) (Etage: 5) Laan op Zuid Rotterdam 179192]]></title>
      <link>https://www.livep2000.nl/monitor/?SPI=2001171404160117</link>
      <pubDate>Fri, 17 Jan 2020 14:04:16 +0100</pubDate>
      <description><![CDATA[1400999 BRW Rotterdam-Rijnmond ( Monitorcode )<br/>1400874 BRW Rotterdam-Rijnmond ( Voorlichter van Dienst 1 )<br/>1400349 BRW Rotterdam-Rijnmond ( Team Brandonderzoek Infocode Zuid )<br/>1400200 BRW Rotterdam-Rijnmond ( OvD Rijmond Noord  )<br/>]]></description>
      <guid>2001171404160117</guid>
      <author/>
      <geo:lat>51.9070947</geo:lat>
      <geo:long>4.4962528</geo:long>
    </item>
    <item>
      <title><![CDATA[B2 AMBU 17150 Raadhuishof 2651JK Berkel en Rodenrijs BERKRR bon 8096]]></title>
      <link>https://www.livep2000.nl/monitor/?SPI=2001171403560217</link>
      <pubDate>Fri, 17 Jan 2020 14:03:56 +0100</pubDate>
      <description><![CDATA[1420999 MKA Rotterdam-Rijnmond ( Monitorcode )<br/>1420050 MKA Rotterdam-Rijnmond ( Ambulance 17-150 )<br/>]]></description>
      <guid>2001171403560217</guid>
      <author/>
      <geo:lat>51.9916445</geo:lat>
      <geo:long>4.4800863</geo:long>
    </item>
    <item>
      <title><![CDATA[B1 AMBU 17124 Maasstadweg 3079DZ Rotterdam ROTTDM bon 8095]]></title>
      <link>https://www.livep2000.nl/monitor/?SPI=2001171403300217</link>
      <pubDate>Fri, 17 Jan 2020 14:03:30 +0100</pubDate>
      <description><![CDATA[1420999 MKA Rotterdam-Rijnmond ( Monitorcode )<br/>1420024 MKA Rotterdam-Rijnmond ( Ambulance 17-124 )<br/>]]></description>
      <guid>2001171403300217</guid>
      <author/>
      <geo:lat>51.8783319</geo:lat>
      <geo:long>4.5453915</geo:long>
    </item>
    <item>
      <title><![CDATA[P 1 Gebouwbrand woning (INCI-02) Laan op Zuid Rotterdam 173451 179234 173431]]></title>
      <link>https://www.livep2000.nl/monitor/?SPI=2001171402280117</link>
      <pubDate>Fri, 17 Jan 2020 14:02:28 +0100</pubDate>
      <description><![CDATA[1400999 BRW Rotterdam-Rijnmond ( Monitorcode )<br/>1400441 BRW Rotterdam-Rijnmond ( Kazernealarm Mijnsherenlaan )<br/>1400349 BRW Rotterdam-Rijnmond ( Team Brandonderzoek Infocode Zuid )<br/>1400231 BRW Rotterdam-Rijnmond ( Postalarm Baan )<br/>]]></description>
      <guid>2001171402280117</guid>
      <author/>
      <geo:lat>51.9070947</geo:lat>
      <geo:long>4.4962528</geo:long>
    </item>
Zendio commented 4 years ago

Schermfoto 2020-01-21 om 07 52 06 Duplicates again, showing no coordinates. I sadly don't have to log to send to you.

Zendio commented 4 years ago

Every p2000 alert that has a location is quickly followed up by a duplicate without the location. Sometimes it arrives seconds after getting the first alert, other times it takes up to 20 minutes.

cyberjunky commented 4 years ago

Can you test 1.0.8?

Zendio commented 4 years ago

On it :)

Zendio commented 4 years ago

Sadly didn't fix it for me. Still duplicates shortly after one another. Just 2 though and the titles are the same, so I've been able to fix it in my automation by using a value_template. Issue remains.

The first message is always correct and contains location data, the second (duplicate) doesn't contain a location.

cyberjunky commented 4 years ago

I checked a bit more, and maybe latest code fixes some occasions, but I get msgs in my feed without location fields, at sometimes more than others.

For example this last one, but most of time a similar event with location is next to it. Screenshot from 2020-03-08 16-05-30

cyberjunky commented 4 years ago

Try release 1.0.10 it should show up soon in HACS, or copy from github.

Zendio commented 4 years ago

Thanks! First thing I noticed that radius doesn't work anymore. It's sending me every single message from the entire region if no location data is known. Is this intended?

cyberjunky commented 4 years ago

Well in older versions messages without location were not shown. Now they are, do you get many of them? Maybe it's better to hide them again, or add config parameter to see them or not?

Zendio commented 4 years ago

Yes, it's spamming a bit. 5 messages in 6 minutes before turning the notification automation off. Made another condition now to only show the ones with a location, so it's back to normal. Having the option would be very nice.

cyberjunky commented 4 years ago

Can you post the notification workaround? Gives me some time to fix it.

Zendio commented 4 years ago
- condition: template
  value_template: '{{ state_attr('sensor.p2000', 'longitude')|int > 0 }}'

When no location data is sent it appears as 0 lat, 0 lon etc, so anything bigger than 0 works. There's probably a cleaner solution but hey.. it works.

Put this as a condition in your automation. If your sensor has a different name, change the sensor.p2000 part

cyberjunky commented 4 years ago

Closing, if there are still problems with latest release please open a new github issue.