Environment Canada Issues

I have the following below in my setup

configuration.yaml

weather:
- platform: `environment_canada`
  name: `environment_canada_daily`
  forecast: `daily`

- platform: `environment_canada`
  name: `environment_canada_hourly`
  forecast: `hourly`

In /config/include/sensors.yaml

- platform: `environment_canada`

Nothing will load in my “Entities Card Configuration” for the Sensors

If I remove one of the

- platform: `environment_canada`

etc…

in the configuration.yaml,

the sensors.yaml

- platform: `environment_canada`

Works with all entities reporting.

Entities Card Configuration

type: entities
entities:
- entity: sensor.advisories
- entity: sensor.warnings
- entity: sensor.visibility
- entity: sensor.forecast
- entity: sensor.temperature
- entity: sensor.high_temperature
etc...

When I add the entry back to configuration.yaml, it stops working again

- platform: environment_canada
  name: environment_canada_hourly
  forecast: hourly

Anyone have any idea on how to get this to work ?

1 Like

Hi and welcome to the forum.

Could you please edit your post and format your pasted config as per point 11 here so we can help you.

This issue has never been resolved. Most likely because I was uncertain how to format my post. Anyhow I will try again.

In my configuration.yaml

weather:
 - platform: environment_canada
   name: environment_canada_daily  
   forecast: daily

 - platform: environment_canada
   name: environment_canada_hourly
   forecast: hourly

sensor:
 - platform: environment_canada 

 - platform: time_date
   display_options:
   - 'date_time'

The sensor: - platform: environment_canada will not load if another entry is there under sensor: - platform: time_date.
When I remove it and other entries it works fine. How do I fix this ?

Is that the only place that sensor: appears in your configuration.yaml file?

Are there any relevant errors in Configuration / Logs ?

Yes it is. I spun up a new VM for testing. The only thing in the config is Environment Canada Weather and Sensor. If I add any other - platform: etc, It kills Environment Canada Sensor

These are the errors in the logs

Error doing job: Task exception was never retrieved

4:38:12 PM – (ERROR) components/environment_canada/weather.py - message first occurred at 4:05:43 PM and shows up 66 times

Error doing job: Task exception was never retrieved

3:24:11 PM – (ERROR) components/environment_canada/weather.py

Error adding entities for domain weather with platform environment_canada

3:23:38 PM – (ERROR) Weather - message first occurred at 3:23:38 PM and shows up 2 times

More detailed logs…

2021-04-30 16:49:06 ERROR (MainThread) [homeassistant.components.weather] Error adding entities for domain weather with platform environment_canada
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 322, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 514, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 547, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 310, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 336, in _async_write_ha_state
    attr.update(self.state_attributes or {})
  File "/usr/src/homeassistant/homeassistant/components/weather/__init__.py", line 180, in state_attributes
    if self.forecast is not None:
  File "/usr/src/homeassistant/homeassistant/components/environment_canada/weather.py", line 174, in forecast
    return get_forecast(self.ec_data, self.forecast_type)
  File "/usr/src/homeassistant/homeassistant/components/environment_canada/weather.py", line 239, in get_forecast
    datetime.datetime.strptime(hours[hour]["period"], "%Y%m%d%H%M")
IndexError: list index out of range
2021-04-30 16:49:07 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 322, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 514, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 547, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 310, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 336, in _async_write_ha_state
    attr.update(self.state_attributes or {})
  File "/usr/src/homeassistant/homeassistant/components/weather/__init__.py", line 180, in state_attributes
    if self.forecast is not None:
  File "/usr/src/homeassistant/homeassistant/components/environment_canada/weather.py", line 174, in forecast
    return get_forecast(self.ec_data, self.forecast_type)
  File "/usr/src/homeassistant/homeassistant/components/environment_canada/weather.py", line 239, in get_forecast
    datetime.datetime.strptime(hours[hour]["period"], "%Y%m%d%H%M")
IndexError: list index out of range
2021-04-30 16:49:37 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 626, in _update_entity_states
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 297, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 336, in _async_write_ha_state
    attr.update(self.state_attributes or {})
  File "/usr/src/homeassistant/homeassistant/components/weather/__init__.py", line 180, in state_attributes
    if self.forecast is not None:
  File "/usr/src/homeassistant/homeassistant/components/environment_canada/weather.py", line 174, in forecast
    return get_forecast(self.ec_data, self.forecast_type)
  File "/usr/src/homeassistant/homeassistant/components/environment_canada/weather.py", line 239, in get_forecast
    datetime.datetime.strptime(hours[hour]["period"], "%Y%m%d%H%M")
IndexError: list index out of range
2021-04-30 16:50:08 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 626, in _update_entity_states
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 297, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 336, in _async_write_ha_state
    attr.update(self.state_attributes or {})
  File "/usr/src/homeassistant/homeassistant/components/weather/__init__.py", line 180, in state_attributes
    if self.forecast is not None:
  File "/usr/src/homeassistant/homeassistant/components/environment_canada/weather.py", line 174, in forecast
    return get_forecast(self.ec_data, self.forecast_type)
  File "/usr/src/homeassistant/homeassistant/components/environment_canada/weather.py", line 239, in get_forecast
    datetime.datetime.strptime(hours[hour]["period"], "%Y%m%d%H%M")
