2 speed Whole House Fan Template issue

Hello, I have a whole house fun that i can control with 2 zwave switches.
One of them for on/off the other one for low/high speed.
Everything works fine, but i wanted to combine both into a template.
There are plenty of examples around and i have something that works , but there are some issues.
Touching the slider and changing the speed also changes the on/off state of the fan. Also the fan state doesnt turn off till i drag the speed to 0 (zero)
Is there a way to change the code to fix those 2 issues?
Thanks in advance

# Whole House Fan
- platform: template
        friendly_name: "House Fan"
        value_template: "{{ states('input_boolean.whf_status') }}"
        percentage_template: "{% if is_state('switch.whf_speed', 'on') %}10{% else %}100{% endif %}"
          service: homeassistant.turn_on
            entity_id: switch.whole_house_fan
          - service: homeassistant.turn_off
              entity_id: switch.whole_house_fan
          - service: input_boolean.turn_off
              entity_id: input_boolean.whf_status
          service: homeassistant.toggle
            entity_id: switch.whf_speed

If you slide the slider to some speed then that should change the fan state to on. if you slide it to 0 speed that should turn the fan state to off.

if that’s what you are seeing then that is expected and so it’s not an issue.

As noted above it should change the state to off if you slide it to 0.

but you should also have a toggle button that changes the state as well. so you should be able to turn it off directly with the toggle.

are you not seeing that?