Parsing attributes from GeoJson objects

Hi all, Happy New Year.

New Year, New project time.

I’m trying to get GeoJson events from my city’s OpenData project. I’ve been able to create a URL query that gets me the data for the last week as a GeoJson object.

geo_location:
  - platform: geo_json_events
    url: "https://phl.carto.com/api/v2/sql?q=SELECT+*+FROM+incidents_part1_part2+WHERE+dispatch_date_time>current_date-7+AND+text_general_code+LIKE+'%Vehicle%'&format=geojson&skipfields=cartodb_id"
    radius: 2.5
    entity_namespace: 'home_crime_vehicle'
    scan_interval: 8640

It is importing everything nicely, but I’m having two problems I can’t find documentation on.

  1. I only get the following attributes and the entity id is geo_location.home_crime_vehicle_unnamed_device_X.
latitude: 39.99001
longitude: -75.18671
source: geo_json_events
external_id: -8078411085321075000
unit_of_measurement: km

I’m assuming this is because its not parsing the rest of the json object. Is there a way I can template that information? Or does the underlying tool not support this?

  1. When using the lovelace map card I can’t figure out the syntax for including these geo_location_sources.
    entities:
      - zone.home
    geo_location_sources:
      - all
    type: map

I’ve gotten the all to work. But I can’t get any specific feed to work. I’ve tried home_crime_vehicle and geo_location.home_crime_vehicle.

On a related note.
I’ve noticed in the documentation that there are three types of geo-json tools. geo_json_events are under the geo_location: section of the config while geonetnz_quakes, wwlln, and a few others have their own sections (wwlln:), and geo_rss_events is a sensor platform. If I’m trying the “future proof” my work against future break-changes, does anyone know which method is likely going to be the “1.0” strategy?

Sorry, the underlying integration does not support any other (custom) attributes.

The correct source in this case is geo_json_events.

The geo_rss_events is the oldest one in the list and works very differently from all the others.
Older integrations are the ones defined under geo_location, and the newer ones are defined as their own top-level integration (like for example geonetnz_quakes). The latter is the preferred new way for integrations to be implemented.

Thanks for the info @exxamalte. That’s pretty much what i guessed. If I ever get around to making a more concerted effort to make a full-fledged plugin I’ll make in the style of wwln.

1 Like

Feel free to have a look at this generic async JSON library that I developed as a basis for specific libraries that will then integrate with HA. This comes with all the things needed to manage entities from a JSON feed, so you would only need to take care of adding any additional custom attributes of that integration.