kodi1 / meteoalarm

meteoalarm sensor
http://meteoalarm.eu/
5 stars 1 forks source link

Formating output #8

Closed Tom-ahawk closed 4 years ago

Tom-ahawk commented 4 years ago

Using your code in a markdown card. Today looks OK, but tomorrow is not displayed correctly. Any ideas why?

image

card:
  content: |
    {% if not is_state('sensor.meteorologisk_alarm', '0') %}
      {% for s  in ['today', 'tomorrow'] %}
        {% set v = state_attr('sensor.meteorologisk_alarm', s) %}
          {% if v -%}
            {% for d  in v -%}
             **<font color="red">Meteorologisk alarm - {{s}}</font>**
             **Event:**
              {{d['event']}}
             **Severity:**  
              {{d['code']}} 
             **Time:**
              {{d['start']}} - {{d['end']}}
             **Description:**
               {{d['norsk']}}
            {% endfor %}
          {% endif %}
      {% endfor -%}
    {% endif %}      
  type: markdown
conditions:
  - entity: sensor.meteorologisk_alarm
    state_not: '0'
type: conditional
Tom-ahawk commented 4 years ago

Copied your code, and then it worked, : D

Here are code with event icons: image

    {% if not is_state('sensor.meteorologisk_alarm', '0') %}
      {% for s  in ['today'] %}
        {% set v = state_attr('sensor.meteorologisk_alarm', s) %}
          {% if v -%}
            {% for d  in v -%}
             **<font color="red">Meteorological alarm - {{s}}</font>**
             **Event:**
             {%if d['event'] == 'Forestfire'%}   <ha-icon icon='mdi:pine-tree'> </ha-icon> {% endif %}{%if d['event'] == 'Wind'%}<ha-icon icon='mdi:weather-windy'></ha-icon>{% endif %}{%if d['event'] == 'Snow/Ice'%}<ha-icon icon='mdi:snowflake-melt'></ha-icon>{% endif %}{%if d['event'] == 'Thunderstorm'%}<ha-icon icon='mdi:weather-lightning'></ha-icon>{% endif %}{%if d['event'] == 'Fog'%}<ha-icon icon='mdi:weather-fog'></ha-icon>{% endif %} {%if d['event'] == 'Extreame high Temp'%}<ha-icon icon='mdi:thermometer-plus'></ha-icon>{% endif %}{%if d['event'] == 'Extreame low temp'%}<ha-icon icon='mdi:thermometer-minus'></ha-icon>{% endif %}{%if d['event'] == 'Costal evenet'%}<ha-icon icon='mdi:sland'></ha-icon>{% endif %}{%if d['event'] == 'Avalances'%}<ha-icon icon='mdi:snowflake-variant'></ha-icon>{% endif %}{%if d['event'] == 'Rain'%}<ha-icon icon='mdi:weather-rainy'></ha-icon>{% endif %}{%if d['event'] == 'Flood'%}<ha-icon icon='mdi:waves'></ha-icon>{% endif %}{%if d['event'] == 'Rain-Flood'%}<ha-icon icon='mdi:weather-pouring'></ha-icon>{% endif %}{{d['event']}}
             **Severity:**  
              {{d['code']}} 
             **Time:**
              {{d['start']}} - {{d['end']}}
             **Description:**
               {{d['norsk']}}
            {% endfor %}
          {% endif %}
      {% endfor -%}
    {% endif %}