pyvesync icon indicating copy to clipboard operation
pyvesync copied to clipboard

Unknown device named ###### model WYSMTOD16A

Open Frederic-SABU opened this issue 2 years ago • 1 comments

I really like the pyvesync library which would allow me to retrieve info in python from my smart outdoor plugs. The model is GreenSun HSCB-SMT-EU. pyvesync logs properly to the vesync APIbut the model is not recognized. Is there anything I should try to retrieve info from this model ? Alternatively would you be able to recommend a vesync smart plug available in Europe that would work. None of the Etkcity products seem to be available. Thks.

Frederic-SABU avatar Jan 15 '24 08:01 Frederic-SABU

The only thing I can suggest is to capture packets and build into library. I am happy to assist you with the process

webdjoe avatar Jun 29 '24 21:06 webdjoe

All those sockets are treated via this endpoint and payload:

https://smartapi.vesync.com/cloud/v2/deviceManaged/bypassV2
{
    "appVersion": "VeSync 4.3.40",
    "phoneBrand": "Jeedom-VeSync",
    "phoneOS": "Jeedom-VeSync",
    "traceId": "1733083741506",
    "acceptLanguage": "fr",
    "timeZone": "Europe\/Brussels",
    "accountID": "XXXX",
    "token": "XXXX",
    "method": "bypassV2",
    "debugMode": true,
    "deviceRegion": "EU",
    "cid": "XXXX",
    "configModule": "ZY_WFBO_OTL_WYSMTOD16A_UN",
    "payload": {
        "data": [],
        "method": "getOutletStatus",
        "source": "APP"
    }
}
{
    "traceId": "1733083743506",
    "code": 0,
    "msg": "request success",
    "module": null,
    "stacktrace": null,
    "result": {
        "traceId": "1733083743506",
        "code": 0,
        "result": {
            "enabled": true,
            "voltage": 234.9955291748047,
            "energy": 0.00041502082778,
            "power": 5.35991096496582,
            "current": 0.02284645661711
        }
    }
}

Flobul avatar Dec 02 '24 11:12 Flobul

@Flobul : seems to work at least for JeeDom issue #134553 - how was it implemented there?

jmplonka avatar Jan 19 '25 17:01 jmplonka

Hey. After some digging, I found another way to get all datas from this socket.

method 'getProperty' with payload: "powerSwitch_1","realTimeVoltage","realTimePower","electricalEnergy","protectionStatus","voltageUpperThreshold","currentUpperThreshold","scheduleNum","powerSave","powerProtection","powerUpperThreshold","inchings","aways"

Flobul avatar Jan 19 '25 21:01 Flobul

@Flobul : what are the methods for

  • get energy (weekly, monthly and yearly)
  • switch the plug on / off Thank you for sharing the logs.

At least "get_details()" is working BIG_GRIN

jmplonka avatar Jan 20 '25 04:01 jmplonka

getOutletStatus is not used for this socket on the app to maintain status. Got lucky it worked here, but values are slightly different from this other way => But getProperty is. This is the status method sent continually by the app:

{
  "appVersion": "VeSync 5.1.60 build7",
  "phoneBrand": "iPad Air",
  "phoneOS": "iOS12.5.4",
  "traceId": "1733433302338",
  "acceptLanguage": "fr",
  "timeZone": "Europe\/Brussels",
  "accountID": "XXXXXX",
  "token": "XXXXXXXXXXXXXX",
  "method": "bypassV2",
  "debugMode": true,
  "cid": "XXXXXXXXXXXX",
  "configModule": "ZY_WFBO_OTL_WYSMTOD16A_UN",
  "configModel": "ZY_WFBO_OTL_WYSMTOD16A_UN",
  "payload": {
    "data": {
      "properties": ["powerSwitch_1", "realTimeVoltage", "realTimePower", "electricalEnergy", "protectionStatus", "voltageUpperThreshold", "currentUpperThreshold", "scheduleNum"]
    },
    "method": "getProperty",
    "source": "APP"
  },
  "userCountryCode": "FR"
}

Flobul avatar Jan 20 '25 09:01 Flobul

get_property is working:

realTimeVoltage = 236.9227294921875
realTimePower = 37.89560317993164
electricalEnergy = 0.20144282673142
protectionStatus = normal
voltageUpperThreshold = 265
currentUpperThreshold = 17
scheduleNum = 26
powerSave = {'enable': 0, 'triggerUpperThreshold': 0}
powerProtection = {'enable': 0, 'triggerType': 'overUpper', 'upperThreshold': 0}
powerUpperThreshold = 4080
inchings = []
aways = []

