Template Fan value resets to 1% when turned on

Tags: #<Tag:0x00007fc3ffbadc98>

I’ve got an extremely simple fan template setup right now. For some reason, whenever I turn this template fan off and on again, the fan speed percentage becomes 1%, even though the input_number helper still has its old value. For example, I would set the fan speed to 33% (my fan has 9 speeds), then turn the fan off. When I turn the fan back on, the fan speed for the fan would show up as 1% instead of 33%. When I check the input_number entity, it still shows as 33%.

Does anyone know why that might be?

Here’s my really simple template:

  - platform: template
        friendly_name: "Living Room Fan"
        unique_id: "living_room_fan"
        value_template: "{{ states('input_boolean.ceiling_fan_state') }}"
        speed_template: "{{ states('input_number.ceiling_fan_speed') }}"
        speed_count: 9
          service: input_boolean.turn_on
            entity_id: input_boolean.ceiling_fan_state
          service: input_boolean.turn_off
            entity_id: input_boolean.ceiling_fan_state
          service: input_number.set_value
            entity_id: input_number.ceiling_fan_speed
            value: "{{ percentage }}"

My input_number is set to have a minimum of 0 and a maximum of 100, with a step size of 1. I’m currently detecting the change in the input_number and input_boolean to control the fan, which is why you don’t see me calling any services in the template.

That’s likely important to include as well

I resolved the problem! It turns out I was using speed_template instead of percentage_template in the config! Once the config was updated, the percentage no longer resets. Perhaps the reason why it always “resets” was that speed_template expected a much smaller value than the percentage value in my input_number.

Only noticed this as I was re-reading my post. I guess this was a case of rubber ducky debugging haha.