hgross / node-red-contrib-tuya-smart

NodeRED nodes to get data from tuya smart devices (like smart plugs, bulbs, ...).
MIT License
43 stars 14 forks source link

How can i set Parameters ? #4

Closed malcomxcia closed 5 years ago

malcomxcia commented 5 years ago

Hello ! Nice Work ;)

But how can I turn a lamp or an Socket on or off ?

I tried with an Inject Node like this

{"set":false}

but doesn't works .....

Where is my mistake ?

Greets and have an Nice Day Malcom

hgross commented 5 years ago

Hi, try to inject {"set": false, "dpsIndex": 1} for off; {"set": true, "dpsIndex": 1} for on. Make sure the deviceId and deviceKey are correct.

malcomxcia commented 5 years ago

Thank you for your Answer ;)

I also tested that {"set": false, "dpsIndex": 1} but also doesn't work

My Device is connected

screenshot-192 168 0 79-1880-2019 02 12-20-39-56

screenshot-192 168 0 79-1880-2019 02 12-20-43-53

jhortolano commented 5 years ago

Hi, I also have the same issue, I can connect to the device (a smart plug in this case) but can't turn on or off from node-red. I'm also trying independently: {"set": false, "dpsIndex": 1} / {"set": true, "dpsIndex": 1} / {"set": false, "dpsIndex": 101} / {"set": true, "dpsIndex": 101}

Any help is much appreciated. Thanks!

hgross commented 5 years ago

The input looks correct to me - do you see the correct (output) status of the node in the debug log? Something like this? tuya 3-socket powerstrip outputs explained

(Instead of answers described in this issue: https://github.com/hgross/node-red-contrib-tuya-smart/issues/3 )

mariley2250 commented 5 years ago

Hi,

I have the same issue. I am currently seeing the correct output and the status changes if i manual operate the switch. It just seems that the input of the block is not being recognised.

Any help would be appreciated.

Thanks

jhortolano commented 5 years ago

Hi,

I haven't tried in node-red after finding this out, will do it when I get a chance, but I think the problem is not related to this plugin, but the local_key. Every time you reset the plug (or bulb) in the android app (or iOS, I guess), the local key is reset, and you need to get it and set it whereever you want to use the plug. I'd recommend to use the python library or node to test it, and then use it in node red.

As I said, I haven't tested in node red yet, but it was showing connected even when the local key was wrong, I would need to test it with the right key.

mariley2250 commented 5 years ago

I used wireshark to get the setting for the switch (as below). When you say local key are you meaning the deviceid??

image

hgross commented 5 years ago

@jhortolano meant the deviceKey and the proposed debug method is very helpful. You can use https://github.com/TuyaAPI/cli to test your tuya device from the console independent from NodeRED: like this tuya-cli get --id 20075335840d8e902ee0 --key 0a47abaf0ebf04a1 --ip 192.168.15.121

If you can see correct ouptut for the device state in NodeRED, there might be a problem with the node. Are you sure, you are using the latest version from npm (1.1.0)? There was a breaking change in 1.1.0 regarding input format - is it possible that you are on an older version?

jhortolano commented 5 years ago

@mariley2250 For the device key (or local key), I got it using the following method: https://github.com/codetheweb/tuyapi/blob/master/docs/SETUP.md

mariley2250 commented 5 years ago

Hi @hgross,

Tried to run script external to node-red with the following results. image

I used the method @jhortolano to get an updated key which rendered the following results light switch key

hgross commented 5 years ago

Looks like tuya-cli is broken because you have installed the 4.0.0 version of tuyapi released by @codetheweb some days ago. This line https://github.com/codetheweb/tuyapi/blob/master/index.js#L266 and the introduced breaking changes with v4 (https://github.com/codetheweb/tuyapi/releases/tag/v4.0.0) lead to my assumption.

This could also cause your problem with setting the state - but then you wouldn't be able to get the status either. I will have a look at the 4.x versions.

In the meantime npm install -g codetheweb/tuyapi@3.2.3 might help you out.

codetheweb commented 5 years ago

Thanks for tagging me @hgross, forgot to update the CLI. I'll get to it right now.

codetheweb commented 5 years ago

Should be fixed now @hgross @mariley2250. Update with npm i @tuyapi/cli -g and let me know if it works.

stepic commented 5 years ago

I have the same issue. Any news? deviceId and deviceKey tested with tuya-cli

Thanks!

hgross commented 5 years ago

Couldn't reproduce it with my devices (a 3-socket-powerstrip from hyleton, multiple single-socket devices from gosund) locally. I published a new version using the latest 3.x version of Tuyapi. What smart-devices (and from which vendors) are you using? Do you see anything in the logs (NodeRED as well as console-log of the browser)?

stepic commented 5 years ago

I have Houzetek AWP07L Smart WiFi Plug. Power status is being reported correctly, but I cannot switch power status (injecting with an inject node: json {"set": true}). The same action with tuya-cli works.

hgross commented 5 years ago

Ok, that is odd.

Can you please try, if injecting {"set": true, "dpsIndex": 1} does the trick? Also, what is the actual json output? (please attach) How are you starting node-red - can you see and share the output from the commandline?

garynl commented 5 years ago

dpsIndex - capital 'I'. Its case sensitive

On Sun, Mar 3, 2019 at 8:44 PM stepic notifications@github.com wrote:

No luck also adding dpsIndex.

This is msg.payload output: object data: object devId: "xxxxxxxxxxxxxx" dps: object 1: false 2: 0 4: 0 5: 0 6: 2317 deviceIp: "192.168.1.163" deviceId: "xxxxxxxx" deviceName: "piantana"

node-red is being started with systemctl (user pi) and I don't see any particular message on console

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/hgross/node-red-contrib-tuya-smart/issues/4#issuecomment-469056655, or mute the thread https://github.com/notifications/unsubscribe-auth/AVdrBimA_lBPm47MCVv2j6WdzindZLnkks5vTCYNgaJpZM4a3qZz .

stepic commented 5 years ago

Solved, it was my fault setting inject node, sorry

Sukuri commented 4 years ago

hi @hgross , I've set up the parameters but disconnected, can I know what's the problem please? image image

Sukuri commented 4 years ago

can help please @malcomxcia @stepic @hgross @jhortolano @codetheweb

codetheweb commented 4 years ago

It's hard to say @Sukuri but going by the device name it appears to be a sensor. Most sensors are not supported by TuyAPI at this time due to the fact they are not constantly connected to WiFi (they only connect for a short period to send updates).

Sukuri commented 4 years ago

@codetheweb noted and thanks for the reply

abbasaabbas commented 4 years ago

Hi @hgross,

Tried to run script external to node-red with the following results. image

I used the method @jhortolano to get an updated key which rendered the following results light switch key

Hi, I have Zoozee smart plug but I don't find the device Key, have you an idea how to get it? Thank you

abbasaabbas commented 4 years ago

Hi, I have Zoozee smart plug but I don't find the device Key, have you an idea how to get it? Thank you

sam1am commented 3 years ago

Boy I wish there were an easier way to do this.