Hi,
I read a lot about the template migration to the new format but still don’t get it entirely.
I got 61 warnings for migrating my templates.
I use a splitting setup and these are the corresponding lines in my configuration yaml:
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
binary_sensor: !include binary_sensors.yaml
switch: !include switches.yaml
sensor: !include sensors.yaml
notify: !include notifications.yaml
alarm_control_panel: !include alarm_control_panel.yaml
In order to understand the procedure I started with the small file switches.yaml. This looks like this:
#====================================#
# Switch - Smart Mi Humidifier 2 #
#====================================#
- platform: template
switches:
smart_mi_humidifier_2_dry:
friendly_name: "Dry Mode"
value_template: "{{ is_state_attr('fan.smart_mi_humidifier_2', 'dry', true) }}"
turn_on:
action: xiaomi_miio_airpurifier.fan_set_dry_on
data:
entity_id: fan.smart_mi_humidifier_2
turn_off:
action: xiaomi_miio_airpurifier.fan_set_dry_off
data:
entity_id: fan.smart_mi_humidifier_2
icon_template: mdi:lightbulb-outline
smart_mi_humidifier_2_child_lock:
friendly_name: "Child lock"
value_template: "{{ is_state_attr('fan.smart_mi_humidifier_2', 'child_lock', true) }}"
turn_on:
action: xiaomi_miio_airpurifier.fan_set_child_lock_on
data:
entity_id: fan.smart_mi_humidifier_2
turn_off:
action: xiaomi_miio_airpurifier.fan_set_child_lock_off
data:
entity_id: fan.smart_mi_humidifier_2
icon_template: "mdi:lock-outline"
smart_mi_humidifier_2_buzzer:
friendly_name: "Buzzer"
value_template: "{{ is_state_attr('fan.smart_mi_humidifier_2', 'buzzer', true) }}"
turn_on:
action: xiaomi_miio_airpurifier.fan_set_buzzer_on
data:
entity_id: fan.smart_mi_humidifier_2
turn_off:
action: xiaomi_miio_airpurifier.fan_set_buzzer_off
data:
entity_id: fan.smart_mi_humidifier_2
icon_template: "mdi:volume-high"
Based on the recommendation
Note: If you are using
switch: !include <filename>.yamlinconfiguration.yaml, remove the switch definition from the included<filename>.yaml.
I ended up with this but it doesn’t seem right and of course also doesn’t work:
#====================================#
# Switch - Smart Mi Humidifier 2 #
#====================================#
template:
- turn_on:
- action: xiaomi_miio_airpurifier.fan_set_dry_on
data:
entity_id: fan.smart_mi_humidifier_2
turn_off:
- action: xiaomi_miio_airpurifier.fan_set_dry_off
data:
entity_id: fan.smart_mi_humidifier_2
default_entity_id: switch.smart_mi_humidifier_2_dry
icon: mdi:lightbulb-outline
name: Dry Mode
state: '{{ is_state_attr(''fan.smart_mi_humidifier_2'', ''dry'', true) }}'
- turn_on:
- action: xiaomi_miio_airpurifier.fan_set_child_lock_on
data:
entity_id: fan.smart_mi_humidifier_2
turn_off:
- action: xiaomi_miio_airpurifier.fan_set_child_lock_off
data:
entity_id: fan.smart_mi_humidifier_2
default_entity_id: switch.smart_mi_humidifier_2_child_lock
icon: mdi:lock-outline
name: Child lock
state: '{{ is_state_attr(''fan.smart_mi_humidifier_2'', ''child_lock'', true)
- turn_on:
- action: xiaomi_miio_airpurifier.fan_set_buzzer_on
data:
entity_id: fan.smart_mi_humidifier_2
turn_off:
- action: xiaomi_miio_airpurifier.fan_set_buzzer_off
data:
entity_id: fan.smart_mi_humidifier_2
default_entity_id: switch.smart_mi_humidifier_2_buzzer
icon: mdi:volume-high
name: Buzzer
state: '{{ is_state_attr(''fan.smart_mi_humidifier_2'', ''buzzer'', true) }}'
Can anyone point me to the right way of migrating this switches.yaml?
thanks in advance