I'm working with a Dyson fan and am trying to write a function that increases the speed of the fan. The enum object FanSpeed has the following members. When I execute [print(i) for i in FanSpeed] I get:
FanSpeed.FAN_SPEED_1
FanSpeed.FAN_SPEED_2
FanSpeed.FAN_SPEED_3
FanSpeed.FAN_SPEED_4
FanSpeed.FAN_SPEED_5
FanSpeed.FAN_SPEED_6
FanSpeed.FAN_SPEED_7
FanSpeed.FAN_SPEED_8
FanSpeed.FAN_SPEED_9
FanSpeed.FAN_SPEED_10
So the first enum object (above) has the name FAN_SPEED_1 (FanSpeed.FAN_SPEED_1.name) and has a value of "0001" (FanSpeed.FAN_SPEED_1.value), and so on.
The function to set speed (to 5 in this example is):
fan.set_configuration(fan_mode=FanMode.FAN, fan_speed=FanSpeed.FAN_SPEED_5)
I can't figure out how to write a function that gets the current speed and then sets it to one level higher. I've tried:
1/ Treating the enum object as a a string and replacing the last character with a number (character type) that's higher. This approach doesn't work for enum objects though.
2/ Looking for some kind of increment or next function but those don't seem to exist for enum objects.