Closed elockman closed 1 year ago
Does this actually work for you? My thermostat uses
INFO:main:Final result: {'dps': {'2': 'cool', '16': 2650, '17': 80, '23': 'f', '24': 2050, '29': 69, '34': 52, '45': 0, '107': '4', '108': 2650, '109': 1500, '110': 80, '111': 59, '115': 'auto', '116': '1', '119': False, '120': 'followschedule', '123': 20, '129': 'alloff'}}
And setting scale=100 is going to totally screw up the values for DPs 110 and 111.
No, I'm still having issues...this PR can be canceled.
What issues are you seeing?
Background I am running code on an embedded linux pc. The code has lag when calling the python script, so I am converting it to an executable with pyinstaller.
Program I wrote this script that takes arguments for {local_key} {device_id} {ip_address} {cmd} {value}
from tinytuya import Contrib
import time
import sys
def main():
local_key = sys.argv[1]
device_id = sys.argv[2]
ip_address = sys.argv[3]
cmd = sys.argv[4]
value = sys.argv[5]
#call python with
#python tuyaSet.py {local_key} {device_id} {ip_address} {cmd} {value}
#use pyinstaller to create an executable file
# pyinstaller --onefile tuyaSet.py
#call executable with
# ./tuyaSet {local_key} {device_id} {ip_address} {cmd} {value}
tstatdev = Contrib.ThermostatDevice( device_id, ip_address, local_key )
if cmd=='mode':
tstatdev.setMode( value )
elif cmd=='fan':
tstatdev.setFan( value )
elif cmd=='fantime':
tstatdev.setFanRuntime( value )
elif cmd=='units':
tstatdev.setUnits( value )
elif cmd=='hold':
tstatdev.setHold( value )
elif cmd=='coolpoint':
tstatdev.status()
tstatdev.setCoolSetpoint( value, 'f' )
elif cmd=='coolpoint_c':
tstatdev.status()
tstatdev.setCoolSetpoint( value, 'c' )
elif cmd=='heatpoint':
tstatdev.status()
tstatdev.setHeatSetpoint( value, 'f' )
elif cmd=='heatpoint_c':
tstatdev.status()
tstatdev.setHeatSetpoint( value, 'c' )
elif cmd=='setpoint':
tstatdev.status()
tstatdev.setSetpoint( value, 'f' )
elif cmd=='setpoint_c':
tstatdev.status()
tstatdev.setSetpoint( value, 'c' )
elif cmd=='midpoint':
tstatdev.status()
tstatdev.setMiddleSetpoint( value, 'f' )
elif cmd=='midpoint_c':
tstatdev.status()
tstatdev.setMiddleSetpoint( value, 'c' )
elif cmd=='status':
data = tstatdev.status()
data = tstatdev.status()
print('Device status: %r' % data)
else:
print('invalid command')
if __name__ == "__main__":
main()
Testing Most of the code works, except setting setpoints. This is what I see from the terminal:
[user@pc tuya]$ python tuyaSet.py 50beb3d0a17fcf51 ebff6f86b19f24547fe8gk 192.168.1.106 status x
Device status: {'dps': {'2': 'auto', '16': 2100, '17': 70, '23': 'f', '24': 2000, '29': 68, '34': 45, '45': 0, '107': '5', '108': 2650, '109': 1550, '110': 80, '111': 60, '115': 'auto', '116': '1', '119': True, '120': 'temphold', '123': 20, '129': 'alloff'}, 'changed': [], 'changed_sensors': []}
[user@pc tuya]$ python tuyaSet.py 50beb3d0a17fcf51 ebff6f86b19f24547fe8gk 192.168.1.106 setpoint 72
[user@pc tuya]$ python tuyaSet.py 50beb3d0a17fcf51 ebff6f86b19f24547fe8gk 192.168.1.106 status x
Device status: {'dps': {'2': 'auto', '16': 2100, '17': 70, '23': 'f', '24': 2000, '29': 68, '34': 45, '45': 0, '107': '5', '108': 2650, '109': 1550, '110': 80, '111': 60, '115': 'auto', '116': '1', '119': True, '120': 'temphold', '123': 20, '129': 'coolfanon'}, 'changed': [], 'changed_sensors': []}
[user@pc tuya]$
As you mentioned earlier, there may be a delay with setpoints, however setting the setpoint changed the screen setpoints from 60 and 80 to -3 and 2. I'm not sure if this is a scaling issue or something else.
It appears to be sending 0 as the value. Setting coolpoint to 72, changes the screen cool setpoint to 0 Setting heatpoint to 72, changes the screen heat setpoint to 0
@uzlonewolf, I think I have my problem resolved.
I had to cast the argument value to an integer. For example:
tstatdev.setMiddleSetpoint( int(value), 'f' )
see issue #327