This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

integrated with Tuya IOT Products
#1
hello 
How could we connect IoT Products which compatible with the Tuya app with OUR LM, SL, HL?
is it possible and How.

regards.
Best Regards,
Reply
#2
Hello.
If Tuya devices are based on ESP8266 or ESP8285, you can install Tasmota firmware (https://tasmota.github.io/docs/) to use mqtt. You also need:
    A mqtt broker, for example mosquitto, running on a PC or a raspberry or similar.
    If you want to use the logic machine itself as a broker, here is an example https://forum.logicmachine.net/showthread.php?tid=2505.
An mqtt client, in this case Logic machine with a Lua script, here is an example of when I asked in the forum how to do it https://forum.logicmachine.net/showthread.php?tid=2649.

I hope you find it useful.
P.S. Be careful that some Tuya devices lately come with realtek wifi and not ESP.
Reply
#3
(17.03.2021, 10:17)JRP Wrote: Hello.
If Tuya devices are based on ESP8266 or ESP8285, you can install Tasmota firmware (https://tasmota.github.io/docs/) to use mqtt. You also need:
    A mqtt broker, for example mosquitto, running on a PC or a raspberry or similar.
    If you want to use the logic machine itself as a broker, here is an example https://forum.logicmachine.net/showthread.php?tid=2505.
An mqtt client, in this case Logic machine with a Lua script, here is an example of when I asked in the forum how to do it https://forum.logicmachine.net/showthread.php?tid=2649.

I hope you find it useful.
P.S. Be careful that some Tuya devices lately come with realtek wifi and not ESP.

Thank You JRP 
Appreciate your reply.
Best Regards,
Reply
#4
they are support API but I don't know if it's compatible with LM
Could admin verify if it's possible or not to integrate Tuya via API in LM

Please see these links: 
https://github.com/codetheweb/tuyapi
https://developer.tuya.com/en/docs/iot/p...1dldk26u64
Best Regards,
Reply
#5
MQTT integration is the easiest solution by far
Reply
#6
Hello
I am trying to reach to my TUYA developer account via API.
Same API GET code easily accesses from Postman but when I try from logic machine I am receiving a time error.

Normally this happens when logic machine has wrong time and date but it seems the NTP and all settings fine.

Could you please give some guidance?

Best

Turker


* table:
["t"]
* number: 1729423258660
["msg"]
* string: request time is invalid
["code"]
* number: 1013
["success"]
* bool: false
["tid"]
* string: 617cb0ab8ed511efb25f867693c53a33
Reply
#7
Check that your LM has correct timezone set. Post your script code.
Reply
#8
Thanks for quick answer. Time Zone is Europe/Madrid. Here is the code

https = require('ssl.https')
json = require('json')
ltn12 = require('ltn12')

token = '***********************'
--tuya



tbl = {}
res, code = https.request({
url = 'https://openapi.tuyaeu.com/v1.0/devices/***8dc756f81122a3al***/status',
method = 'GET',
headers = {
['authorization'] = 'Bearer ' .. token,
['content-type'] = 'application/json',
},
sink = ltn12.sink.table(tbl),
})


log(os.date('%c'))

if res and code == 200 then
resp = table.concat(tbl)
resp = json.pdecode(resp)

log(resp)
else
log(res, code)
end
Reply
#9
I don't see any timestamp being passed to the request in your code. Do you have documentation on how the API calls should be made?
Reply
#10
Yes here is the API guide

https://developer.tuya.com/en/docs/iot/a...a8uuo1j4t4
Reply
#11
Hello

I think after your guidance I have progressed on the time. Now the issue is I need to sign the GET code with HMAC-SHA256

How can we add a "crypto" library so this code can work:

local sign = crypto.hmac("sha256", str, secret):upper()

Thank you
Reply
#12
Use this:
Code:
require('encdec')
sig = encdec.hmacsha256(ciphertext, hmac_key):upper()
Reply
#13
Thank you.

it worked but I think the ciphertext is not correct --> Here is the response string: {"code":1004,"msg":"sign invalid","success":false,"t

local ciphertext = client_id .. access_token .. t .. nonce .. identifier .. stringToSign

What is the identifer for Wiser?
identifier: The custom signature content for app authorization. When the authorization type is Android, you need to concatenate SHA1 and Application ID to form an identifier without a separator. For other types, you can directly use the customized Bundle Identifier.
Reply


Forum Jump: