feedparser: Error while setting up platform feedparser - seems to be GeoRSS related

HA version - 88.2 feedparser.py version - 0.0.4

Feedparser fails w/ following error:

2019-03-17 14:13:29 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform feedparser
Traceback (most recent call last):
  File "/config/deps/lib/python3.7/site-packages/feedparser.py", line 3766, in _gen_georss_coords
    t = [nxt(), nxt()][::swap and -1 or 1]
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 128, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 416, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/feedparser/sensor.py", line 46, in setup_platform
    add_devices([FeedParserSensor(hass, config)])
  File "/config/custom_components/feedparser/sensor.py", line 58, in __init__
    self.update()
  File "/config/custom_components/feedparser/sensor.py", line 62, in update
    parsedFeed = feedparser.parse(self._feed)
  File "/config/deps/lib/python3.7/site-packages/feedparser.py", line 3956, in parse
    saxparser.parse(source)
  File "/usr/local/lib/python3.7/xml/sax/expatreader.py", line 111, in parse
    xmlreader.IncrementalParser.parse(self, source)
  File "/usr/local/lib/python3.7/xml/sax/xmlreader.py", line 125, in parse
    self.feed(buffer)
  File "/usr/local/lib/python3.7/xml/sax/expatreader.py", line 217, in feed
    self._parser.Parse(data, isFinal)
  File "/usr/src/python/Modules/pyexpat.c", line 471, in EndElement
  File "/usr/local/lib/python3.7/xml/sax/expatreader.py", line 381, in end_element_ns
    self._cont_handler.endElementNS(pair, None)
  File "/config/deps/lib/python3.7/site-packages/feedparser.py", line 2052, in endElementNS
    self.unknown_endtag(localname)
  File "/config/deps/lib/python3.7/site-packages/feedparser.py", line 696, in unknown_endtag
    method()
  File "/config/deps/lib/python3.7/site-packages/feedparser.py", line 1463, in _end_georss_point
    geometry = _parse_georss_point(self.pop('geometry'))
  File "/config/deps/lib/python3.7/site-packages/feedparser.py", line 3775, in _parse_georss_point
    coords = list(_gen_georss_coords(value, swap, dims))
RuntimeError: generator raised StopIteration

Here is the XML it was attempting to parse; I did validate this XML against an online validator and it passed, but maybe there’s something in there that might help so I’m including it.

<rss xmlns:georss="http://www.georss.org/georss" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
<channel>
<title>Active Incidents</title>
<description>All Active Incidents</description>
<language>en-us</language>
<pubDate>Sun, 17 Mar 2019 14:22:09 -0400</pubDate>
<copyright>Copyright 511nj.org</copyright>
<ttl>1</ttl>
<atom:link type="application/rss+xml" rel="self" href="https://siftrss.com/f/rM97xqQppx"/>
<item>
<title>NJ 21 northbound : Watermain break</title>
<description>
NJ DOT - STMC: Watermain break on NJ 21 northbound area of I-280 (Newark) all lanes open to traffic
</description>
<pubDate>Sun, 17 Mar 2019 13:39:29 -0400</pubDate>
<georss:point>40.7473097576 -74.1674443187</georss:point>
</item>
<item>
<title>
New Jersey Turnpike/I-95 northbound : Disabled vehicle
</title>
<description>
NJ Turnpike Auth.: Disabled vehicle on New Jersey Turnpike/I-95 express lanes northbound South of Exit 71 (NB) - NJ 4/Broad Ave (Teaneck Twp) right lane blocked
</description>
<pubDate>Sun, 17 Mar 2019 13:33:00 -0400</pubDate>
<georss:point>40.8737688181 -73.9957312183</georss:point>
</item>
<item>
<title>
New Jersey Turnpike - Eastern Spur northbound : Accident
</title>
<description>
NJ Turnpike Auth.: Accident on New Jersey Turnpike - Eastern Spur northbound North of Interchange 15W - I-280 (Kearny) center lane blocked
</description>
<pubDate>Sun, 17 Mar 2019 13:59:32 -0400</pubDate>
<georss:point>40.7554488245 -74.1060449598</georss:point>
</item>
</channel>
</rss>

