Keep getting an error with this admittedly ugly template, and am not seeing the issue:
2024-12-22 17:25:47.875 ERROR (MainThread) [homeassistant.config] Invalid config for 'fan' from integration 'template' at packages/air_quality.yaml, line 81: template value should be a string for dictionary value 'fans->air_purifier->set_preset_mode->0->data', got {'device': 'air_purifier', 'command': "{% if preset_mode == 'turbo' and state_attr('fan.air_purifier', 'preset_mode') == 'high'%}\n up\n{% elif preset_mode == 'turbo' and state_attr('fan.air_purifier', 'preset_mode') == 'medium'%}\n up\n{% elif preset_mode == 'turbo' and state_attr('fan.air_purifier', 'preset_mode') == 'low'%}\n up\n{% if preset_mode == 'high' and state_attr('fan.air_purifier', 'preset_mode') == 'turbo'%}\n down\n{% elif preset_mode == 'high' and state_attr('fan.air_purif..., please check the docs at https://www.home-assistant.io/integrations/template
- platform: template
fans:
air_purifier:
friendly_name: "Air Purifier"
value_template: >-
{% if states('sensor.living_room_air_purifier_power_power')|int > 0 %}
on
{% else %}
off
{% endif %}
turn_on:
- action: remote.send_command
target:
entity_id: remote.universal_remote
data:
device: air_purifier
command: power
turn_off:
- action: remote.send_command
target:
entity_id: remote.universal_remote
data:
device: air_purifier
command: power
preset_modes:
- "low"
- "medium"
- "high"
- "turbo"
preset_mode_template: >-
{% if states('sensor.living_room_air_purifier_power_power')|int > 40 %}
turbo
{% elif states('sensor.living_room_air_purifier_power_power')|int > 15 %}
high
{% elif states('sensor.living_room_air_purifier_power_power')|int > 7 %}
medium
{% elif states('sensor.living_room_air_purifier_power_power')|int > 6 %}
low
{% else %}
off
{% endif %}
speed_count: 4
set_preset_mode:
- action: remote.send_command
target:
entity_id: remote.universal_remote
data:
device: air_purifier
command: >-
{% if preset_mode == 'turbo' and state_attr('fan.air_purifier', 'preset_mode') == 'high'%}
up
{% elif preset_mode == 'turbo' and state_attr('fan.air_purifier', 'preset_mode') == 'medium'%}
up
{% elif preset_mode == 'turbo' and state_attr('fan.air_purifier', 'preset_mode') == 'low'%}
up
{% if preset_mode == 'high' and state_attr('fan.air_purifier', 'preset_mode') == 'turbo'%}
down
{% elif preset_mode == 'high' and state_attr('fan.air_purifier', 'preset_mode') == 'medium'%}
up
{% elif preset_mode == 'high' and state_attr('fan.air_purifier', 'preset_mode') == 'low'%}
up
{% if preset_mode == 'medium' and state_attr('fan.air_purifier', 'preset_mode') == 'turbo'%}
down
{% elif preset_mode == 'medium' and state_attr('fan.air_purifier', 'preset_mode') == 'high'%}
down
{% elif preset_mode == 'medium' and state_attr('fan.air_purifier', 'preset_mode') == 'low'%}
up
{% if preset_mode == 'low' and state_attr('fan.air_purifier', 'preset_mode') == 'turbo'%}
down
{% elif preset_mode == 'low' and state_attr('fan.air_purifier', 'preset_mode') == 'high'%}
down
{% elif preset_mode == 'low' and state_attr('fan.air_purifier', 'preset_mode') == 'medium'%}
down
{% else %}
up
{% endif %}
num_repeats: >-
{% if preset_mode == 'turbo' and state_attr('fan.air_purifier', 'preset_mode') == 'high'%}
1
{% elif preset_mode == 'turbo' and state_attr('fan.air_purifier', 'preset_mode') == 'medium'%}
2
{% elif preset_mode == 'turbo' and state_attr('fan.air_purifier', 'preset_mode') == 'low'%}
3
{% if preset_mode == 'high' and state_attr('fan.air_purifier', 'preset_mode') == 'turbo'%}
1
{% elif preset_mode == 'high' and state_attr('fan.air_purifier', 'preset_mode') == 'medium'%}
1
{% elif preset_mode == 'high' and state_attr('fan.air_purifier', 'preset_mode') == 'low'%}
2
{% if preset_mode == 'medium' and state_attr('fan.air_purifier', 'preset_mode') == 'turbo'%}
2
{% elif preset_mode == 'medium' and state_attr('fan.air_purifier', 'preset_mode') == 'high'%}
1
{% elif preset_mode == 'medium' and state_attr('fan.air_purifier', 'preset_mode') == 'low'%}
1
{% if preset_mode == 'low' and state_attr('fan.air_purifier', 'preset_mode') == 'turbo'%}
3
{% elif preset_mode == 'low' and state_attr('fan.air_purifier', 'preset_mode') == 'high'%}
2
{% elif preset_mode == 'low' and state_attr('fan.air_purifier', 'preset_mode') == 'medium'%}
1
{% else %}
0
{% endif %}