Support for Environment Canada platforms

Hi,

Thanks for this great integration. I noticed in a post form a couple of weeks ago that you have introduced a new overlay that will display the time of each gif. As well, you slowed down the FPS. I was wondering how you can enable/control those two features? Is that coming in a new update to the integration within a future HA release? Or, is it something available today in a setting of the camera entity?

Thanks

There’s an open pull request with these changes, but it’s currently stuck due to a build error. I’ll try to get this fixed for 0.114. In the meantime, you can run the code from release 0.2.0 as a custom component (that’s what I’m doing on my own instance):

Adding new configuration options is trickier, as I can’t do that until I modify the components to work with HA’s new GUI-based configuration. That’s on my list of things to do, but I don’t know right now when I’m going to get to it. If you’re running a custom component you could modify the code locally, which I recognize is less than ideal.

Thanks Michael. I appreciate your efforts on this and your timely response.

So I manually pulled down this PR onto the 0.113b3 (I see it’s going to be added to b4 or the final release, but while I wait…). The first restart worked fine (no errors), but after restarting once more now I got:

Logger: homeassistant
Source: components/environment_canada/weather.py:155 
First occurred: 1:55:31 PM (1 occurrences) 
Last logged: 1:55:31 PM

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/homeassistant/helpers/entity_platform.py", line 293, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/local/lib/python3.8/site-packages/homeassistant/helpers/entity_platform.py", line 452, in _async_add_entity
    entity.async_write_ha_state()
  File "/usr/local/lib/python3.8/site-packages/homeassistant/helpers/entity.py", line 290, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/local/lib/python3.8/site-packages/homeassistant/helpers/entity.py", line 314, in _async_write_ha_state
    sstate = self.state
  File "/usr/local/lib/python3.8/site-packages/homeassistant/components/weather/__init__.py", line 188, in state
    return self.condition
  File "/usr/local/lib/python3.8/site-packages/homeassistant/components/environment_canada/weather.py", line 155, in condition
    elif self.ec_data.hourly_forecasts[0].get("icon_code"):
IndexError: list index out of range

This is now on env_canada 0.1.0.

Hello all, I just found the environment_canada integration and I love it. I set up the default daily and sensors and everything worked fine. but then I decided I wanted both the daily and the hourly, so I set up two weather: definitions and named them _hourly and _daily. everything is fine with the weather component, but the sensor component has stopped working. I only have one sensor definition for it, and there is no “name” to associate it with, but it certainly does not like me having two weather: components.

Any suggestions as to how I could get both daily and hourly, and the sensors to all work?

Thanks so much,
Brian.

Yup, I was able to recreate this and I’m not sure what is causing it. I’ll see if I can figure it out.

Thanks so much!

@michaeldavie, trying to work my way through this, I did notice and I am not sure if this is best practice, but because of the imports in the init.py the modules for data, radar, and hydro are getting imported each time you import any env_canada module. so even if you are not setting up the camera integrations, the radar module is being imported… also I am not sure about python efficiency, but would that not mean it is being loaded 4 times in my case (2 weather, 1 sensor, 1 camera)? to be clear I don’t think this is the source of my issue, just trying to make heads and tails of all this.

Hope you figure that out that hourly daily problem.

I’m having an issue with false TTS announcements for warnings and such and I’m wondering if anybody can tell me whats happening. Currently right now I have the automation to trigger on state change for the sensor which the announcement is to be made. I have not designated what state change in the front end and I believe that it defaults to any state change in that case.

The problem I’m seeing is that periodically through the day I’ll get an announcement that is nothing.

environment_canada_weather_watch_announcement:
  alias: environment canada weather watch announcement
  sequence:
     - service: tts.google_translate_say
       data_template:
         entity_id: media_player.redacted
         message: This is an Environment Canada weather watch declaration. There is an"{{ states('sensor.watches') }} in effect."

Basically nothing or the same is announced in the “{{ states(‘sensor.watches’) }}” portion. This leads me to believe that the sensor has been updated perhaps but not with anything or with the same information.
Is there a way to get rid of the false/repeat announcements ?

