mlfunston / node-red-contrib-broadlink-control

Set of node-red nodes to manage the Broadlink home automation device suite
MIT License
44 stars 24 forks source link

MP1 How to turn on/off only 1 socket at time #18

Closed HernanLencinas closed 4 years ago

HernanLencinas commented 4 years ago

Hello, Im trying to create a flow on node-red to turn on/off only 1 socket at time. For example, turn on/off only s1 but when I config like this node-red crash

{ "action": "setState", "state": true, "s1": true, }

1 Nov 18:08:33 - SyntaxError: Unexpected token u in JSON at position 0
at JSON.parse ()
at MP1._device.on (/root/.node-red/node_modules/node-red-contrib-broadlink-control/nodes/MP1Node.js:56:84)
at MP1.emit (events.js:198:13)
at Socket.Device.cs.on (/root/.node-red/node_modules/node-red-contrib-broadlink-control/nodes/Device.js:50:22)
at Socket.emit (events.js:198:13)
at UDP.onMessage [as onmessage] (dgram.js:628:8)

Perhaps im doing something wrong, can you help me? Thanks in advance.

mlfunston commented 4 years ago

This looks to be related to #11 . There appears to be an issue in the code but I have not had a chance to look into it yet and don't have a unit to test with. Have you tried a get state and then send the change along with the previous state of the other ones?

HernanLencinas commented 4 years ago

I have several units available. If I give you remote access can you do the tests you need?

mlfunston commented 4 years ago

I've ordered a unit myself to do some testing. Trying to remotely connect will be difficult.

I tried doing some tests separately on the code and it seems to work ok, but you need to include all 4 s parameters. If you want to change s1 and s3 for example, send the following:

{ "action": "setState", "state": false, "s1": true, "s2": false, "s3": true, "s4": false }

Only the switches marked with true will be changed to the state defined - false (off) in the case above.

Let me know if that works.