I tried deleting the deps folder to allow it to rebuild in case there was a version issue or corruption but it didn’t seem to help; on first boot I didn’t get the error but it returned immediately on the next restart afterwards.

I am restoring things from a previous backup and this is the only thing left that I haven’t been able to figure out on my own. It was working previously for me. I also double checked the config of the sensor itself and it seems valid. I even tried excluding the georss:point data from the sensor, but after restart I got the same exact error.

Here’s the config:

- platform: feedparser
  name: Traffic Incidents
  #Source RSS -  http://511nj.org/RSS511Service/RSS511Service.svc/rest/rss/RSSActiveIncidents
  feed_url: https://siftrss.com/f/rM97xqQppx 
  exclusions:
    - georss:point

I’m kinda out of my realm of knowledge at this point and I was hoping that you might be able to take a look and either point me in the right direction or advise a solution. I’d really hate to have to stop using FeedParser as I still want to use it elsewhere; I recently got my WeeWx weather station running on a spare Pi and was hoping to pull the feed on it into HA.

Thanks for your time and effort!

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 31 (14 by maintainers)

Most upvoted comments

well I still plan on doing a full re-write of it…someday 😄 i’ll leave this open until I update the dependency

It doesn’t seem to be an issue anymore. I also updated the manifest.json to pull the newest beta release of McKee’s feedparser lib (6.0.0b1) and that works as well. I can’t get it to display in List Card because the data is nested and I can’t figure out the proper syntax, but it is showing in the sensor and I no longer have to exclude it.