Here is my current automation code generated from the gui

- id: environment canada weather warning'
  alias: environment canada weather warning
  description: ''
  trigger:
  - entity_id: sensor.warnings
    platform: state

It calls the script above

Update on the list index out of range error: through some debugging, it looks like sometimes when getting an initial set of EC data, the hourly forecasts list is not populated. This happens to me pretty regularly when Home Assistant starts. By adding this check to line 155 of weather.py, it has been working with no further errors.

elif len(self.ec_data.hourly_forecasts) > 0:

Seems like a trivial fix for me to submit a PR, but let me know if that would help.

Hi all,
I have been using this extension for very long time and it has been great. However since a few days I experience a problem that I can’t figure out: The sensor platform does not seems to update as frequently and as reliably as the weather platform. Unfortunately it affects my automation.

I am not sure what is wrong. I removed the integration and added it again but it seems to be always the same problem.

Sometime I can see an error but I am not sure it is related. Here is the log: https://pastebin.com/xBaDNyXD

I created a template sensor from the weather platform in order to plot the difference in Grafana:

- platform: template
  sensors:
    meteo_temperature2:
      unit_of_measurement: '°C'
      value_template: "{{ state_attr('weather.montreal', 'temperature') }}"

Similar to post175, I am running into chance_of_precip state unknown. If you look at attached screen shot, if there is no chance, they don’t seem to publish a 0%. If they publish a number the sensor works fine. The problem for me is I use the sensor state to trigger an action, in an esp device. Anyway to set this state to zero if not published? I guess i could make a template sensor possibly with an if then else for this case.

I’m running in to similar delayed sensor updates. The weather platform seems to work great, but the sensor platform often doesn’t update for many hours at a time. This seems new in the past few versions.

Restarting HA always forces an update to the sensor platform, however between restarts is often “locks up” and shows no updates for extended periods. I’m not seeing anything in the logs either.

This is causing me all sorts of issues in other areas of my automations.

1 Like

it is possible to give a sensor for tonigh and tomorow summuray?

right now I have forecast sensor: today but not tonight and tomorow

@michaeldavie. I have tried to go over this with a fine tooth comb, and I cannot see what the issue is for the sensors not updating when there are two other weather configurations. especially because the camera config works just fine. When I set up some logging, I determined that it does in fact set up the sensor_list just fine, and it adds the entities. but for some reason the update() is not running; no logging I put in there seems to get called. could this be a larger problem with how HA is calling the sensor updates? Any help would be greatly appreciated.

@bcarter Considering the issue that @bob88865 and I are having, I’m not sure that the problem with update() not running is related to multiple weather configurations. I only have one weather configuration, and my sensors frequently don’t update.
Now it’s possible this is 2 unrelated issues, but I’d say maybe this is a larger issue than just multiple weather configs.

Hi ! I added the camera platform in the configuration.yaml so now I have a sensor “camera” in my entities. I’m wondering how can I add it on my UI. I don’t have a camera card when I want to add a card.

Hi, it looks like at 4:00am in the day of Friday the forecast was shifted by one day in the future…
Fresh updated weather sensor vs Env.Can. website:

Screenshot from 2020-09-04 04-07-18

custom weather card as well as lovelace one are showing the same result

Will see in the morning of friday if the forecast shift back

I use picture-entity card

aspect_ratio: 0%
entity: camera.environment_canada_radar
type: picture-entity

Is there any way to debug when receiving “unavailable” for sensor readings? Was working for about 10 hours after I implemented it but since then all the sensor data like uv_index has just read “unavailable”. The weather data seems fine but I cannot get what I want from it (uv_index and other values used in some min_max calculations)

Only thing I see in the log is this but that’s for the weather component and not sensor and the weather data is working despite the error.

2020-09-06 10:07:45 WARNING (MainThread) [homeassistant.components.weather] Setup of weather platform environment_canada is taking over 10 seconds.