type: custom:stack-in-card
cards:
- type: markdown
content: >
{% if state_attr('sensor.weather_alerts','entries') != 0 %}
{% for item in state_attr('sensor.weather_alerts','entries') %}
{% for type, icon in
[
('extreme heat', 'weather-sunny-alert'),
('fog', 'weather-fog'),
('ice', 'car-traction-control'),
('lightning', 'weather-lightning'),
('rain', 'weather-pouring'),
('rain, wind', 'weather-pouring'),
('snow', 'weather-snowy-heavy'),
('snow, ice', 'weather-snowy-heavy'),
('thunderstorm', 'weather-lightning'),
('thunderstorms', 'weather-lightning-rainy'),
('wind', 'weather-windy')
('flood', 'flooding')
]
if type == item.summary | regex_findall_index('.*warning of (.*) affecting Somerset.*', ignorecase=True) %}
{% set color = item.summary.split(' ')[0] %}
{% set summary = item.summary | regex_findall_index('(.*) affecting South West England: (.*) valid from (.*) to (.*)', ignorecase=True) %}
{% set link = item.link %}
{% set time_utc_from = summary[2][0:2] ~':'~ summary[2][2:4] %}
{% set time_utc_to = summary[3][0:2] ~':'~ summary[3][2:4] %}
{% set date_from = summary[2][5:8] +'-'+ summary[2][9:11] +'-'+ summary[2][12:] %}
{% set date_to = summary[3][5:8] +'-'+ summary[3][9:11] +'-'+ summary[3][12:] %}
{% set time_local_from = ((now().date() ~ ' ' ~ time_utc_from ~ "+00:00") | as_datetime | as_local).strftime('%H:%M') %}
{% set time_local_to = ((now().date() ~ ' ' ~ time_utc_to ~ "+00:00") | as_datetime | as_local).strftime('%H:%M') %}
| | |
| -: | -- |
| <font color = {%- if 'Yellow' == color %}'gold' {%- elif 'Amber' ==
color %}'darkorange' {%- else %}'firebrick' {%- endif %}> <ha-icon icon={{
"'mdi:" + icon + "'" }}> </ha-icon></font> | <a href='{{ link }}'>**{{
summary[0] }}** </a> |
|| from **{{ time_local_from }}** to **{{ time_local_to }}** on **{{
date_from }}** |
{% endfor %}
<br>
{% endfor %}
{% else %} No warnings at present {% endif %}
Could you help me with the correct format for Somerset & south west?
I’m wondering if I’m adding my sensors wrong?
When you have more than 1 sensor is it correct to use sensor again or should they all be under a single class?
sensor:
######## Frost Sensor:
- platform: template
sensors:
24hrlowtemp:
value_template: >
{% set start = now().replace(hour=0,minute=0,second=0, microsecond=0) %}
{% set end = (start + timedelta(days=1)) %}
{% set start = start.strftime("%Y-%m-%dT%H:%M:%S+00:00") %}
{% set end = end.strftime("%Y-%m-%dT%H:%M:%S+00:00") %}
{{ state_attr('weather.forecast_home', 'forecast') | selectattr('datetime', '>=', start) | selectattr('datetime','<=', end) | map(attribute='templow') | list | max }}
### Weather - Tomo Rain Probability
template:
- sensor:
name: rain tomo
state: >
{{ state_attr('weather.home', 'forecast')[1].precipitation_probability }}
### Weather - Alerts System
sensor: #-----------------------------------------------------------------------
- platform: feedparser
name: "Weather Alerts"
feed_url: 'https://www.metoffice.gov.uk/public/data/PWSCache/WarningsRSS/Region/sw'
date_format: '%a, %b %d %I:%M %p'
inclusions:
- summary
- link