Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API updates state but actual thermostat unit does not #15

Closed
pabo opened this issue May 7, 2021 · 3 comments
Closed

API updates state but actual thermostat unit does not #15

pabo opened this issue May 7, 2021 · 3 comments

Comments

@pabo
Copy link

pabo commented May 7, 2021

I'm seeing a behavior I can't explain. (Spoiler alert: by the end of this post I think I've explained it)

  1. Using wyze-sdk, check the status of the fan mode, which shows ThermostatFanMode.ON
therm = client.thermostats.info(device_mac='CO_EA1_3130XXXXX')
print(therm.fan_mode)
  1. Using wyze-sdk, set the fan mode to AUTO:
client = Client(email='XXXX', password='XXXX')
client.thermostats.set_fan_mode(
    device_mac='CO_EA1_31304635103637394a414c5b',
    device_model='CO_EA1',
    fan_mode=ThermostatFanMode.AUTO
)
  1. Using wyze-sdk, check the status of the device. It is in fact set to ThermostatFanMode.AUTO
therm = client.thermostats.info(device_mac='CO_EA1_3130XXXXX')
print(therm.fan_mode)
  1. Using the Wyze iPhone app, check the status of the device. It also shows the fan set to Auto.

All of that makes sense. What doesn't make sense is:

  1. The thermostat itself, sitting on my wall, still has the fan mode set to ON.
  2. If I use the Wyze app to change the fan mode, everything works - calls to client.thermostats.info show the right status, the app shows the right status, and the unit on the wall shows the right status.

How the heck is the unit on the wall not updating from this wyze-sdk, but is updating from the app?

I set up a proxy to see what was going on.

Here's a request from the wyze-sdk via set_fan_mode():

  | POST /plugin/earth/set_iot_prop HTTP/1.1
-- | --
Host | wyze-earth-service.wyzecam.com
User-Agent | okhttp/4.7.2
Accept-Encoding | gzip
Accept | */*
Connection | keep-alive
appid | 9319141212m2ik
appinfo | wyze_android_2.19.14
phoneid | XXXX
access_token | XXXXXX==
requestid | ea37483189b62b407c2ea0f9251c7e0c
signature2 | ebf081f4a8f63431a1dd7bac3fa1d26a
Content-Length | 128
Content-Type | application/json

{
	"did": "CO_EA1_3130XXXX",
	"model": "CO_EA1",
	"props": {
		"fan_mode": "auto"
	},
	"is_sub_device": 0,
	"nonce": "1620348740786"
}

and here's a request from my iphone app:

:method | POST
-- | --
:scheme | https
:path | /plugin/earth/set_iot_prop_by_topic
:authority | wyze-earth-service.wyzecam.com
content-type | application/json
appid | XXXX
appinfo | wyze_ios_2.19.24
accept | */*
requestid | 7defc485b1315390b1a95445f78b276f
accept-language | en-US;q=1, el-US;q=0.9
accept-encoding | gzip, deflate, br
content-length | 128
user-agent | Wyze/2.19.24 (iPhone; iOS 14.4.2; Scale/3.00)
signature2 | bd6e10ca3b7f9968d547fed975b1ae03
phoneid | XXXX
access_token | XXXX==

{
	"did": "CO_EA1_3130XXXX",
	"nonce": "1620349892154",
	"props": {
		"fan_mode": "auto"
	},
	"model": "CO_EA1",
	"is_sub_device": 0
}

The big difference I see here is the endpoint set_iot_prop_by_topic vs set_iot_prop. It looks like when setting one topic, the two endpoints accept the same signature of props. So I updated my locally running wyze-sdk to use set_iot_prop_by_topic instead, and voila! It updates my wall unit.

If I had to guess, maybe the set_iot_prop endpoint has a bug where it updates the state server side, which works for any clients that are polling, but doesn't push out any updates to the actual wall unit.

Not sure if you want to update all instances of set_iot_prop to set_iot_prop_by_topic, or just wait around for Wyze to maybe fix their endpoint.

@shauntarves
Copy link
Owner

@pabo good sleuthing. It looks like set_iot_prop is only used for resetting the filters and updating schedule information - the way I read it, basically anything that doesn't talk to the actual thermostat.

Please pull branch 15-api-updates-state-but-actual-thermostat-unit-does-not and re-test. If this works better, I will create a new official release

@pabo
Copy link
Author

pabo commented May 10, 2021

@shauntarves It worked perfectly on that branch

@shauntarves
Copy link
Owner

Merged into 1.1.3 and published to pypi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants