Fan Speed Automation Help

I am somewhat new to home assistant and I want to create an automation that when I press the power on button on my zwave switch, if the ceiling fan is already on, it increases the speed of the fan. If its already on high it goes to the lowest speed.

I created an automation but its not triggering for some reason

alias: Master Fan Speed
description: Set fan speed when the fan is already on
trigger:
  - platform: device
    type: turned_on
    device_id: 23cae5913868b362bf111063cb198941
    entity_id: fan.gezwavemasterfan
    domain: fan
condition:
  - condition: device
    device_id: 23cae5913868b362bf111063cb198941
    domain: fan
    entity_id: fan.gezwavemasterfan
    type: is_on
action:
  - if:
      - condition: numeric_state
        entity_id: fan.gezwavemasterfan
        above: 1
        below: 50
        attribute: fan.percentage
    then:
      - service: fan.set_percentage
        target:
          entity_id:
            - fan.gezwavemasterfan
        data:
          percentage: 66
  - if:
      - condition: numeric_state
        entity_id: fan.gezwavemasterfan
        above: 51
        below: 75
        attribute: fan.percentage
    then:
      - service: fan.set_percentage
        target:
          entity_id:
            - fan.gezwavemasterfan
        data:
          percentage: 99
  - if:
      - condition: numeric_state
        entity_id: fan.gezwavemasterfan
        above: 76
        below: 100
        attribute: fan.percentage
    then:
      - service: fan.set_percentage
        target:
          entity_id:
            - fan.gezwavemasterfan
        data:
          percentage: 33
mode: single

I can see messages in the console
ge-zwave-master-fan turned on triggered by service fan.set_percentage

if the fan is already on then you can’t turn it on again. so the device trigger you have won’t work:

  trigger:
  - platform: device
    type: turned_on
    device_id: 23cae5913868b362bf111063cb198941
    entity_id: fan.gezwavemasterfan
    domain: fan

you should use an event trigger looking at the event generated by the power button to trigger the automation.

also I don’t think you should use (for example) “fan.percentage” as the attribute in the condition

I think the attribute should just be “percentage”.

make those changes and see if you can get it working.

I don’t believe the GE fan switches will log anything besides turning on or turning off. So, like @finity mentioned, your trigger will not work nor is there a way to do what you want with the switch by itself. You could use a button device to do so though.

They must have some way of controlling the speed, not just on off. So there must be something that the switch (or fan) generates that HA can consume and then interact with.

Typically that is an event sent by the switch.

as long as the fan supports multi speeds then this should be doable.

I guess my only question is, if the fan already supports multiple speeds then why not just use the speed button(s) on the remote to set the speeds instead of the power button of the remote.

I could understand if you were using an external switch/controller (I do exactly that with my fans using an external scene switch that’s not part of the fan system to control the fan) but not if you are just using the same fan remote.

is there some reason why you need to do what you are asking?