Closed skycrack-77 closed 1 year ago
Hi, you have a Json formatting problem.
The string '{white:{br:100, ct:0}}'
is not valid Json. Json expects ”
around strings (like “white”, “br”, “ct”).
So you would use the command:
mosquitto_pub -t "/ewelink_command/1001088fc6/send_json" -m '{“white”:{“br”:100, “ct”:0}}'
You may also have to escape the ”
depending on what OS/shell you are using.
You may also find that you don’t need the brackets ie
mosquitto_pub -t "/ewelink_command/1001088fc6/send_json" -m '“white”:{“br”:100, “ct”:0}'
Let me know which of these (if any) works.
Hello Nick, thanks for your support.
unfortunately it doesn't work. I try everything for Days an read all the Comments in your code, without success.
mosquitto_pub -t "/ewelink_command/1001088fc6/send_json" -m '{"white":{"br":100, "ct":0}}' Sending command: {"action": "update", "userAgent": "app", "from": "app", "params": "{\"white\":{\"br\":100, \"ct\":0}}", "apikey": "0ea2ca0f-6b45-43ff-819a-710439769f54", "deviceid": "1001088fc6", "ts": 1619376019, "sequence": "1619376019255"}
[D Main.EwelinkClient ] WS connection closed
mosquitto_pub -t "/ewelink_command/1001088fc6/send_json" -m '"white":{"br":100, "ct":0}'
[D Main.EwelinkClient ] Sending command: {"action": "update", "userAgent": "app", "from": "app", "params": "\"white\":{\"br\":100, \"ct\":50}", "apikey": "0ea2ca0f-6b45-43ff-819a-710439769f54", "deviceid": "1001088fc6", "ts": 1619376520, "sequence": "1619376520404"}
[D Main.EwelinkClient ] WS connection closed
also i try
mosquitto_pub -t "/ewelink_command/1001088fc6/send_json" -m 'white: {'br': 2, 'ct': 0}'
[D Main.EwelinkClient ] CLIENT: message received topic: /ewelink_command/1001088fc6/send_json [I Main.EwelinkClient ] CLIENT: Received Command: send_json, device: 1001088fc6, Setting: white: {br: 2, ct: 0} [D Main.Default ] deviceid: 1001088fc6, got command from queue: send_json, white: {br: 2, ct: 0} [I Main.Default ] Default CLIENT: Received Command: send_json, device: 1001088fc6, Setting: white: {br: 2, ct: 0} [D Main.Default ] send_json: for device 1001088fc6 [D Main.EwelinkClient ] sending: { "action": "update", "apikey": "0ea2ca0f-6b45-42ff-819a-710439769f54", "deviceid": "1001088fc6", "from": "app", "params": "white: {br: 2, ct: 0}", "sequence": "1619377230468", "ts": 1619377230, "userAgent": "app" } [D Main.EwelinkClient ] Sending command: {"action": "update", "userAgent": "app", "from": "app", "params": "white: {br: 2, ct: 0}", "apikey": "0ea2ca0f-6b45-42ff-819a-710439769f54", "deviceid": "1001088fc6", "ts": 1619377230, "sequence": "1619377230468"} [D Main.EwelinkClient ] WS connection closed [D Main.EwelinkClient ] Disconnecting [D Main.Default ] deviceid: 10008ae241, process queue exited: task completed [D Main.Default ] deviceid: 100097c066, process queue exited: task completed [D Main.Default ] deviceid: 10009345e5, process queue exited: task completed [D Main.Default ] deviceid: 1000920eae, process queue exited: task completed [D Main.Default ] deviceid: 1000644d1f, process queue exited: task completed [D Main.Default ] deviceid: 10003baa31, process queue exited: task completed [D Main.Default ] deviceid: 100103f737, process queue exited: task completed [D Main.Default ] deviceid: 10003baafc, process queue exited: task completed [D Main.Default ] deviceid: 1001088fc6, process queue exited: task completed [D Main.Default ] deviceid: 10011fcc31, process queue exited: task completed [D Main.EwelinkClient ] exited keepalive loop [I Main.EwelinkClient ] published: EWE-MQclient/status: Disconnected [D Main.EwelinkClient ] Exited Receive Loop [W Main ] Client Disconnected
Format looks good, but no Success sorry about that. hope we find a solution. Best Regards
I don’t have a B2 bulb to try, but I’ll take a look tomorrow.
By the way:
mosquitto_pub -t "/ewelink_command/1001088fc6/send_json" -m 'white: {'br': 2, 'ct': 0}'
Can’t work. Json expects ” around strings. You could try this:
mosquitto_pub -t "/ewelink_command/1001088fc6/send_json" -m 'white: {“br”: 2, “ct”: 0}'
Json formatting is very specific. It might be easier to knock up a custom device for the B2, I’s fairly simple.
Are the settings ‘white’, ‘read’, ‘computer’ etc names that you gave to the settings? Or are they built in?
Ok, the problem is that it’s sending the command as a string, not Json.
mosquitto_pub -t "/ewelink_command/1001088fc6/send_json" -m '{"white":{"br":100, "ct":0}}'
Is the correct format, I need to figure out why it’s not being loaded as Json.
Ok, found it.
I just pushed a fixed version. Try pulling it now, hopefully it will now work correctly with:
mosquitto_pub -t "/ewelink_command/1001088fc6/send_json" -m '{"white":{"br":100, "ct":0}}'
Having looked through the code (which I haven't in a while), if the B2 gets set up as a default device, with the new version I just pushed, you could also use the command:
mosquitto_pub -t "/ewelink_command/1001088fc6/white" -m '{"br":100, "ct":0}'
or
mosquitto_pub -t "/ewelink_command/1001088fc6/bright" -m '{"br":100, "ct":0}'
or computer
, read
, nightLight
etc. as these commands should be created by the default device automatically, along with set_switch
. I'm not sure if ltype
is a setting (it's set to white
right now) - or is read only, but that would also be available as a command, eg:
mosquitto_pub -t "/ewelink_command/1001088fc6/ltype" -m 'read'
let me know if these commands work as expected, if so, a custom device isn't really needed.
Dear Nick, I am very excited once again.
mosquitto_pub -t "/ewelink_command/1001088fc6/send_json" -m '{"white":{"br":100, "ct":0}}'
works wonderfully.
I hope to be able to derive the remaining application functions in this way.
The other Params in your last Posting i will try.
Thank you very much for your very quick response and the time you invested.
if I had your address I would send you a B2 ;-)
Glad it's working.
I don't think sending me a B2 would help as it's a Europe only product I believe (220-240V). - I'm in Canada.
It did help sort out some bugs in the send_json
interface anyway!
New App ID and Secret was required.
Hello, i want change the bright of a B2 Bulb. When i send
mosquitto_pub -t "/ewelink_command/1001088fc6/send_json" -m '{white:{br:100, ct:0}}'
the Websocket disconnected.[D Main.EwelinkClient ] CLIENT: message received topic: /ewelink_command/1001088fc6/send_json [I Main.EwelinkClient ] CLIENT: Received Command: send_json, device: 1001088fc6, Setting: {white:{br:100, ct:0}} [D Main.Default ] deviceid: 1001088fc6, got command from queue: send_json, {white:{br:100, ct:0}} [I Main.Default ] Default CLIENT: Received Command: send_json, device: 1001088fc6, Setting: {white:{br:100, ct:0}} [D Main.Default ] send_json: for device 1001088fc6 [D Main.EwelinkClient ] sending: { "action": "update", "apikey": "0ea2ca0f-6b45-43ff-819a-710439769f54", "deviceid": "1001088fc6", "from": "app", "params": "{white:{br:100, ct:0}}", "sequence": "1619356129714", "ts": 1619356129, "userAgent": "app" } [D Main.EwelinkClient ] Sending command: {"action": "update", "userAgent": "app", "from": "app", "params": "{white:{br:100, ct:0}}", "apikey": "0ea2ca0f-6b45-43ff-819a-710439769f54", "deviceid": "1001088fc6", "ts": 1619356129, "sequence": "1619356129714"} [D Main.EwelinkClient ] WS connection closed [D Main.EwelinkClient ] Disconnecting [D Main.Default ] deviceid: 10008ae241, process queue exited: task completed [D Main.Default ] deviceid: 100097c066, process queue exited: task completed [D Main.Default ] deviceid: 10009345e5, process queue exited: task completed [D Main.Default ] deviceid: 1000920eae, process queue exited: task completed [D Main.Default ] deviceid: 1000644d1f, process queue exited: task completed [D Main.Default ] deviceid: 10003baa31, process queue exited: task completed [D Main.Default ] deviceid: 100103f737, process queue exited: task completed [D Main.Default ] deviceid: 10003baafc, process queue exited: task completed [D Main.Default ] deviceid: 1001088fc6, process queue exited: task completed [D Main.Default ] deviceid: 10011fcc31, process queue exited: task completed [D Main.EwelinkClient ] exited keepalive loop [I Main.EwelinkClient ] published: EWE-MQclient/status: Disconnected [D Main.EwelinkClient ] Exited Receive Loop [W Main ] Client Disconnected
The Json Output from ewelink is: { "__v": 0, "_id": "608042abf4b0e20008d548c7", "apikey": "0ea2ca0f-6b45-43ff-819a-710439769f54", "brandLogoUrl": "https://eu-ota.coolkit.cc/logo/q62PevoglDNmwUJ9oPE7kRrpt1nL1CoA.png", "brandName": "SONOFF", "createdAt": "2021-04-21T15:20:11.588Z", "devConfig": {}, "devGroups": [], "deviceUrl": "", "deviceid": "1001088fc6", "devicekey": "54af3297-3bcc-4af6-9f69-4c049a6af309", "extra": { "id": "5f97e54a875e410cccbd4df1", "extra": { "apmac": "d0:27:02:11:1c:dd", "brandId": "5c4c1aee3a7d24c7100be054", "description": "20201027008", "mac": "d0:27:02:11:1c:dc", "manufacturer": "\u6df1\u5733\u677e\u8bfa\u6280\u672f\u6709\u9650\u516c\u53f8", "model": "WTW-SNL-02", "modelInfo": "5e7a146548af4f7140874c8e", "staMac": "D0:27:02:11:1C:DC", "ui": "\u53cc\u8272\u51b7\u6696\u706f\u652f\u6301\u968f\u8c03\u53ca\u573a\u666f", "uiid": 103 } }, "family": { "id": "5ea82fbd3afd5d0007e0991e", "index": -7 }, "group": "", "groups": [], "ip": "95.91.104.154", "location": "", "name": "B2 Lampe", "offlineTime": "2021-04-24T12:16:33.528Z", "online": true, "onlineTime": "2021-04-25T01:01:51.461Z", "params": { "OTA": "success", "bindInfos": { "alexa": [ "0ea3ca0f-6b45-42ff-819a-710439769f54_26ca1996a20e8bd63617ab272d4eeede1d2d8e32" ], "gaction": [ "0ea2ca0d-6b45-42ff-819a-710439769f54_ewelink-google-home-v1" ] }, "bright": { "br": 100, "ct": 255 }, "computer": { "br": 20, "ct": 255 }, "fwVersion": "1.3.5", "ltype": "white", "nightLight": { "br": 5, "ct": 0 }, "read": { "br": 100, "ct": 255 }, "selfApikey": "", "sequence": "123456789", "staMac": "D0:27:02:11:1C:DC", "switch": "on", "timers": [], "version": 7, "white": { "br": 39, "ct": 0 } }, "productModel": "B02", "relational": [], "settings": { "alarmNotify": 1, "appDoorbellNotify": 1, "opsHistory": 1, "opsNotify": 0, "wxAlarmNotify": 0, "wxDoorbellNotify": 0, "wxOpsNotify": 0 }, "shareUsersInfo": [], "sharedTo": [], "showBrand": true, "type": "10", "uiid": 103 },
Maybe i do something wrong. Im glad for a Hint.