Home Assistant 湿球温度传感器配置指南
First, you need to create a helper.
Settings → Devices & services → Helpers → Create helper → Template → Sensor
Name it 'wet bulb', set its measurement to °C, then paste in the following (you will need to change the sensor names to match those in the respective weather station or room):
{% set temp_entity = 'sensor.alpstuga_air_quality_monitor_temperature' %}
{% set rh_entity = 'sensor.alpstuga_air_quality_monitor_humidity' %}
{% set temp = states(temp_entity) | float(none) %}
{% set rh = states(rh_entity) | float(none) %}
{% if temp is none or rh is none %}
unknown
{% else %}
{% set wbt = temp atan(0.151977 ((rh + 8.313659) ** 0.5))
• atan(temp + rh)
• atan(rh - 1.676331)
• (0.00391838 * (rh ** 1.5) atan(0.023101 rh))
• 4.686035 %}
{% set wbgt = (0.7 wbt) + (0.3 temp) %}
{{ wbgt | round(1) if wbgt is not none else 'unknown' }}
{% endif %}
Once the helper is in, make sure you have Apex Charts and Mushroom installed (via HACS), make a new card, drop this into the code. Change the 'states' lines near the top to reflect your real sensors:
type: vertical-stack
cards:
• type: custom:mushroom-template-card
entity: sensor.wet_bulb
primary: |
{{ states('sensor.wet_bulb') }}°C WBGT
secondary: >
{% set w = states('sensor.wet_bulb') | float(none) %} {% set t =
states('sensor.alpstuga_air_quality_monitor_temperature') %} {% set h =
states('sensor.alpstuga_air_quality_monitor_humidity') %} {% if w is none %}
Unavailable · Temp {{ t }}°C · RH {{ h }}%
{% elif w < 25 %}
Low · Temp {{ t }}°C · RH {{ h }}%
{% elif w < 27.8 %}
Elevated · Temp {{ t }}°C · RH {{ h }}%
{% elif w < 29.4 %}
Warning · Temp {{ t }}°C · RH {{ h }}%
{% elif w < 31.7 %}
Dangerous · Temp {{ t }}°C · RH {{ h }}%
{% else %}
Extreme · Temp {{ t }}°C · RH {{ h }}%
{% endif %}
icon: mdi:sun-thermometer
icon_color: |
{% set w = states('sensor.wet_bulb') | float(none) %} {% if w is none %}
grey
{% elif w < 25 %}
blue
{% elif w < 27.778 %}
green
{% elif w < 29.44 %}
amber
{% elif w < 31.778 %}
red
{% else %}
purple
{% endif %}
badge_icon: |
{% set w = states('sensor.wet_bulb') | float(none) %} {% if w is none %}
mdi:help
{% elif w < 27.778 %}
mdi:check
{% elif w < 29.44 %}
mdi:alert
{% elif w < 31.778 %}
mdi:fire-alert
{% else %}
mdi:skull-crossbones
{% endif %}
badge_color: |
{% set w = states('sensor.wet_bulb') | float(none) %} {% if w is none %}
grey
{% elif w < 27.778 %}
green
{% elif w < 29.44 %}
amber
{% elif w < 31.778 %}
red
{% else %}
purple
{% endif %}
layout: horizontal
tap_action:
action: more-info
• type: gauge
entity: sensor.wet_bulb
name: Wet Bulb Risk
min: 12.77
max: 37.778
needle: true
severity:
green: 25
yellow: 27.778
red: 29.44
• type: custom:apexcharts-card
experimental:
color_threshold: true
graph_span: 12h
header:
show: true
title: Wet Bulb history
show_states: true
colorize_states: true
yaxis:
• min: 21.111
max: 37.778
decimals: 1
apex_config:
chart:
height: 220
legend:
show: false
annotations:
yaxis:
• "y": 21.111
y2: 25
fillColor: "#2196f3"
opacity: 0.1
• "y": 25
y2: 27.778
fillColor: "#4caf50"
opacity: 0.1
• "y": 27.778
y2: 29.444
fillColor: "#ffc107"
opacity: 0.14
• "y": 29.555
y2: 31.667
fillColor: "#f44336"
opacity: 0.13
• "y": 31.667
y2: 37.778
fillColor: "#9c27b0"
opacity: 0.15
series:
• entity: sensor.wet_bulb
name: WBGT
type: area
stroke_width: 3
unit: °C
color_threshold:
• value: 21.1
color: "#2196f3"
• value: 25
color: "#4caf50"
• value: 27.778
color: "#ffc107"
• value: 29.44
color: "#f44336"
• value: 31.778
color: "#9c27b0"
group_by:
duration: 5min
func: avg