Garden State Parkway northbound : Building fire: {
  "title": "Garden State Parkway northbound : Building fire",
  "title_detail": {
    "type": "text/plain",
    "language": null,
    "base": "https://siftrss.com/f/rM97xqQppx",
    "value": "Garden State Parkway northbound : Building fire"
  },
  "summary": "NJ Turnpike Auth.: Building fire and Fire department activity and Outside Agency Assist on Garden State Parkway northbound exiting at Exit 29 - US 9 (Somers Point)  exit ramp closed to all traffic.  Motorist are advised to seek alternate route.",
  "summary_detail": {
    "type": "text/html",
    "language": null,
    "base": "https://siftrss.com/f/rM97xqQppx",
    "value": "NJ Turnpike Auth.: Building fire and Fire department activity and Outside Agency Assist on Garden State Parkway northbound exiting at Exit 29 - US 9 (Somers Point)  exit ramp closed to all traffic.  Motorist are advised to seek alternate route."
  },
  "published": "Thu, Jan 30 06:18 AM",
  "where": {
    "type": "Point",
    "coordinates": [
      -74.618952491,
      39.309583815
    ]
  }
}
I-80 eastbound : Crash: {
  "title": "I-80 eastbound : Crash",
  "title_detail": {
    "type": "text/plain",
    "language": null,
    "base": "https://siftrss.com/f/rM97xqQppx",
    "value": "I-80 eastbound : Crash"
  },
  "summary": "NJ DOT - STMC: Crash on I-80 eastbound East of Exit 62 - Garden State Parkway (Saddle Brook Twp)  right and center lanes closed 5-10 minute delay",
  "summary_detail": {
    "type": "text/html",
    "language": null,
    "base": "https://siftrss.com/f/rM97xqQppx",
    "value": "NJ DOT - STMC: Crash on I-80 eastbound East of Exit 62 - Garden State Parkway (Saddle Brook Twp)  right and center lanes closed 5-10 minute delay"
  },
  "published": "Thu, Jan 30 07:57 AM",
  "where": {
    "type": "Point",
    "coordinates": [
      -74.0995627545,
      40.9035231457
    ]
  }
}
George Washington Bridge westbound : Truck restrictions: {
  "title": "George Washington Bridge westbound : Truck restrictions",
  "title_detail": {
    "type": "text/plain",
    "language": null,
    "base": "https://siftrss.com/f/rM97xqQppx",
    "value": "George Washington Bridge westbound : Truck restrictions"
  },
  "summary": "Port Authority NY/NJ: Truck restrictions on George Washington Bridge westbound entering at New York Side/Upper Level (Manhattan)  The 179th Street ramp to New Jersey has a width restriction  of 8'6\". Please use alternate route. Westbound Trans Manhattan Epressway restrictions are width 10' and height are 13'6\".",
  "summary_detail": {
    "type": "text/html",
    "language": null,
    "base": "https://siftrss.com/f/rM97xqQppx",
    "value": "Port Authority NY/NJ: Truck restrictions on George Washington Bridge westbound entering at New York Side/Upper Level (Manhattan)  The 179th Street ramp to New Jersey has a width restriction  of 8'6\". Please use alternate route. Westbound Trans Manhattan Epressway restrictions are width 10' and height are 13'6\"."
  },
  "published": "Wed, Jan 01 11:00 AM",
  "where": {
    "type": "Point",
    "coordinates": [
      -73.9454749908247,
      40.8503529522236
    ]
  }
}
US 30 both directions : Traffic Signal Down: {
  "title": "US 30 both directions : Traffic Signal Down",
  "title_detail": {
    "type": "text/plain",
    "language": null,
    "base": "https://siftrss.com/f/rM97xqQppx",
    "value": "US 30 both directions : Traffic Signal Down"
  },
  "summary": "NJ DOT - STMC: Traffic Signal Down and Utility Pole Down on US 30 both directions between CR 689/Berlin Cross Keys Rd (Berlin)  and CR 534/Jackson Rd (Berlin)  all lanes closed and detoured follow detour use caution",
  "summary_detail": {
    "type": "text/html",
    "language": null,
    "base": "https://siftrss.com/f/rM97xqQppx",
    "value": "NJ DOT - STMC: Traffic Signal Down and Utility Pole Down on US 30 both directions between CR 689/Berlin Cross Keys Rd (Berlin)  and CR 534/Jackson Rd (Berlin)  all lanes closed and detoured follow detour use caution"
  },
  "published": "Thu, Jan 30 06:40 AM",
  "where": {
    "type": "Point",
    "coordinates": [
      -74.9322706058,
      39.7957093665
    ]
  }
}
US 9 southbound : Building fire: {
  "title": "US 9 southbound : Building fire",
  "title_detail": {
    "type": "text/plain",
    "language": null,
    "base": "https://siftrss.com/f/rM97xqQppx",
    "value": "US 9 southbound : Building fire"
  },
  "summary": "NJ DOT - TOC South: Building fire on US 9 southbound CR 559/Mays Landing Rd (Somers Point)  to Garden State Parkway (Somers Point)  all lanes closed and detoured 10-15 minute delay use caution",
  "summary_detail": {
    "type": "text/html",
    "language": null,
    "base": "https://siftrss.com/f/rM97xqQppx",
    "value": "NJ DOT - TOC South: Building fire on US 9 southbound CR 559/Mays Landing Rd (Somers Point)  to Garden State Parkway (Somers Point)  all lanes closed and detoured 10-15 minute delay use caution"
  },
  "published": "Thu, Jan 30 08:04 AM",
  "where": {
    "type": "Point",
    "coordinates": [
      -74.6127479068,
      39.3121776573
    ]
  }
}
I-295 northbound : Crash: {
  "title": "I-295 northbound : Crash",
  "title_detail": {
    "type": "text/plain",
    "language": null,
    "base": "https://siftrss.com/f/rM97xqQppx",
    "value": "I-295 northbound : Crash"
  },
  "summary": "NJ DOT - TOC South: Crash on I-295 northbound North of Exit 57 - US 130 (Bordentown Twp)  right shoulder closed use caution",
  "summary_detail": {
    "type": "text/html",
    "language": null,
    "base": "https://siftrss.com/f/rM97xqQppx",
    "value": "NJ DOT - TOC South: Crash on I-295 northbound North of Exit 57 - US 130 (Bordentown Twp)  right shoulder closed use caution"
  },
  "published": "Thu, Jan 30 08:05 AM",
  "where": {
    "type": "Point",
    "coordinates": [
      -74.718920399,
      40.1451046324
    ]
  }
}
friendly_name: Traffic Incidents
icon: mdi:rss

Yo, just for shits and giggles, I downloaded the hotfix and replaced the release version in /deps/ (actually renamed it cause I wanted to save it in case things went South on me) and the damn thing works! This eliminates the issue I was having and I am back in business. Guy even furnished a bash script in the post that downloads the hotfix and overwrites the installed feedparser.py!

Thanks again for your help, Ian.