-
need Python 3.10 +
-
Copy
.env.exampleto.envin the same folder ascontroller.py. -
Fill in
.env:TCL_USERNAME=0812345678 TCL_PASSWORD=your-password TCL_DEVICE_ID=DtR9MSvgAAE TCL_PHONE_PREFIX=66 TCL_COUNTRY=TH TCL_TIMEZONE=Asia/BangkokTCL_USERNAMEis the phone number or email you use in the TCL Home appTCL_DEVICE_IDi found it on my ac stickers on the right side
py controller.py status show power, set temperature and room temperature
py controller.py on turn the AC on
py controller.py off turn the AC off
py controller.py temp +1 raise the temperature by 1 (use -1 to lower it)
(temperature always in between 16 and 30 (its locked by TCL) )
TCL has no public API, so this script request the TCL home app
- Log in. It sends your username and an MD5 hash of your password to
pa.account.tcl.com, using the same headers as the Android app. TCL returns a login token, which is saved in.tcl_token.jsonand reused until it is close to expiring. - Get an AWS identity. It sends the token to TCL's IoT service (
loadBalance). The request is signed withmd5(timestamp + nonce). TCL replies with an AWS Cognito identity and the address of the AWS IoT server for your account. - Get AWS keys. It exchanges that identity with AWS Cognito for temporary AWS keys.
- Talk to the AC. The AC is controlled through an AWS IoT "device shadow", a JSON copy
of the AC's state kept in the cloud.
statusreads the shadow.on,offandtemppublish a change such as{"powerSwitch": 1}or{"targetTemperature": 24}to$aws/things/<device id>/shadow/update. The AC picks up the change from the shadow.
