借chatgpt实现的
默认是折叠状态
点击标题后展开状态
根据预警等级显示相应颜色,例如红色预警将显示红色字体
天气使用的 dscao 大佬的和风天气
type: markdown
content: |
{% set warnings = (state_attr('weather.tian_qi', 'warning') or [])
| selectattr('sender', 'defined')
| selectattr('sender', 'search', '淮安区气象台')
| list %}
{% if warnings | length > 0 %}
{% set warning = warnings[0] %}
{% set color =
'#FF0000' if warning.severityColor == 'Red' else
'#FF9900' if warning.severityColor == 'Orange' else
'#D4A017' if warning.severityColor == 'Yellow' else
'#0066FF' if warning.severityColor == 'Blue' else
'#000000' %}
{% set clean_text = warning.text | replace('区应急局、区气象局联合提醒注意防范。', '') %}
<details>
<summary>
<big><b><font color="{{ color }}">
<ha-icon icon="mdi:cloud-alert-outline"></ha-icon>
{{ warning.title }}
</font></b></big>
</summary>
<b><font color="{{ color }}">
<br>
{{ clean_text }}
</font></b>
</details>
{% else %}
当前无气象预警信息
{% endif %}
text_only: true
配合卡片的可见性功能,可实现有预警显示,无预警隐藏
|