Duux Fan API reverse-engineered & written in Go
Reversed from the iOS app. Tested on a Whisper Flex model.
Only compatible with Duux Fans. Does not support other Duux devices.
This was written quickly whilst figuring out the API for Duux fans. It is functional, but there are many improvements that could be made. I won't be dedicating much time to it.
Log into your Duux account.
This emulates the login procedure of the app. You will be emailed a code to authenticate.
The API tokens are stored in your home folder. They are encrypted using the key defined in main.go
. This needs improvement as is not the most secure way of storing tokens.
There is currently no logic to make use of the refresh_token
provided. Whilst the access_token
does have an expires_in
value of over 12 weeks (7776000 seconds), this has not been tested.
login
None.
$ ./duux login
Logging in...
Enter your email:
[YOUR_EMAIL]
Successfully sent login code!
Please check your email.
Enter your login code:
[LOGIN_CODE]
Getting auth token...
Successfully got auth token!
API key saved
API key saved
Getting user...
User data saved to /your/home/folder/.duux-user.json
Successfully got user!
Log out of your Duux account.
The app does not communicate with the server when logging out - it simply abandons the token. Again, this process is emulated by deleting the access tokens & user data from your home folder.
logout
None.
$ ./duux logout
Logging out...
Successfully logged out!
Get all the fans associated with your Duux account.
This will technically return all Duux devices on your account, not just fans, however this code doesn't explicitly support any other devices - simply because I have none to test with!
You will need the ID shown here for controlling this device specifically.
getfans
None.
$ ./duux getfans
Getting sensors...
ID |Type |Name |Colour |Power |Mode |Speed |Vertical |Horizontal |Timer |MAC Address
12345 |20 |DUUX.1.108725 |Black |On |Natural |10 |1 |1 |6 hours |[DEVICE_MAC]
Set a default fan, to be assumed for all future commands.
This will list all the fans on your account (similar to getfans
), and ask for an ID to be used as the default fan.
For all future commands, you will not have to specify a fan ID. For example, power on
will suffice.
setdefault
None.
$ ./duux setdefault
Getting sensors...
ID |Type |Name |Colour |Power |Mode |Speed |Vertical |Horizontal |Timer |MAC Address
12345 |20 |DUUX.1.108725 |Black |On |Natural |10 |1 |1 |6 hours |[DEVICE_MAC]
Enter the ID of the fan you want to set as default:
12345
Successfully set default fan!
Get all the schedules set for your device.
getschedule <fan id>
- Fan ID: the ID of the fan to control, obtained from
getfans
. Not required if you have usedsetdefault
.
$ ./duux getschedule 12345
Getting schedule...
Schedule(s): 4
Schedule 239724:
- At 06:00:01, only on Monday
- Power: On
Schedule 239725:
- At 07:00, only on Monday
- Power: Off
Schedule 239728:
- At 06:00:01, only on Wednesday
- Power: On
- Mode: Normal
- Speed: 5
Schedule 239729:
- At 08:00, only on Wednesday
- Power: Off
Control the power of your fan.
power <fan id> <on/off>
- Fan ID: the ID of the fan to control, obtained from
getfans
. Not required if you have usedsetdefault
. - Power Action: the power action to perform,
on
oroff
$ ./duux power 12345 on
Setting power...
Successfully set power!
Set the speed of your fan.
speed <fan id> <speed, 1-26>
- Fan ID: the ID of the fan to control, obtained from
getfans
. Not required if you have usedsetdefault
.` - Speed: the speed to set the fan to, between 1 and 26
$ ./duux speed 12345 20
Setting speed...
Successfully set speed!
Set the air mode of your fan.
mode <fan id> <normal/natural/night>
- Fan ID: the ID of the fan to control, obtained from
getfans
. Not required if you have usedsetdefault
. - Air Mode: the mode to set, either
normal
,natural
, ornight
$ ./duux mode 12345 natural
Setting mode...
Successfully set mode!
Specify how long, from now, until your fan will power off.
If your fan is not currently powered on, it will be before the timer is started.
timer <fan id> <hours>
- Fan ID: the ID of the fan to control, obtained from
getfans
. Not required if you have usedsetdefault
. - Hours: how many hours, from now, for the fan to remain on for
$ ./duux timer 12345 5
Setting timer...
Setting power...
Successfully set power!
Successfully set timer!
Set which ways your fan will oscillate.
oscillation <fan id> <vertical/horizontal> <on/off>
- Fan ID: the ID of the fan to control, obtained from
getfans
. Not required if you have usedsetdefault
. - Direction: which direction change, either
vertical
orhorizontal
- Action: what to do with this mode,
on
oroff
./duux oscillation 12345 vertical on
Setting oscillation...
Successfully set oscillation!