Support for Environment Canada platforms

@michaeldavie:

Probably pulled from https://dd.weather.gc.ca/observations/xml/ON/yesterday/yesterday_on_20191115_e.xml

A more complex XML structure to parse…

Can I request a change to the State value of the Advisories, Warnings, Watches, Statements?

It would be super helpful to have a state value (perhaps None) when there are no Advisories, Warnings, Watches, or Statements.

Currently the empty state value does not allow the use of state_not in Lovelace.

I had a binary_sensor work around for this but that also appears to have broken at some point while updating HA. Perhaps as these sensors are no longer hidden or false when no alerts are issued.

Thanks

@rlongfield Good Idea,

Here’s a workaround that works with the current release of HA 101.3.

  bad_weather:
    value_template: >-
      {% set alerts = [ is_state('sensor.advisories', ""), 
                        is_state('sensor.statements', ""),
                        is_state('sensor.watches', ""),
                        is_state('sensor.warnings', "")] %}
      {{ alerts | select('==', false) | list | count > 0  }}
1 Like

@pg.sylvestre

Thanks for the work around. Glad to have my warning card back up and working!

1 Like

Unfortunately, I’m not able to change this. I tried previously, and the maintainers asked me to stick with None when there’s no value. If Lovelace is not able to handle this properly, you could try raising an issue on the main project.

That example gave me a sense of déjà vu! :slight_smile:

Wow, I really wish they would consolidate this data a bit more. The components already take quite a while to load due to all the fetching and parsing required, and the fact that they use different geo-bounding for each dataset. I’ll take a look at this one and see if there’s value in pulling it in as well.

@michaeldavie They probably structured it this way because it remains static for 24 hours. Something to consider.

The structure is fine, it’s just a pain to take a user-provided lat/lon and find the right (i.e. closest) data point, and to do it separately for each feed of data that Environment Canada provides. Ideally they would provide an API to do pretty much what my env_canada library is doing—submit a lat/lon, and get back a data structure with everything they know about it. But they don’t, so I have to scrounge up all of the bits myself.

Sorry for the rant…

It’s justified. While scanning through the QC version of it I considered the challenge of matching a given location to the closest one reported within the file. Whoa! That’s a headache! Pretty far from a one-to-one mapping of weather stations to what’s available in that file.

@michaeldavie:

I saw that when I scanned the structure of the past observation data. Your rant is justified.

Let’s not forget the power of the human and let them choose the station id. In my case, the closest calculated station is actually not the one I wanted because of the micro-climate across a large water mass. It’s actually in a different province.

I had to override the logic and set the station id myself. Thanks for making that possible.

I suspect most users don’t mind being that specific and giving an id ‘a la yahoo weather’.

The same problem of geo-location existed for me in darksky. Not in another province, but…it selected sensors at a marina; again, giving me the micro-climate on the edge of a large water mass.

My suggestion, is to let Ha configurators select a station id or even a city name if they want the extra data you can provide…

Does anyone know how to add two sensors? I can only see one…

sensor:
  - platform: environment_canada
    # Lookups of dd.weather.gc.ca every 10 minutes
    scan_interval: 600
    # Chelsea
    station: "QC/s0000615"
  - platform: environment_canada
    # Lookups of dd.weather.gc.ca every 10 minutes
    scan_interval: 600
    # Ottawa
    station: "ON/s0000430"

Hmmm, that’s odd. This loads both for me:

sensor:
  - platform: environment_canada
    station: ON/s0000411
    scan_interval: 300

  - platform: environment_canada
    station: ON/s0000430
    scan_interval: 300

@michaeldavie Indeed strange…

I am not certain how the internal works but something odd is going on. I replaced my sensors for yours and now only the third sensor in the list below is working, previously only Chelsea was working.
The entries from the core.entity_registry found for: “platform”: “environment_canada”. Example for the humidity sensor I have:

            {
                "config_entry_id": null,
                "device_id": null,
                "disabled_by": null,
                "entity_id": "sensor.humidity",
                "name": null,
                "platform": "environment_canada",
                "unique_id": "Chelsea-humidity"
            },
...
            {
                "config_entry_id": null,
                "device_id": null,
                "disabled_by": null,
                "entity_id": "sensor.humidity_2",
                "name": null,
                "platform": "environment_canada",
                "unique_id": "Ottawa (Kanata - Orl\u00e9ans)-humidity"
            },
...
            {
                "config_entry_id": null,
                "device_id": null,
                "disabled_by": null,
                "entity_id": "sensor.humidity_3",
                "name": null,
                "platform": "environment_canada",
                "unique_id": "Thunder Bay-humidity"
            },

My YAML configuration is:

  - platform: environment_canada
    # Lookups of dd.weather.gc.ca every 10 minutes
    scan_interval: 600
    station: ON/s0000411
  - platform: environment_canada
    # Lookups of dd.weather.gc.ca every 10 minutes
    scan_interval: 600
    station: ON/s0000430

Hi, can I setup with my iphone location?

Unfortunately, I don’t think so. The location from the config is used up front to initialize the objects, and it doesn’t have any support for dynamic reconfiguration.

Ok thanks you

I have this issue as well.

I wanted to have both hourly and daily options on the weather.xxx and it killed off my sensors.

Are you saying that the weather component was interfering with the sensor one? I think I might know what the issue is with having two weather entities for the same location, as the entity_id would be the same. To be honest this isn’t a use case I’d considered…it might be a breaking change to fix.

probably and instance append to the id is required. The problem I have breaks sometimes the Radar and Sensors other times. I has not been consistent enough for me to report with clarity to be helpful.