Closed NGancevich closed 3 years ago
I can't test, i don't have a Sonoff S-Series. If anyone can test it, any contribution are welcome
I don't have a Sonoff S-Series. However I am having the same issue with my BasicR3 Sonoff device.
Both device.TurnOn() and device.TurnOff() do not work, with no error reported. I run the unit tests for TurnOnDevice and TurnOffDevice with no action on the device.
The test-data.json is correct because I can call GetCredentials fine. GetDevices also works fine to get the list of devices, and the correct device is selected from the list before calling TurnOn or TurnOff.
The switch does turn on and off fine when using the ewelink app. The switch does turn on and off fine when using the ewelink webiste https://web.ewelink.cc/ GetState works fine to get the state of the device after turning on and off via app or website.
The SDK used to work fine a few months ago to turn the device on and off. I wonder if something has changed on the ewelink listener side? Let me know if you need any more info to help get to the bottom of this.
I have the same experience with the SetStartup test method. The test runs fine with no error, but the device startup mode is not set to on.
Setting startup to on via the ewelink app works fine.
i tried with my sonoff basic version 3.5.0 , firmware ita-gz1-gl getcredentials, getstate works but on and off not working. i tried to update payloads but nothing to do. regards
maybe the url for WS changed.
urls.cs
public static string GetWebsocketUrl(string region) { return $"wss://{region}-pconnect3.coolkit.cc:8080/api/ws"; }
thank you mzumbo, changing url i've this message now:
Now I's working for me
I had to change:
1) constants.cs internal const string VERSION = "8";
2) wsupdatepaylod.cs internal WsUpdatePayload(string deviceId, string apiKey, object @params) { var seq = CoolkitHelper.MakeSequence();
action = "update";
apikey = apiKey;
deviceid = deviceId;
this.@params = @params;
userAgent = "app";
sequence = seq.sequence;
ts = "0";
}
3) wscredentialspayload.cs internal WsCredentialsPayload(string accessToken, string apiKey) { var seq = CoolkitHelper.MakeSequence();
action = "userOnline";
at = accessToken;
apikey = apiKey;
appid = "oeVkj2lxxxxxxxxxxx"; //your appid
nonce = CoolkitHelper.MakeNonce();
ts = seq.timestamp;
userAgent = "app";
sequence = seq.sequence;
version = AppData.VERSION;
}
4) websocket.cs
public void UpdateDevice(string apiKey, string deviceId, object @params)
{
var wsUpdatePayload = new WsUpdatePayload(deviceId, apiKey, @params);
Thread.Sleep(100);
websocket.Send(wsUpdatePayload.AsJson());
}
Yes! Great! it works! thank you mzumbo!
Thanks mzumbo for your contribution. If you want, make a PR and I will check compatibility
I tried multiple times but no any action. I didn't get any error while executing device.TurnOff(); from method below
[Fact] public async void TurnOffDevice() { var ewelink = new Ewelink(Email, Password, Region); var credentials = await ewelink.GetCredentials(); await ewelink.GetDevices();