webdjoe / pyvesync

pyvesync is a python library to manage Etekcity & Levoit smart devices
MIT License
175 stars 83 forks source link

Add support for Smart bulb ESL100MC #89

Closed mcrypt closed 1 year ago

mcrypt commented 3 years ago

It would be great if you could add support for ESL100MC "multicolor" light bulb! Personally i don't care about the "multicolor" option, i just want to be able to switch it on/off

webdjoe commented 3 years ago

Capture some packets and I'll be happy to add!

michalantoszczuk commented 2 years ago

@webdjoe

Setting color + brightness:

{ "payload": { "source": "APP", "method": "setLightStatus", "data": { "action": "on", "speed": 0, "green": 169, "brightness": 100, "blue": 177, "red": 255, "colorMode": "color" } }, "phoneOS": "iPadOS 15.2", "acceptLanguage": "en", "phoneBrand": "iPad", "cid": "ABC123***", "configModule": "WiFi_Bulb_MulticolorBulb_US", "token": "ABC123***", "timeZone": "Europe\/Warsaw", "traceId": "ABC123***", "userCountryCode": "PL", "appVersion": "VeSync 3.2.6 build6", "accountID": "ABC123***", "method": "bypassV2" }

michalantoszczuk commented 2 years ago

@webdjoe

Turning on: { "payload": { "source": "APP", "method": "setSwitch", "data": { "id": 0, "enabled": true } }, "phoneOS": "iPadOS 15.2", "acceptLanguage": "en", "phoneBrand": "iPad", "cid": "ABC123***", "configModule": "WiFi_Bulb_MulticolorBulb_US", "token": "ABC123***", "timeZone": "Europe\/Warsaw", "traceId": "ABC123***", "userCountryCode": "PL", "appVersion": "VeSync 3.2.6 build6", "accountID": "ABC123***", "method": "bypassV2" }

michalantoszczuk commented 2 years ago

@webdjoe Getting status: { "payload": { "source": "APP", "method": "getLightStatus", "data": {} }, "phoneOS": "iPadOS 15.2", "acceptLanguage": "en", "phoneBrand": "iPad", "cid": "ABC123***", "configModule": "WiFi_Bulb_MulticolorBulb_US", "token": "ABC123***", "timeZone": "Europe\/Warsaw", "traceId": "ABC123***", "userCountryCode": "PL", "appVersion": "VeSync 3.2.6 build6", "accountID": "ABC123***", "method": "bypassV2" }

michalantoszczuk commented 2 years ago

@webdjoe all should POST https://smartapi.vesync.com/cloud/v2/deviceManaged/bypassV2

webdjoe commented 2 years ago

Thank you, I will work on this. How did you capture packets from the app?

On Thu, Feb 24, 2022 at 4:49 PM michalantoszczuk @.***> wrote:

@webdjoe https://github.com/webdjoe all should POST https://smartapi.vesync.com/cloud/v2/deviceManaged/bypassV2

— Reply to this email directly, view it on GitHub https://github.com/webdjoe/pyvesync/issues/89#issuecomment-1050299309, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB6JJBRIYN5BS2AGC2OTADTU42RX5ANCNFSM5D4F2QFA . You are receiving this because you were mentioned.Message ID: @.***>

michalantoszczuk commented 2 years ago

@webdjoe macOS 12 (Apple M1) + VeSync app (from AppStore, version iPad/iPhone) + Charles (https://www.charlesproxy.com). If you need more packets, just tell me.

aigimig commented 2 years ago

+1, also have some ESL100MC bulbs :)

michalantoszczuk commented 2 years ago

Thank you, I will work on this. How did you capture packets from the app? On Thu, Feb 24, 2022 at 4:49 PM michalantoszczuk @.> wrote: @webdjoe https://github.com/webdjoe all should POST https://smartapi.vesync.com/cloud/v2/deviceManaged/bypassV2 — Reply to this email directly, view it on GitHub <#89 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB6JJBRIYN5BS2AGC2OTADTU42RX5ANCNFSM5D4F2QFA . You are receiving this because you were mentioned.Message ID: @.>

Any news?

webdjoe commented 2 years ago

@michalantoszczuk I'm working on this now. Can you send the device list return? It should be from the home screen of the app.

michalantoszczuk commented 2 years ago

