Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in HA when only one High Tide for Location #2

Open
Gavin-A92 opened this issue Dec 17, 2021 · 1 comment
Open

Error in HA when only one High Tide for Location #2

Gavin-A92 opened this issue Dec 17, 2021 · 1 comment

Comments

@Gavin-A92
Copy link

Gavin-A92 commented Dec 17, 2021

Hi

Seems some locations in https://tidetimes.org.uk/ only offer one High (and Low I guess) tide per day. Not sure if this is caused by timing of the actual tide or an issue with their platform. Either way it throws an error in HA as below because the second High Tide cannot be read.

Location I've seen this happening for is https://tidetimes.org.uk/balbriggan-tide-times which seems to have either two Highs with no Lows or some other combination, but at all times only two times there?

I've circumvented by using another location and all seems OK so just throwing it out there in case you wanted to have a look.........

2021-12-17 02:35:48 ERROR (MainThread) [homeassistant.components.sensor] Error adding entities for domain sensor with platform tides
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 382, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 613, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 748, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 505, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 541, in _async_write_ha_state
    extra_state_attributes = self.extra_state_attributes
  File "/config/custom_components/tides/sensor.py", line 71, in extra_state_attributes
    attr["high_tide_2_time"] = self.data[2][1]
IndexError: list index out of range

Here's the current RSS info for that location

<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
	<title>Balbriggan Tide Times</title>
	<link>https://www.tidetimes.org.uk/balbriggan-tide-times</link>
	<description>Balbriggan tide times.</description>
	<lastBuildDate>Fri, 17 Dec 2021 00:00:00 GMT</lastBuildDate>
	<language>en-gb</language>
	<atom:link href="https://www.tidetimes.org.uk/balbriggan-tide-times.rss" rel="self" type="application/rss+xml"/>
	<item>
		<title>Balbriggan Tide Times for 17th December 2021</title>
		<link>https://www.tidetimes.org.uk/balbriggan-tide-times</link>
		<guid>https://www.tidetimes.org.uk/balbriggan-tide-times</guid>
		<pubDate>Fri, 17 Dec 2021 00:00:00 GMT</pubDate>
		<description>&lt;a href=&quot;https://www.tidetimes.org.uk&quot; title=&quot;tide times&quot;&gt;Tide Times&lt;/a&gt; &amp;amp; Heights for &lt;a href=&quot;https://www.tidetimes.org.uk/balbriggan-tide-times&quot; title=&quot;Balbriggan tide times&quot;&gt;Balbriggan&lt;/a&gt; on 17th December 2021&lt;br/&gt;&lt;br/&gt;10:20 - High Tide &#x28;4.1m&#x29;&lt;br/&gt;22:31 - High Tide &#x28;3.99m&#x29;&lt;br/&gt;</description>
	</item>
</channel>
</rss>
@rianoc
Copy link
Owner

rianoc commented Dec 17, 2021

That's weird - I'd only accounted for the common case there there are only 3 tides over 24hrs (full tide cycle is 24hr 50mins)

Will have a look at handling this case, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants