RealZimboGuy / ewelink-api-java

Java Api for the Sonoff ewelink
http://ewelink-api-java.co.zw/
15 stars 5 forks source link

unable to control multi channel device #6

Closed dvorap closed 11 months ago

dvorap commented 11 months ago

Hi, nice work!

but it is unable to control multi-channel devices, for example, TX2C.

Are you planning to support it?

Thank you

RealZimboGuy commented 11 months ago

Hi, I've never had one of those devices to "play" with do you have any info about how it responds or behavior with the current code? We can made modifications as needed.

On Tue, Oct 24, 2023, 6:58 PM dvorap @.***> wrote:

Hi, nice work!

but it is unable to control multi-channel devices, for example, TX2C.

Are you planning to support it?

Thank you

— Reply to this email directly, view it on GitHub https://github.com/RealZimboGuy/ewelink-api-java/issues/6, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADYYQWBW44GQY7O7WN5PQA3YA7XSDAVCNFSM6AAAAAA6OANZYSVHI2DSMVQWIX3LMV43ASLTON2WKOZRHE2TSNRZGMZDAMA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

dvorap commented 11 months ago

I guess you have to put an object "switches" into the "params" field. This is an example of message from WebSocket update action: { "action": "Update", "deviceid": "multi-channel-device", "apikey": "--", "userAgent": "device", "params": { "switches": [ { "switch": "off", "outlet": 0 }, { "switch": "on", "outlet": 1 }, { "switch": "off", "outlet": 2 }, { "switch": "off", "outlet": 3 } ] }, "seq": "55" }

and this is an example of single channel device: { "action": "update", "deviceid": "single-cahnnel-device", "apikey": "--", "userAgent": "device", "params": { "switch": "on" }, "seq": "72" }

Yeah, I know terrible design form ewelink 🤷

RealZimboGuy commented 11 months ago

OK, it looks doable based on that, does the message from ewelink on the websocket look similar when you change a switch state via other platform /manually? I might only have time in a few days to check the code but you are welcome to do a pull req for the changes

On Tue, Oct 24, 2023, 7:34 PM dvorap @.***> wrote:

I guess you have to put an object "switches" into the "params" field. This is an example of message from WebSocket update action: { "action": "Update", "deviceid": "multi-channel-device", "apikey": "--", "userAgent": "device", "params": { "switches": [ { "switch": "off", "outlet": 0 }, { "switch": "on", "outlet": 1 }, { "switch": "off", "outlet": 2 }, { "switch": "off", "outlet": 3 } ] }, "seq": "55" }

and this is an example of single channel device: { "action": "update", "deviceid": "single-cahnnel-device", "apikey": "--", "userAgent": "device", "params": { "switch": "on" }, "seq": "72" }

Yeah, I know terrible design form ewelink 🤷

— Reply to this email directly, view it on GitHub https://github.com/RealZimboGuy/ewelink-api-java/issues/6#issuecomment-1777708814, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADYYQWBGFSYHECEU35AWXX3YA73YVAVCNFSM6AAAAAA6OANZYSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONZXG4YDQOBRGQ . You are receiving this because you commented.Message ID: @.***>

RealZimboGuy commented 11 months ago

have a look at 3.1.0-RELEASE, a few changes, you should be able to access the switch values thing.getItemData().getParams().getSwitches() and then based on that i added the eweLink.setMultiDeviceStatus(,)

you will i think need to push all the outlet status changes at the same time im not sure you can just send ie outlet 3 off, but im not sure you will have to test and let me know

dvorap commented 11 months ago

I tested it, and it works. You can even send just one outlet, don't need to send it all. That is exactly what I need, thank you, I really appreciate it 👍