Trying to control a smart fan using tinytuya #477
-
Please lmk if this is the right place to ask. I am trying to control a smart fan (this one) using a raspberry pi. I am able to control the operating mode (on or off) of the fan. using import tinytuya
from tinytuya import Contrib
import time
fan = Contrib.ClimateDevice('dev_ID','IP_address','local_key',version = 3.3)
fan.turn_on()
time.sleep(3)
fan.turn_off() This seems to work just fine. However, when we try to set the fan speed using I tried to use To localise the problem, I used It returns :
The data that gets returned from the fan is: The function def status_json(self):
"""Wrapper around status() that replace DPS indices with human readable labels."""
status = self.status()["dps"]
return {
"Power On": status[self.DPS_POWER],
"Set temperature": status[self.DPS_SET_TEMP],
"Current temperature": status[self.DPS_CUR_TEMP],
"Fan speed": status[self.DPS_FAN],
"Temperature unit": status[self.DPS_TEMP_UNIT],
"Sleep preset On": status[self.DPS_SLEEP_PRESET],
"Swing On": status[self.DPS_SWING],
"Operating mode": status[self.DPS_STATE],
"Timer left": status[self.DPS_TIMER],
} Does anyone know why it only returns the first three but not the rest? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 10 replies
-
I believe |
Beta Was this translation helpful? Give feedback.
It's going to require some trial and error, but you should be able to do it without running the wizard.
Create a monitor script using https://github.com/jasonacox/tinytuya/blob/master/examples/monitor.py and, with it running, change the speed and mode in the phone app. You should see updates in the monitor script when you do that. Once you have the values for the different speeds/modes you can put together a script to control it. Something along the lines of: