I have a conditional weather warning card that fired on a binary sensor I created when it’s value was set to on. It works but I’d like to push this to the next level with my new HA install.
Currently I get a red card that says ‘Weather Alert’ and contains a link to Environment Canada’s Alert page for my area. This card pops for Advisories, Statements, Watches, or Warnings.
What I would like to do is have a separate card for each level, and each card a different colour and wording.
I thought if I had a Conditional card that still used the Binary sensor to trigger its appearence and then a Vertical Stack card with 4 more conditional cards inside the Vertical Stack. Each card would have a condition of state_not: ’ ’ and would appear when then appropriate sensor wasn’t blank.
The parent card (the binary sensor conditional card) triggers properly but it all the nested conditional cards appear.
In this setup Conditional Card 1 is triggered on a Binary Sensor being set to ‘on’
The Markdown Card is being used to mark that the Binary Sensor is active.
In this instance Conditional Card 2 should only be triggering when the sensor is not blank. However the sensor is blank and it’s being triggered.
I’m guessing that since Conditional Card 1 is true then all other Conditional Cards will also be true?
I thought about that but I was hoping to have the Weather Alert card only present when there is an Alert. Without the parent Conditional Card there is always a card visible.
I tried your suggestion but it doesn’t seem to work. I also tried one where I skipped the bad weather sensor while trying to get the state-switch working. I didn’t have any luck with that either.
type: 'custom:state-switch'
entity: sensor.advisories
template: "{% if states('sensor.advisories') != ' ' %} show-1 {% else %} dont_show {% endif %}"
states:
show-1:
type: markdown
content: >-
Environment Canada has issued a Weather Advisory
https://weather.gc.ca/warnings/report_e.html
title: Weather Advisory
dont_show:
type: markdown
content: Dont Show
title: Dont Show
I set a value for sensor.advisories in Dev Tools, States and nothing happens.
Paying attention to remove the space between the ''
OR
Maybe it would be simpler to create some new binary_sensors in your configuration.yaml that take into account both the weather_alert and the advisories sensor.
For example,
binary_sensor:
- platform: template
sensors:
weather_alert_on_advisories_on:
value_template: >-
{{ is_state('binary_sensor.bad_weather','on') and not is_state('sensor.advisories','') }}
This will result in a new binary_sensor that turns on when both conditions are active.
Thenk you can use this new sensor, in a conditional card, for example, without having to do all the templating in the front-end.
type: 'custom:state-switch'
entity: sensor.advisories
template: >-
{% if states('sensor.advisories')
and it should have been
type: 'custom:state-switch'
entity: template
template: >-
{% if states('sensor.advisories')
It works like a charm, well except for multiple alerts issued (a watch and warning issued at the same time. That’s an issue with my if statements and the super quick fix is to invert the states so that Warnings override everything else. Since the links all go to the same page that isn’t an issue worth fixing.