crismc / homeassistant_nationalrailtimes_integration

A custom Home Assistant component to show next available trains to specific stops through the National Rail Darwin SOAP API.
14 stars 4 forks source link

[Bug]: station messages wrapped with <p> </p> #3

Open ReX1983 opened 1 year ago

ReX1983 commented 1 year ago

Requirements

Current Behavior

Some station messages are reported as:

The Ticket Office is currently closed at XYZ station.

Expected Behavior

and

should not be displayed. ### Steps To Reproduce You just need a station that has ticket office closed message. ### Context _No response_ ### Environment ```markdown - Browser: - HA Version: - NationalRailTimes: ``` ### Anything else? I have modified my local copy of ` def extra_state_attributes(self)` adding the followings before return: ``` pattern1 = re.compile(r'

') attributes["message"] = [pattern1.sub('', sub) for sub in attributes["message"]] pattern2 = re.compile(r'

') attributes["message"] = [pattern2.sub('', sub) for sub in attributes["message"]] ``` It works, would be good to add something similar in your implementation.

crismc commented 1 year ago

Yeah, did see this every now and again on mine too... waiting for it to pop back up so I can test, and will look to add a wrapper.

Will probably look to add it in the apidata.py/message method, as sensor.py/extra_state_attributes was designed as more of a controller / gatherer of data than a manipulator. Although if you've already issued a fix locally, happy to review a pull request and merge it in, with full crediting to you.

Honestly, nice to see someone other than me is getting use out of this :)

Macka1993 commented 1 year ago

I'm also experiencing this bug, it causes the lovelace card to disappear from my dashboard, I've worked around it by choosing another local station

coolssor commented 8 months ago

Looks like I'm facing this issue too on my side. We've got some pretty hellish weather at the moment here in Scotland, so the alerts will likely be on for a while longer if you want to test with mine :)

image