Weather Alert Automation - Environment Canada

I need help setting up an automation with the Environment Canada integration.

I have a sensor.warning
when there is no warning the sensor state is nothing.

I want to trigger a tts message on my google speakers if there is a warning.

I tried setting up an automation

- id: '1607996304910'

  alias: Weather Warning

  description: ''

  trigger:

  - platform: state

    entity_id: sensor.warnings

  condition: []

  action:

  - service: tts.google_translate_say

    entity_id: media_player.whole_home_group

    data_template:

      message: '{{ states(''sensor.warnings'') }} in effect.'

  mode: single

I want it tor trigger when changed from NOTHING to ANYTHING
with the automation as written above, i get a message on my speakers " in effect " every 600 seconds (default update interval of integraton)
so it gets triggerd everytime the sensor is updated from NOTHING to NOTHING.
I know its wrong…
how do i do it right?

the inegeration info https://www.home-assistant.io/integrations/environment_canada/
put me onto this idea…
it gives an example Alert Script… but does not give an example of how to trigger the script.

is it possible to use a wildcard * in the TO field?
from : ‘’
to: ‘*’

would this be
from: nothing / to: anything?
??

as a condition:
Not ‘nothing’
! ‘nothing’ might have to play with that
Although you could just have it say for any state change since chances are you are initiating it during ‘nothing’ so any change will be ‘something’. I have a similair notification and I say for any state change, since ‘none’ in my case is the removal of the previous warning.

alias: Notification Weather Alert - Speaker
description: ''
trigger:
  - platform: state
    entity_id: sensor.nws_alerts
    attribute: spoken_desc
    for: '00:01:00'
condition:
  - condition: state
    entity_id: light.leviton_masterbed
    state: 'on'
action:
  - service: media_player.volume_set
    data:
      volume_level: 0.9
    entity_id: media_player.rpispeaker1
  - service: tts.marytts_say
    entity_id: media_player.rpispeaker1
    data_template:
      message: 'Weather Alert {{state_attr(''nws_alerts'', ''spoken_desc'')}}'
mode: single

To clarify, it only speaks if my bedroom light is on and has been in for a minute (reduces spurious warnings)

Thank you for helping… but i dont get it… or you are suggesting something I already tried.

the code I pasted above in first post, as far as I know is " any state change ".
it triggers every time the sensor updates, even if the state doesnt change from no state.
I think maybe its gets triggered because of an attribute “last updated”.

Or maybe i just dont have enough brain cells to understand what you are suggesting.

does this help?

image

There is no attribute that lists a warning.
Are using an integration to get this sensor or did you set it up manually?
If this only announces the time of the alert and not the alert itself then use ‘alert time’ as a trigger (see my example above and replace ‘spoken_desc’ with ‘alert time’

from the first post:
the integration info https://www.home-assistant.io/integrations/environment_canada/
yes, its an integration.
The warning is supposed to populate in the “state” section, not under attributes… if I understand this right.

If i type “Tornado” in the blank state section, hit “set state”, the speaker says " Tornado in effect ", using the code provided in the integration documentation.
This seems like its doing what it is supposed to do.

But they didnt provide any trigger info… hence my situation…

when there is no warning, state is empty. and the speaker says " in effect " every time the “updated” attribute updates…

That is the example they use. I use the ‘alert time’ as a condition in your automation.
You could send it to your phone as a notification to provide more information regarding weather (pun intended) it is triggered or not. You just have to wait for an actual warning.

When I was testing my automation out, I found an area that had warnings in effect and specifically set my location to be within that area just so I could test it.

so?

alias: Weather Warning
description: ''
trigger:
  - platform: state
    entity_id: sensor.warnings
    attribute: alert time
condition: []
action:
  - service: tts.google_translate_say
    entity_id: media_player.whole_home_group
    data_template:
      message: '{{ states(''sensor.warnings'') }} in effect.'
mode: single

( yes, i do realize i could just go try… but someone has to post an answer for the next person who reads)

I am trying to create exactly the same type of automation… did you get it working?
I know this is an old post, thought I would ask anyway.