As you can see the sensor had not just a Wind Warning but also a Special Weather Statement, on Sunday there were 3 warnings for my area.
I think having 3 sensors might be the best way to handle this. Something like Statement, Watch, and Warning sensors. The question is do you just have these sensors be binary either on or off? Then let the user do what they will from there? or do you have the warning in the sensor similar to how it is now but broken out by the 3 categories?
Personally I like the idea of the sensors being just on or off but that being said I don’t see why I couldn’t create binary sensors have them trigger if one of the 3 is active to achieve my end goal.
Not sure how it would be done but maybe setting the sensors up to allow end users to have the alerts broadcasted on TTS. I don’t know if that means having the alert data in the sensor or something more complicated. Just trying to future think uses for this great tool.
Now if only Environment and Climate Change Canada had an api.
Haven’t tried this component yet, but for EC warnings I’m creating persistent notifications. A few times a day I scrape the EC XML using node red and create a persistent notification from that. Then with Lovelace I use a conditional card and markdown to display the persistent notification if it exists. Ultimately I think Lovelace could use a “list” card that’ll list persistent notifications or other stuff.
Could you invert your condition to say: state_not: “unknown” (or whatever the sensor says when there are no warnings in effect)? That should trigger it for your 3 categories.
@davidbb thanks for that tip. That is a great short term fix. Ideally I’d love to have the conditional card coloured Grey, Yellow, Red based on whether it’s a Statement, Watch, or Warning.
Now I just need to wait for a weather alert to be sure it’s working
FWIW, based on my experience of having created an Environment Canada weather driver in 2009 (and I’ve been using it ever since), whatever strategy is chosen to represent EnviroCan’s alerts (Statement, Watch, Warning, Ended) be advised that multiple alerts can be in effect for the same region.
For my purposes, I dispensed with Statements and focused on reporting Watch, Warning, and Ended. Other than announcing the alerts (via the home’s PA system), they’re also used to set the thermostat’s background color as yet another means of grabbing our attention (Watch=yellow, Warning=red, Ended=green).
This may be possible. It looks like the env_canada library pulls the base radar gif from Environment Canada, and this gif does not include any additional data. What Environment Canada does on their site is overlay several other gifs (one for each of roads, town names, road numbers, etc). I don’t think this is possible in Python directly without including an external dependency, but @michaeldavie may know more.
I’ve made a few changes to the radar component. It will now switch between the regular and the fallback COMP images as required on every update, and will also handle missing frames.
I’ve broken out the categories of alerts into separate sensors as suggested by @rlongfield. Multiple alerts of the same type are still concatenated together.
Your configuration may need to be updated:
warning is no longer valid as a monitored_condition
New sensors for alerts are:
warnings
watches
advisories
statements
endings
The component files have been updated on Dropbox and Github. The env_canada library has also been updated to 0.0.6, and this will need to be installed as well.
Thanks again to everyone for all of your help, and keep the bug reports and suggestions coming!
Thanks @michaeldavie. Running the latest version of env_canada and the custom component. Looks like sensor.py fails if there are no alerts in the EC data on startup:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py", line 128, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=hass.loop)
File "/usr/local/lib/python3.5/asyncio/tasks.py", line 406, in wait_for
return fut.result()
File "/usr/local/lib/python3.5/asyncio/futures.py", line 294, in result
raise self._exception
File "/usr/local/lib/python3.5/concurrent/futures/thread.py", line 55, in run
result = self.fn(*self.args, **self.kwargs)
File "/root/.homeassistant/custom_components/environment_canada/sensor.py", line 103, in setup_platform
for sensor_type in config[CONF_MONITORED_CONDITIONS]])
File "/root/.homeassistant/custom_components/environment_canada/sensor.py", line 103, in <listcomp>
for sensor_type in config[CONF_MONITORED_CONDITIONS]])
File "/root/.homeassistant/custom_components/environment_canada/sensor.py", line 116, in __init__
self.update()
File "/usr/local/lib/python3.5/site-packages/homeassistant/util/__init__.py", line 224, in wrapper
result = method(*args, **kwargs)
File "/root/.homeassistant/custom_components/environment_canada/sensor.py", line 146, in update
self.ec_data.conditions.update(self.ec_data.alerts)
AttributeError: 'ECData' object has no attribute 'alerts'
That’s odd. The alerts dictionary is created when the ECData object is created, so I’m not sure how it could be absent. Maybe try removing all versions of env_canada and installing just 0.0.6?
Not sure why but a restart of Home Assistant allowed the custom component to load correctly. Now seeing the new sensors. Perhaps some cache somewhere… Thanks!
The overlay looks good! Working well for me with the McGill radar. Tested on HA 0.89.0.
@michaeldavie given the testing and feedback you have received here, I suggest rebasing your PR onto 0.89.0 and asking for a review one more time. You mentioned lack of familiarity with Git a few months back but it looks like you have it under control now if you need help feel free to DM me.
@davidbb Thanks! I was thinking the same thing. Everything seems to be running smoothly now (thanks to all of the feedback!), so I think I’ll push all three components into the same PR.
@rlongfield That should have upgraded the env_canada library, but you need to make sure that the custom_component files are in sync as well. They each have a line like the following, and the version numbers need to match: REQUIREMENTS = ['env_canada==0.0.7']. You also need to restart your container after updating everything.
The latest files are at the Dropbox and Github links above. Let me know if you have any trouble.