jmplonka avatar Jan 20 '25 10:01 jmplonka

@Flobul : but setProperty is not working for 'powerSwitch_1' to switch plug on / off?!?

jmplonka avatar Jan 20 '25 10:01 jmplonka

Is there a how-to for capturing traffic of vesync app? Didn't succeed until yet. MacOS, iPhone, WireShark available frida approach wasn't successful yet with emulated "Pixel3A XL"

jmplonka avatar Jan 20 '25 14:01 jmplonka

@Flobul : but setProperty is not working for 'powerSwitch_1' to switch plug on / off?!?

Works with setSwitch with payload : 'enabled'

Flobul avatar Jan 20 '25 16:01 Flobul

Is there a how-to for capturing traffic of vesync app? Didn't succeed until yet. MacOS, iPhone, WireShark available frida approach wasn't successful yet with emulated "Pixel3A XL"

iPad jailbreaked, ssl-kill-switch3 installed, mitmproxy on my Mac. Up and running.

Flobul avatar Jan 20 '25 16:01 Flobul

something is wrong with:

        body['payload'] = {
            'method': 'setSwitch',
            'source': 'APP',
            'data': {'enabled': 1},
        }

jmplonka avatar Jan 20 '25 20:01 jmplonka

something is wrong with:

        body['payload'] = {
            'method': 'setSwitch',
            'source': 'APP',
            'data': {'enabled': 1},
        }

Add {'id': 0, 'enabled': true}

Flobul avatar Jan 21 '25 07:01 Flobul

@Flobul : Thank you! Now I can get Details and toggle switch see fork Screenshot will follow.

jmplonka avatar Jan 21 '25 18:01 jmplonka

how can I update a single file or install the repo to HomeAssistant?

jmplonka avatar Jan 21 '25 19:01 jmplonka

@Flobul : one thing is not working - get energy by period

        body['payload'] = {
            'method': 'getEnergyHistory',
            'source': 'APP',
            'data': {
                'fromDay': int(from_day.timestamp()),
                'toDay'  : int(till_day.timestamp()),
            }
        }

returns code = -1

jmplonka avatar Jan 21 '25 21:01 jmplonka

@Flobul : one thing is not working - get energy by period

        body['payload'] = {
            'method': 'getEnergyHistory',
            'source': 'APP',
            'data': {
                'fromDay': int(from_day.timestamp()),
                'toDay'  : int(till_day.timestamp()),
            }
        }

returns code = -1

Yeah, it doesn't work on every devices.

Flobul avatar Jan 22 '25 07:01 Flobul

how can I update a single file or install the repo to HomeAssistant?

I don't use this or homeassistant. 🤗

Flobul avatar Jan 22 '25 07:01 Flobul

Well, than I‘m done. Will prepare the pull request, so @cdnninja can update the HA part.

jmplonka avatar Jan 22 '25 08:01 jmplonka

I created my own custom integration for testing. current status for a device that is online (!): Image Something is missing in integration :(

jmplonka avatar Jan 25 '25 16:01 jmplonka

I created my own custom integration for testing. current status for a device that is online (!): Image Something is missing in integration :(

Can't help you with HA. Works fine on Jeedom.

Flobul avatar Jan 25 '25 18:01 Flobul

finally I got it working 🥳

Image

will clean up my code and prepare pull requests…

jmplonka avatar Jan 26 '25 18:01 jmplonka

Awesome, looking forward to seeing the PR.

cdnninja avatar Jan 26 '25 21:01 cdnninja

@cdnninja : will send you my updated integration files ( supported devices are now more generic) - test pending. have a look at my vesync_integration

jmplonka avatar Jan 27 '25 16:01 jmplonka

We are working to try move the HA integration to be more generic. Assuming the changes for this device follow that trend it should be easy to get it working.

cdnninja avatar Jan 27 '25 16:01 cdnninja

@cdnninja: Tests are passed and seems to work with pyvesync 2.1.17 package (RP created). please update my changes I made to vesync integration.

jmplonka avatar Jan 28 '25 16:01 jmplonka

This is now included in v3.0. Please check the readme, this was a complete rewrite with many breaking changes so existing code will not work.

webdjoe avatar Sep 22 '25 01:09 webdjoe

There seems to be two separate API calls for the outlet status. For anyone which getOutletStatus works, can you please tell me your deviceType and configModule?

webdjoe avatar Oct 27 '25 00:10 webdjoe

This is now supported. Please open a new issue if there are any bugs

webdjoe avatar Dec 03 '25 02:12 webdjoe