pyvesync_list

webdjoe commented 2 years ago

@michalantoszczuk Apologies, I meant the api call return of the device list. Also can you send the returns as well. Hard to debug or test without them

michalantoszczuk commented 2 years ago

@webdjoe anything else?

getHomeInfo: Request: :method POST :scheme https :path /cloud/v1/homeManaged/getHomeInfo :authority smartapi.vesync.com accept */* content-type application/json accept-encoding br;q=1.0, gzip;q=0.9, deflate;q=0.8 user-agent VeSync/3.2.42 (com.etekcity.vesyncPlatform; build:12; iOS 15.5.0) Alamofire/5.2.1 accept-language pl-PL;q=1.0, en-PL;q=0.9, de-PL;q=0.8 content-length 357

Response: { "traceId": "1659807701719", "code": 0, "msg": "request success", "result": { "roomInfoList": [{ "roomId": 1234567, "roomName": "Backyard", "roomLight": "Part Sun,part Shade", "createTime": 12345678901, "groupList": [], "deviceList": [] }, { "roomId": 1234567, "roomName": "Bedroom", "roomLight": "Part Sun,part Shade", "createTime": 12345678901, "groupList": [], "deviceList": [{ "logicDeviceType": 1, "isOwner": true, "cid": "1234567890qwertyuiopQWERTYUIOP12", "uuid": "a1234567-1234-1abc-12ab-a1b2345c67d8", "macID": null, "subDeviceNo": 0, "subDeviceType": null, "deviceName": "Lampa sypialnia", "deviceImg": "https://image.vesync.com/defaultImages/ESL100MC/icon_color_light_bulb.png", "configModule": "WiFi_Bulb_MulticolorBulb_US", "deviceRegion": "EU", "type": "Wifi-light", "deviceType": "ESL100MC", "authKey": null, "connectionType": "wifi", "currentFirmVersion": "1.0.12", "createTime": 12345678901, "sharedPeople": [], "deviceStatus": "on", "connectionStatus": "online", "mode": null, "speed": null, "extension": null, "deviceProp": null }] }, { "roomId": 1234567, "roomName": "Kitchen", "roomLight": "Part Sun,part Shade", "createTime": 12345678901, "groupList": [], "deviceList": [] }, { "roomId": 1234567, "roomName": "Living Room", "roomLight": "Part Sun,part Shade", "createTime": 12345678901, "groupList": [], "deviceList": [] }, { "roomId": 1234567, "roomName": "Master Bedroom", "roomLight": "Part Sun,part Shade", "createTime": 12345678901, "groupList": [], "deviceList": [] }, { "roomId": 1234567, "roomName": "pokój X", "roomLight": "Part Sun,part Shade", "createTime": 12345678901, "groupList": [], "deviceList": [{ "logicDeviceType": 1, "isOwner": true, "cid": "1234567890qwertyuiopQWERTYUIOP12", "uuid": "a1234567-1234-1abc-12ab-a1b2345c67d8", "macID": null, "subDeviceNo": 0, "subDeviceType": null, "deviceName": "Pokój X lampa ", "deviceImg": "https://image.vesync.com/defaultImages/ESL100MC/icon_color_light_bulb.png", "configModule": "WiFi_Bulb_MulticolorBulb_US", "deviceRegion": "EU", "type": "Wifi-light", "deviceType": "ESL100MC", "authKey": null, "connectionType": "wifi", "currentFirmVersion": "1.0.12", "createTime": 12345678901, "sharedPeople": [], "deviceStatus": "on", "connectionStatus": "online", "mode": null, "speed": null, "extension": null, "deviceProp": null }] }, { "roomId": 0, "roomName": null, "roomLight": null, "createTime": null, "groupList": [], "deviceList": [] }] } }

webdjoe commented 2 years ago

@michalantoszczuk Thank you, I also need the "getting status" return from the server. The return json from the set status calls have code: 0 correct?

michalantoszczuk commented 2 years ago

example: { "traceId": "123", "code": 0, "msg": "request success", "result": { "traceId": "123", "code": 0, "result": { "action": "on", "brightness": 100, "colorMode": "color", "speed": 0, "red": 255, "green": 1, "blue": 0 } } }

aigimig commented 2 years ago

@webdjoe have you maybe had a chance to add this bulb? :)

webdjoe commented 2 years ago

Hey @michalantoszczuk @aigimig Please check out PR #149 . I added support for the ESL100MC. Not able to test but based off your captures should be close

webdjoe commented 2 years ago

@sdrapha Please check out #149 and make sure I didn't break any of your methods for Valceno bulbs. I tried to maintain consistency and compatibility with your code.

sdrapha commented 2 years ago

@sdrapha Please check out #149 and make sure I didn't break any of your methods for Valceno bulbs. I tried to maintain consistency and compatibility with your code.

I'll take a look a it once I get a chance to sit down at the computer, maybe later in the night.

aigimig commented 2 years ago

hi, thanks for your work @webdjoe! I had a look at the latest release and have one problem. The on/off function seems to be working fine but setting the color/brightness has no effect on the bulb despite the 'success' response. Any ideas?

Code: device.display() device.turn_on() device.display() device.set_rgb_color(255, 0, 0) device.set_brightness(1) device.display()

Debug mode output:

Device Name:.................. Lamp Model: ....................... ESL100MC Subdevice No: ................ None Status: ...................... off Online: ...................... online Type: ........................ Wifi-light CID: ......................... CID_redacted_CID UUID: ........................ UUID_redacted_UUID Brightness: .................. 43 % ColorHSV: .................... hue: 0.0, saturation: 0.0, value: 54.0,
ColorRGB: .................... hue: 0.0, saturation: 0.0, value: 54.0,
ColorMode: ................... color 2022-11-03 14:59:34,309 - DEBUG - =======call_api============================= 2022-11-03 14:59:34,310 - DEBUG - [post] calling '/cloud/v2/deviceManaged/bypassV2' api 2022-11-03 14:59:34,310 - DEBUG - API call URL: https://smartapi.vesync.com/cloud/v2/deviceManaged/bypassV2 2022-11-03 14:59:34,310 - DEBUG - API call headers: {"Content-Type": "application/json; charset=UTF-8", "User-Agent": "okhttp/3.12.1"} 2022-11-03 14:59:34,310 - DEBUG - API call json: {"timeZone": "Europe/Warsaw", "acceptLanguage": "en", "accountID": "1234567", "token": "token_redacted", "appVersion": "2.8.6", "phoneBrand": "iPad", "phoneOS": "iPadOS 15.2", "traceId": "1667483974", "method": "bypassV2", "debugMode": false, "deviceRegion": "US", "cid": "CID_redacted_CID", "configModule": "WiFi_Bulb_MulticolorBulb_US", "payload": {"source": "APP", "method": "setSwitch", "data": {"id": 0, "enabled": true}}} 2022-11-03 14:59:35,035 - DEBUG - API response: {'traceId': '1667483974', 'code': 0, 'msg': 'request success', 'module': None, 'stacktrace': None, 'result': {'traceId': '1667483974', 'code': 0}}

2022-11-03 14:59:35,052 - DEBUG - =======call_api============================= 2022-11-03 14:59:35,052 - DEBUG - [post] calling '/cloud/v2/deviceManaged/bypassV2' api 2022-11-03 14:59:35,052 - DEBUG - API call URL: https://smartapi.vesync.com/cloud/v2/deviceManaged/bypassV2 2022-11-03 14:59:35,052 - DEBUG - API call headers: {"Content-Type": "application/json; charset=UTF-8", "User-Agent": "okhttp/3.12.1"} 2022-11-03 14:59:35,052 - DEBUG - API call json: {"timeZone": "Europe/Warsaw", "acceptLanguage": "en", "accountID": "1234567", "token": "token_redacted", "appVersion": "2.8.6", "phoneBrand": "iPad", "phoneOS": "iPadOS 15.2", "traceId": "1667483975", "method": "bypassV2", "debugMode": false, "deviceRegion": "US", "cid": "CID_redacted_CID", "configModule": "WiFi_Bulb_MulticolorBulb_US", "payload": {"method": "setLightStatus", "source": "APP", "data": {"action": "on", "speed": 0, "red": 255, "green": 0, "blue": 0, "colorMode": "color"}}} Device Name:.................. Lamp Model: ....................... ESL100MC Subdevice No: ................ None Status: ...................... on Online: ...................... online Type: ........................ Wifi-light CID: ......................... CID_redacted_CID UUID: ........................ UUID_redacted_UUID Brightness: .................. 43 % ColorHSV: .................... hue: 0.0, saturation: 0.0, value: 54.0,
ColorRGB: .................... hue: 0.0, saturation: 0.0, value: 54.0,
ColorMode: ................... color 2022-11-03 14:59:35,789 - DEBUG - API response: {'traceId': '1667483975', 'code': 0, 'msg': 'request success', 'module': None, 'stacktrace': None, 'result': {'traceId': '1667483975', 'code': 11000000}}

2022-11-03 14:59:35,791 - DEBUG - =======call_api============================= 2022-11-03 14:59:35,791 - DEBUG - [post] calling '/cloud/v2/deviceManaged/bypassV2' api 2022-11-03 14:59:35,791 - DEBUG - API call URL: https://smartapi.vesync.com/cloud/v2/deviceManaged/bypassV2 2022-11-03 14:59:35,791 - DEBUG - API call headers: {"Content-Type": "application/json; charset=UTF-8", "User-Agent": "okhttp/3.12.1"} 2022-11-03 14:59:35,791 - DEBUG - API call json: {"timeZone": "Europe/Warsaw", "acceptLanguage": "en", "accountID": "1234567", "token": "token_redacted", "appVersion": "2.8.6", "phoneBrand": "iPad", "phoneOS": "iPadOS 15.2", "traceId": "1667483975", "method": "bypassV2", "debugMode": false, "deviceRegion": "US", "cid": "CID_redacted_CID", "configModule": "WiFi_Bulb_MulticolorBulb_US", "payload": {"method": "setLightStatus", "source": "APP", "data": {"action": "on", "speed": 0, "brightness": 1}}} 2022-11-03 14:59:36,505 - DEBUG - API response: {'traceId': '1667483975', 'code': 0, 'msg': 'request success', 'module': None, 'stacktrace': None, 'result': {'traceId': '1667483975', 'code': 11000000}}

Device Name:.................. Lamp Model: ....................... ESL100MC Subdevice No: ................ None Status: ...................... on Online: ...................... online Type: ........................ Wifi-light CID: ......................... CID_redacted_CID UUID: ........................ UUID_redacted_UUID Brightness: .................. 1 % ColorHSV: .................... hue: 0.0, saturation: 100.0, value: 100.0,
ColorRGB: .................... hue: 0.0, saturation: 100.0, value: 100.0,
ColorMode: ................... color

sdrapha commented 2 years ago

@aigimig the display() method was wrong, and I created a PR to fix that. But, what about the physical bulb itself, does it change color or is that also broken? because that would be an separate issue from the display method I put the fix for. I had a quick look at the code and didn't find anything obvious out of place. but I don't have a esl100mc myself to test it.

sdrapha commented 2 years ago

only thing I noticed from your debug output:

{"method": "setLightStatus", "source": "APP", "data": {"action": "on", "speed": 0, "red": 255, "green": 0, "blue": 0, "colorMode": "color"}}}

there is no "brightness" key on that payload. maybe that is the issue.

the captured call from @michalantoszczuk does include the brightness key:

{ "source": "APP", "method": "setLightStatus", "data": { "action": "on", "speed": 0, "green": 169, "brightness": 100, "blue": 177, "red": 255, "colorMode": "color" }

aigimig commented 2 years ago

@sdrapha The bulb only changes colors when controlled from the official VeSync app. When controlled by the pyvesync lib, only turn on/off works but not the color or brightness. I noticed the 'brightness' difference too and tried to add it in debug mode but it made no difference - no effect on the bulb itself. @michalantoszczuk maybe you can have a look and confirm whether it works for you or if the setLightStatus has changed?

webdjoe commented 2 years ago

There are a few possible issues - userCountryCode, debugMode and brightness in the request. Let me make adjustments and I'll start a new branch. @aigimig, are you based in the EU?

sdrapha commented 2 years ago

@aigimig Can you try testing this branch? https://github.com/sdrapha/pyvesync/tree/patch-2 I added an empty brightness key, to the calls that only changes the colors

Do you know how to clone the git, and setup an virtual env on python to do that? the CONTRBUTING.md has some instruction on how to do that, so you can test the current code directly, without waiting for a release, the only difference would be the git clone address, where you would git clone https://github.com/sdrapha/pyvesync/tree/patch-2 instead

If it works I do a PR with that change

aigimig commented 2 years ago

@webdjoe yes, EU @sdrapha I will check tonight and let you know

aigimig commented 2 years ago

The result is still the same. The response is 'success' but the bulb's color/brightness does not change. I also tried modifying timezone, region and even app version to match what I've got on my phone but that did not change anything.

Code: device.display() device.turn_on() device.display() device.set_rgb_color(255, 0, 0) device.set_brightness(1) device.display()

Debug mode output:

Device Name:.................. Lamp Model: ....................... ESL100MC Subdevice No: ................ None Status: ...................... off Online: ...................... online Type: ........................ Wifi-light CID: ......................... CID_redacted_CID UUID: ........................ UUID_redacted_UUID Brightness: .................. 43 % ColorHSV: .................... hue: 0.0, saturation: 0.0, value: 54.0,
ColorRGB: .................... red: 138.0, green: 138.0, blue: 138.0,
ColorMode: ................... color 2022-11-04 17:56:47,986 - DEBUG - =======call_api============================= 2022-11-04 17:56:47,986 - DEBUG - [post] calling '/cloud/v2/deviceManaged/bypassV2' api 2022-11-04 17:56:47,986 - DEBUG - API call URL: https://smartapi.vesync.com/cloud/v2/deviceManaged/bypassV2 2022-11-04 17:56:47,986 - DEBUG - API call headers: {"Content-Type": "application/json; charset=UTF-8", "User-Agent": "okhttp/3.12.1"} 2022-11-04 17:56:47,986 - DEBUG - API call json: {"timeZone": "Europe/Warsaw", "acceptLanguage": "en", "accountID": "1234567", "token": "token_redacted", "appVersion": "2.8.6", "phoneBrand": "SM N9005", "phoneOS": "Android", "traceId": "1667581007", "method": "bypassV2", "debugMode": false, "deviceRegion": "US", "cid": "CID_redacted_CID", "configModule": "WiFi_Bulb_MulticolorBulb_US", "payload": {"source": "APP", "method": "setSwitch", "data": {"id": 0, "enabled": true}}} 2022-11-04 17:56:48,733 - DEBUG - API response: {'traceId': '1667581007', 'code': 0, 'msg': 'request success', 'module': None, 'stacktrace': None, 'result': {'traceId': '1667581007', 'code': 0}}

2022-11-04 17:56:48,733 - DEBUG - =======call_api============================= 2022-11-04 17:56:48,733 - DEBUG - [post] calling '/cloud/v2/deviceManaged/bypassV2' api 2022-11-04 17:56:48,733 - DEBUG - API call URL: https://smartapi.vesync.com/cloud/v2/deviceManaged/bypassV2 2022-11-04 17:56:48,733 - DEBUG - API call headers: {"Content-Type": "application/json; charset=UTF-8", "User-Agent": "okhttp/3.12.1"} 2022-11-04 17:56:48,733 - DEBUG - API call json: {"timeZone": "Europe/Warsaw", "acceptLanguage": "en", "accountID": "1234567", "token": "token_redacted", "appVersion": "2.8.6", "phoneBrand": "SM N9005", "phoneOS": "Android", "traceId": "1667581008", "method": "bypassV2", "debugMode": false, "deviceRegion": "US", "cid": "CID_redacted_CID", "configModule": "WiFi_Bulb_MulticolorBulb_US", "payload": {"method": "setLightStatus", "source": "APP", "data": {"action": "on", "speed": 0, "brightness": "", "red": 255, "green": 0, "blue": 0, "colorMode": "color"}}} Device Name:.................. Lamp Model: ....................... ESL100MC Subdevice No: ................ None Status: ...................... on Online: ...................... online Type: ........................ Wifi-light CID: ......................... CID_redacted_CID UUID: ........................ UUID_redacted_UUID Brightness: .................. 43 % ColorHSV: .................... hue: 0.0, saturation: 0.0, value: 54.0,
ColorRGB: .................... red: 138.0, green: 138.0, blue: 138.0,
ColorMode: ................... color 2022-11-04 17:56:49,548 - DEBUG - API response: {'traceId': '1667581008', 'code': 0, 'msg': 'request success', 'module': None, 'stacktrace': None, 'result': {'traceId': '1667581008', 'code': 11000000}}

2022-11-04 17:56:49,548 - DEBUG - =======call_api============================= 2022-11-04 17:56:49,548 - DEBUG - [post] calling '/cloud/v2/deviceManaged/bypassV2' api 2022-11-04 17:56:49,548 - DEBUG - API call URL: https://smartapi.vesync.com/cloud/v2/deviceManaged/bypassV2 2022-11-04 17:56:49,548 - DEBUG - API call headers: {"Content-Type": "application/json; charset=UTF-8", "User-Agent": "okhttp/3.12.1"} 2022-11-04 17:56:49,548 - DEBUG - API call json: {"timeZone": "Europe/Warsaw", "acceptLanguage": "en", "accountID": "1234567", "token": "token_redacted", "appVersion": "2.8.6", "phoneBrand": "SM N9005", "phoneOS": "Android", "traceId": "1667581009", "method": "bypassV2", "debugMode": false, "deviceRegion": "US", "cid": "CID_redacted_CID", "configModule": "WiFi_Bulb_MulticolorBulb_US", "payload": {"method": "setLightStatus", "source": "APP", "data": {"action": "on", "speed": 0, "brightness": 1, "red": "", "green": "", "blue": ""}}} 2022-11-04 17:56:50,314 - DEBUG - API response: {'traceId': '1667581009', 'code': 0, 'msg': 'request success', 'module': None, 'stacktrace': None, 'result': {'traceId': '1667581009', 'code': 11000000}}

Device Name:.................. Lamp Model: ....................... ESL100MC Subdevice No: ................ None Status: ...................... on Online: ...................... online Type: ........................ Wifi-light CID: ......................... CID_redacted_CID UUID: ........................ UUID_redacted_UUID Brightness: .................. 1 % ColorHSV: .................... hue: 0.0, saturation: 100.0, value: 100.0,
ColorRGB: .................... red: 255, green: 0, blue: 0,
ColorMode: ................... color

sdrapha commented 2 years ago

now, the colorMode key is missing from the set_brightness() api call. There are not enough captured calls to study all the possible combinations. I would assume that the other colorMode that is not "color" would be "white"? And maybe there are missing needed parameters when we switch between colormodes. That is true in the ValcenoBulbs, and for esl100mc, there are not enough packets captured to see all the different combinations.

aigimig commented 2 years ago

yes, the other color mode is 'white'. @michalantoszczuk any chance you could capture some more packets? I don't have access to an iPad

sdrapha commented 2 years ago

@aigimig I just updated that same previous branch, to include an empty colorMode key on the api call, when only changing brightness. Please, if you have the opportunity to test that again please. Another scenario I would ask you to tes is, by changing the Color Mode in the vesync app, and then tryng the pyvesync lib, to see if you get different results depending on the current colorMode.

aigimig commented 2 years ago

@sdrapha unfortunately no change. Also, I think you misspelled the key name and used 'color' instead of 'colorMode' but I tried both options (also by passing 'color' or 'white' as value) but still no luck :/ I also noticed that the brightness value displayed in the device.display() result is the value from the 'white' colorMode (app remembers a different value for each mode)

sdrapha commented 2 years ago

On top of that, I also noticed now, that nowhere in the code there is an api call to SET the colorMode to "white"

aigimig commented 2 years ago

On top of that, I also noticed now, that nowhere in the code there is an api call to SET the colorMode to "white"

That might be it. Maybe a colorMode has to be explicitly set before calling setLightStatus for color/brightness modifications.

sdrapha commented 2 years ago

I fixed the typo, and explicitly included colorMode = "white", when changing brightness, so I'm assuming that the brightness works only in white mode, and the rgb values have their 'brightness' level already contained in the rgb values itself, which makes sense. rgb(230,230,230) is brighter than rgb(30,30,30) and still the same color.

michalantoszczuk commented 2 years ago

It's funny. Now I have red lamp (red=255, green=0, blue=0). Brightness=100 If I turn the brightness to 50%, the payload is: red=128, green=0, blue=0, brightness=100.

sdrapha commented 2 years ago

That is exactly I was talking about, it seems that the 'brightness' parameter is exclusive to white mode, and when in color mode, you just tweak the rgb values to get more or less intensity

sdrapha commented 2 years ago

I just added a new method, set_color_mode( ), the options are 'color', 'white' ; assuming that could be used to set the color mode without touching other parameters. Please if you could test it.

aigimig commented 2 years ago

No change on my side :/ The mode in the app does not change and the brightness (for mode 'white') and color (for mode 'color') modifications don't work. Also, the set_color_mode does not update the device.display() value

sdrapha commented 2 years ago

Should the brightness parameter always be 100 ? while tweaking the rgb values? instead of a empty value? that is why more packets captures would be useful, to see all the possible combinations of setLightStatus calls

aigimig commented 2 years ago

Should the brightness parameter always be 100 ?

I tried that too with no luck

sdrapha commented 2 years ago

Ok, I did one more push to try to fix the colorMode status, at least on the pyvesync lib instance. But to get the api calls to really work on the bulb, it's beyond me without any more packets capture to study the calls posible combinations.

sdrapha commented 2 years ago

I also hope webdjoe has any insights regarding 'userCountryCode' or anything else missing on the headers, instead of the payload.

aigimig commented 2 years ago

I only noticed that turn_on/turn_off return code 0: {'traceId': '1667589369', 'code': 0, 'msg': 'request success', 'module': None, 'stacktrace': None, 'result': {'traceId': '1667589369', 'code': 0}} whereas all the setLightStatus calls (colorMode, brightness, rgb) return code 11000000 in the result field {'traceId': '1667589392', 'code': 0, 'msg': 'request success', 'module': None, 'stacktrace': None, 'result': {'traceId': '1667589392', 'code': 11000000}}

sdrapha commented 2 years ago

'code': 11000000 means the server received the request successfully, and the payload was rejected because it was wrong. I saw that code when the Valceno methods broke during the code refactoring. Again, we need more captures to figure out the api

sdrapha commented 2 years ago

I did one more push, to set brightness 100 while sending rgb parameters. That supposedly will replicate the api call from the only one packet capture we have from feb 24 by @michalantoszczuk , (the third post on this issue), We are really getting into some exploration mode now, without more info.

webdjoe commented 2 years ago

Without having the device it's impossible to know what's going on. The inner code mean's the request was authenticated to that account but there is an issue with the device payload. If you are unable to capture more packets, please use the Rest Client vs code addin, insomnia or postman to send this POST request with your token, accountID and cid to see if this works. The traceid is the epoch timestamp, you can get this by going to https://www.epochconverter.com/. Must be within a few minutes of sending the call.

{
    "payload": {
        "source": "APP",
        "method": "setLightStatus",
        "data": {
            "action": "on",
            "speed": 0,
            "green": 169,
            "brightness": 100,
            "blue": 177,
            "red": 255,
            "colorMode": "color"
        }
    },
    "phoneOS": "iPadOS 15.2",
    "acceptLanguage": "en",
    "phoneBrand": "iPad",
    "cid": "++++++DEVICE CID+++++++++",
    "configModule": "WiFi_Bulb_MulticolorBulb_US",
    "token": "+++++ACCOUNT TOKEN+++++++++",
    "timeZone": "Europe\/Warsaw",
    "traceId": "THIS IS THE EPOCH TIMESTAMP FOR THE REQUEST",
    "userCountryCode": "PL",
    "appVersion": "VeSync 3.2.6 build6",
    "accountID": "++++++++ACOUNT ID++++++++",
    "method": "bypassV2"
}
aigimig commented 2 years ago

@sdrapha the RGB modifications started working! so at least we know the one packet we have apart from on/off is correct :) @webdjoe thanks, I will give it a go and report back

sdrapha commented 2 years ago

Insomnia is great, I recommend, and it already has an automatic unix Timestamp feature, so you don't need to manually get it and type it. Also, you can have multiple requests saved so it's easy to explore.

It looks like that: image

aigimig commented 2 years ago

this one works for brightness so we were really close :) brightness (rgb values are irrelevant but the keys must be present)

sdrapha commented 2 years ago

great, I pushed a commit for this last discovery for brightness only adjustment. I wonder now, how to change colormodes, without touching the other parameters, should the other parameters be present( probably yes), but they should be [empty, 0 or 100] ?