nathan-gs / ha-map-card

A Map Card for Home Assistant
https://community.home-assistant.io/t/map-card-a-slightly-improved-map-card/693088
MIT License
25 stars 7 forks source link

TypeError: Cannot read properties of undefined (reading 'length') #77

Closed KeithSBB closed 5 days ago

KeithSBB commented 1 month ago

I'm using GeoJson to read fire incidents from https://www.fire.ca.gov/umbraco/api/IncidentApi/GeoJsonList?inactive=false&yer=2024 (x,y) which creates entities that work in the default HA map. When I add them to ha-map-card I encountered the following error when ha-map-card tries to read these entities:

`geo_location.geo_json_events_01j3ttrjwj15wm6wmyjs7hfw0e_5523279784558815805 skipped due to missing data TypeError: Cannot read properties of undefined (reading 'length')

at Entity._abbr (map-card.js?hacstag=734825457140:15016:14)

at Entity._createMapMarker (map-card.js?hacstag=734825457140:15088:27)

at new Entity (map-card.js?hacstag=734825457140:15005:24)

at map-card.js?hacstag=734825457140:15877:24

at Array.map (<anonymous>)

at MapCard._firstRender (map-card.js?hacstag=734825457140:15853:39)

at MapCard.render (map-card.js?hacstag=734825457140:15734:32)

at MapCard.update (map-card.js?hacstag=734825457140:14550:236)

at MapCard.performUpdate (map-card.js?hacstag=734825457140:14537:5001)

at MapCard.scheduleUpdate (map-card.js?hacstag=734825457140:14537:453`
nathan-gs commented 1 month ago

I suspect the event does not have a name. Will add a fallback.

Unfortunately I cannot view the URL (likely geo-restricted). Can you share your config?

KeithSBB commented 1 month ago

First of all, thanks for creating and supporting this very cool custom card. there was a typo in the URL which I fixed, try to see if you can go there now.

Here's my ha_map-card yaml:

type: custom:auto-entities
filter:
  include:
    - entity_id: geo_location.geo_json_events_*
      options:
        display: icon
        size: 6
        color: yellow
    - entity_id: zone.home
      options:
        size: 32
  exclude: []
card:
  type: custom:map-card
  theme_mode: auto
  title: Fire Incidents
  debug: true
  focus_entity: zone.home
  zoom: 8
  card_size: 9
cards: []
title: Fire
KeithSBB commented 1 month ago

Update: I manually named one of these GeoJson entities and it then shows up on the map. the problem is that the default name is terrible. The issue seems to be with the GeoJson integration as it looks for a "title" attribute in the feed properties, but this feed sets that as "name". There's a generalized GeoJson: https://github.com/Fusion/python-aio-geojson-query/tree/master/examples/homeassistant but it hasn't been updated in 4 years and seems difficult to use. Really need a good GeoJson feed to entity creation integration that supports mappings to custom attributes....

nathan-gs commented 5 days ago

Fixed in v1.5.1