IndexError: list index out of range
2021-04-30 16:50:37 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 626, in _update_entity_states
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 297, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 336, in _async_write_ha_state
    attr.update(self.state_attributes or {})
  File "/usr/src/homeassistant/homeassistant/components/weather/__init__.py", line 180, in state_attributes
    if self.forecast is not None:
  File "/usr/src/homeassistant/homeassistant/components/environment_canada/weather.py", line 174, in forecast
    return get_forecast(self.ec_data, self.forecast_type)
  File "/usr/src/homeassistant/homeassistant/components/environment_canada/weather.py", line 239, in get_forecast
    datetime.datetime.strptime(hours[hour]["period"], "%Y%m%d%H%M")
IndexError: list index out of range
2021-04-30 16:51:08 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 626, in _update_entity_states
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 297, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 336, in _async_write_ha_state
    attr.update(self.state_attributes or {})
  File "/usr/src/homeassistant/homeassistant/components/weather/__init__.py", line 180, in state_attributes
    if self.forecast is not None:
  File "/usr/src/homeassistant/homeassistant/components/environment_canada/weather.py", line 174, in forecast
    return get_forecast(self.ec_data, self.forecast_type)
  File "/usr/src/homeassistant/homeassistant/components/environment_canada/weather.py", line 239, in get_forecast
    datetime.datetime.strptime(hours[hour]["period"], "%Y%m%d%H%M")
IndexError: list index out of range

Just to make sure this problem isn’t due to something obscure, have you set your location (within Canada) in Configuration > General?

By default, the Environment Canada integration uses Home Assistant’s latitude and longitude (in order to know for where it should report weather conditions in Canada). Otherwise, you can explicitly supply the integration with location coordinates.

I assume you have done this but I just want to make sure you have.


EDIT

I just noticed you posted a log of error messages. Looks like it’s struggling to work properly.

Yes I have… My complete configuration.yaml below.


# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
#sensor: !include sensors.yaml


homeassistant:
  name: Home
  latitude: xxxxxxxxx
  longitude: xxxxxxxxx
  elevation: xxx
  unit_system: metric
  time_zone: America/Vancouver

weather:
 - platform: environment_canada
   name: environment_canada_daily  
   forecast: daily
   station: BC/sxxxxxxxx 
   
 - platform: environment_canada
   name: environment_canada_hourly
   forecast: hourly
   station: BC/sxxxxxxxx
sensor:
 - platform: environment_canada 
   station: BC/sxxxxxxxx 
   
# - platform: time_date
#   display_options:
# - 'date_time'

I just set up this VM to test as I have never been able to fix it on my main system. There is literally nothing but Environment Canada on this HA VM.

I will assume your answer is “No”. In that case, you should either set Home Assistant’s location (to somewhere in Canada) and restart Home Assistant or set the location, or station, in the Environment Canada integration, as per its documentation.

My Home Assistant’s location is set to my location. The xxxxxxxx above is just the blanked out locations for this thread

So what do I do now ? I really would like to get this fixed…

If you are 100% sure your location is set correctly and the integration has access to it, as per 123’s advice above, the only thing I can think to do is delete the whole integration and try setting it up again (have you tried turning it off and on?).

If you still get the same error we can show you how to raise an issue on github.

The location is set correctly and I am assuming the integration has access to it. In lovelace
I see this for my Weather Forecast Card

This is what I see for the Sensors in my Entities Card

If I remove the following below from my sensors.yaml, then everything in Environment Canada works

 - platform: time_date
   display_options:
    - 'time'
    - 'date'
    - 'date_time'
    - 'date_time_utc'
    - 'date_time_iso'
    - 'time_date'
    - 'time_utc'
    - 'beat'

 - platform: systemmonitor
   resources:
    - type: disk_use_percent
      arg: /home
    - type: memory_free
    - type: memory_use_percent
    - type: memory_use
    - type: processor_use
    - type: processor_temperature
    - type: swap_use_percent
    - type: swap_use
    - type: swap_free
    - type: load_1m
    - type: load_5m
    - type: load_15m

With items above removed

This is all on a newly created HA with nothing but the Environment Canada on it…

I moved my HA from a NUC to a VM on ESXi. Since the move i get the following error.

Retrying setup: Cannot connect to host maps.geogratis.gc.ca:80 ssl:default [Connect call failed ('192.67.45.111', 80)]

Everything else is working fine. Can someone please help?

This is a new problem. I too am experiencing it, but adding it to a post that was created for the integration that is different than what we are experiencing now isn’t the best way to go about it. If when searching by the forums you don’t see the exact error you’re getting, you make a brand new post, or a bug report.

It looks like that the site is down…