unparagoned / njsTuya

Openhab interface for Tuya home automation devices sold under various names
27 stars 11 forks source link

Trying to understand local and cloud mode #21

Closed edwolfe3 closed 4 years ago

edwolfe3 commented 5 years ago

Why are my results different when using local vs cloud mode? Why don't I have all the devices for local mode?


[14:25:08] openhabian@openHAB:/srv/openhab2-conf$ node /etc/openhab2/scripts/node_modules/njstuya
{ "devices": [
{ "id": 04200099b4e62d136fea, "broadcast": {"ip":"172.31.10.226","gwId":"04200099b4e62d136fea","active":2,"ability":0,"mode":0,"encrypt":true,"productKey":"JxRc0L3YeVkRanNf","version":"3.1"}, "schema": {"devId":"04200099b4e62d136fea","dps":{"1":false,"2":0}} },
] }
{ "devices": [ {"04200099b4e62d136fea":{"ip":"172.31.10.226","gwId":"04200099b4e62d136fea","active":2,"ability":0,"mode":0,"encrypt":true,"productKey":"JxRc0L3YeVkRanNf","version":"3.1","devId":"04200099b4e62d136fea","dps":{"1":false,"2":0}}} ] }
[14:25:37] openhabian@openHAB:/srv/openhab2-conf$ node /etc/openhab2/scripts/node_modules/njstuya -mode cloud
{
  '04200099b4e62d136fea': 'OFF',
  '04200099b4e62d13684c': 'OFF',
  '10670365bcddc2f9d58c_1': 'OFF',
  '10670365bcddc2f9d58c_2': 'OFF',
  '06200045dc4f2236e565_1': 'OFF',
  '06200045dc4f2236e565_2': 'OFF',
  '10670365bcddc2fa4c7c_1': 'OFF',
  '10670365bcddc2fa4c7c_2': 'OFF',
  '0620004568c63abd5ad0_1': 'OFF',
  '0620004568c63abd5ad0_2': 'OFF'
}
unparagoned commented 5 years ago

Local and Cloud mode are completely different modes and I just try and return the raw data. But you are correct that local mode doesn't seem to show all the devices, this isn't anything I've come across before. How many devices do you have? Local mode is very sensitive so if you have used the app or anything else then it may mess up local devices and they won't broadcast their states unencrypted. You've made a few decent posts and some of them related to devices with multiple items, which isn't anything I have or tested, so could you post what devices you have so I can buy then and test them. Also I think you're the first person to actually use cloud mode, I don't even use it. So it may take me some time to figure out some of your issues.

edwolfe3 commented 5 years ago

I would actually prefer to use local mode but it isn't working for me as stated above. In the mean time, I'm using cloud mode. I have 6 devices:

2xSolpow Smart Plug Outlet 4xDILISENS 2 in 1 Smart Plug Mini Outlet with Energy Monitoring

edwolfe3 commented 5 years ago

FYI, I have used the app except for the one that is showing up; so, does that mean local will never work for me?

unparagoned commented 5 years ago

You have to make sure the app is properly closed on your phone. Force close it and then those devices should start working locally after a bit.

Here is an old python version that should what devices are broadcasting locally and what they are broadcasting. It might/should show devices that are displaying encrypted states as will.

https://github.com/unparagoned/njsTuya/blob/79ca6a8ff5de70f7d173923fd0a6db88134e7cfa/scripts/njstuyamonitor.py

edwolfe3 commented 5 years ago

Fore close the app and those devices should start working locally after a bit.

How long is a bit? I forced the app closed this morning, but I don't get anything different when I run the script using -mode local

Here is an old python version that should what devices are broadcasting locally and what they are broadcasting. It might/should show devices that are displaying encrypted states as will.

I tried the script but it returned (i haven't had to investigate yet):

[Traceback (most recent call last):
  File "njstuyamonitor.py", line 9, in <module>
    from timeout import timeout
ImportError: No module named timeout](url)**