template:
- sensor:
- name: ws_xiaomi_at
device_class: temperature
unit_of_measurement: °C
state: >
{% set st = states('sensor.t2_cloud_t05c00_temperature') | float %}
{% set sh = states('sensor.t2_cloud_t05c00_humidity') | float %}
{% set st = 1.8 * st + 32 | float %}
{% set hi = 0.5 * (st + 61 + (st - 68) * 1.2 + sh * 0.094) | float %}
{% if hi >= 80 -%}
{% set hi = -42.379 + 2.04901523 * st + 10.14333127 * sh - 0.22475541 * st * sh
- 0.00683783 * st * st - 0.05481717 * sh * sh + 0.00122874 * st * st * sh
+ 0.00085282 * st * sh * sh - 0.00000199 * st * st * sh * sh | float %}
{% if sh < 13 and 80 < st < 112 -%}
{% set adjustment = (13 - sh) / 4 * sqrt((17 - abs(st - 95)) / 17) | float %}
{% set hi = hi - adjustment | float %}
{% elif sh > 85 and 80 < st < 87 %}
{% set adjustment = (sh - 85) * (87 - st) / 50 | float %}
{% set hi = hi + adjustment | float %}
{%- endif %}
{%- endif %}
{{((hi - 32) / 1.8)|round(1)}}