frawau / aiotuya Goto Github PK
View Code? Open in Web Editor NEWLibrary for LAN control of Tuya devices. Include provisioning.
License: MIT License
Library for LAN control of Tuya devices. Include provisioning.
License: MIT License
Deleted
Hello,
I'm very interested to manage my Tuya devices on my Raspberry without use Smartlife, IFTTT or others...
I'm following the instructions :
python3 -m pip install aiotuya
Installation of aiotuya OK, with a warning :
The script aiotuya is installed in '/home/pi/.local/bin' which is not on PATH.
So i add the path to PATH.
sudo nano .profile
I write the following instruction at the end of the file
PATH="/home/pi/.local/bin:$PATH"
I execute : python3 -m aiotuya
Script tell me to "Hit Enter to start", however, i have got only one line "Select Device :"
Nothing else.
I cancel the script, and i execute :
python3 -m aiotuya -e [email protected] -p Mysmartlifepassword -s MyWifiSSID24ghz -P MyWifiPassword24ghz
It's better !
Script tell me to "Hit Enter to start", i have got only one line "Select Device : [0] Provision new devices"
I type "0" many times, but script is looping without information.
I cancel the script, and i execute :
python3 -m aiotuya -e [email protected] -p Mysmartlifepassword -s MyWifiSSID24ghz -P MyWifiPassword24ghz -d
It's better !
Script tell me to "Hit Enter to start", i have got only one line "Select Device : [0] Provision new devices"
I type "0" and i ve got many debug information like this :
DEBUG: Request is {'a': 'tuya.m.device.list.token', 'deviceId': 'vw9957pc93ml2xxxxxxxxc4yrayj2icr4hy8dwxbtu', 'os': 'Linux', 'lang': 'en', 'v': '1.0', 'clientId': 'kqnykr87dfdffdsf978wcyjvk', 'time': 1581796624, 'postData': '{"token":"kx683g5X"}', 'sid': 'az158144I3317651ndsfK7L36c631a2d26a9dsf8cca3e773afcfccf8'}
(i've modified these informations)
Script is looping without end...
So how to use it ? Can i have some examples to detect my devices (i have got only socket) and send a "on" or "off" instruction to a specific socket ?
Thanks for your help !
Hi !
I'm working on a custom component to add a plug sensor to home assistant, it works currently by providing a local_key
, a dev_id
and the ip address of the plug.
I tried your work and was amazed when a realised the local_key
and the dev_id
were in the .aiotuya
file !
I only want the "sniffing" part that retrieve these two informations.
The best would be if you could provide a python API that can be just imported and used like this:
import aiotuya
listener = aiotuya.listener()
wait(100)
for (id, key) in listener.get_couples():
print(id, key)
If you don't have the time, I can do it. In that case how do you want me to reference your work ? (It would be easier for me to just build an other repo and copy/paste relevant part of your work)
Just started plugging around with this module since I just recently got a hold of a few Tuya smart plugs and other devices. Ran the simple python -m aiotuya
and ran into an AttributeError issue. I'm sure that I wouldn't have any issues editing the installed source (I'm pretty familiar with Python). Any thoughts or suggestions?
OS: Windows 10
Python Ver.: 3.7.1
aiohttp: 3.6.2
pycryptodome: 3.9.4
Here is the traceback:
$>python -m aiotuya
Hit "Enter" to start
Use Ctrl-C to quit
Traceback (most recent call last):
File "C:\Users\Molly\AppData\Local\Programs\Python\Python37-32\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Users\Molly\AppData\Local\Programs\Python\Python37-32\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\Molly\AppData\Local\Programs\Python\Python37-32\lib\site-packages\aiotuya\__main__.py", line 240, in <module>
scanner.close()
File "C:\Users\Molly\AppData\Local\Programs\Python\Python37-32\lib\site-packages\aiotuya\aiotuya.py", line 794, in close
if self.transport:
AttributeError: 'TuyaScanner' object has no attribute 'transport'
Heloo,
please add device wattmeter.
Thanks thanks.
Hi, I am grateful you created this tool, however it does not work on my raspbian buster.
here is the traceback:
File "/usr/lib/python3.5/runpy.py", line 183, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/usr/lib/python3.5/runpy.py", line 142, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/usr/lib/python3.5/runpy.py", line 109, in _get_module_details
import(pkg_name)
File "/home/pi/.local/lib/python3.5/site-packages/aiotuya/init.py", line 2, in
from .provision import TuyaProvision, TuyaCloud
File "/home/pi/.local/lib/python3.5/site-packages/aiotuya/provision.py", line 52, in
import aiohttp, random,string
ImportError: No module named 'aiohttp'
Hi, i've generated a IOT cloud app in my iot Tuya account (as documented here).
However, when using my own credentials it doesn't seem that I can associate my device.
Same issue it seems to happen when using a different region with your credentials, but not sure if it's totally related.
The js project also mentions the usage of the client schema, but not sure it's related here.
python -m aiotuya -e **********@gmail.com -p ********** -s Meepo -P ********** -d
DEBUG: Using selector: SelectSelector
Hit "Enter" to start
Use Ctrl-C to quit
Traceback (most recent call last):
File "C:\Users\samar\AppData\Local\Programs\Python\Python37-32\lib\runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "C:\Users\samar\AppData\Local\Programs\Python\Python37-32\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "D:\Study Work\Story\Valorant\new_env\lib\site-packages\aiotuya_main.py", line 240, in
scanner.close()
File "D:\Study Work\Story\Valorant\new_env\lib\site-packages\aiotuya\aiotuya.py", line 794, in close
if self.transport:
AttributeError: 'TuyaScanner' object has no attribute 'transport'
'
Is this an handled exception? Pls guide me.
I'm getting a not implementederror when running this. Issue seems windows related.
Traceback (most recent call last):
File "C:\Program Files (x86)\Python38-32\lib\runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Program Files (x86)\Python38-32\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\mvwe\AppData\Roaming\Python\Python38\site-packages\aiotuya\__main__.py", line 242, in <module>
loop.remove_reader(sys.stdin)
File "C:\Program Files (x86)\Python38-32\lib\asyncio\events.py", line 504, in remove_reader
raise NotImplementedError
NotImplementedError
The default eventloop doesn't seem to work on win32. I think a fix should be:
if sys.platform == 'win32':
loop = aio.ProactorEventLoop()
aio.set_event_loop(loop)
else:
loop = aio.get_event_loop()
for line 226 in main.py. But now in run into the second issue. stdin does not seem to be supported.
When connecting a new light-bulb with no prior connection to the WiFi, how would it receive the data I send over my encrypted WiFi?
There should be a way of doing a PM. Anyway really nice script, it would really help and I don't know this but I herd that all devices provisioned by a key can then be controlled by that key. Have a read through the following thread where some people decided against releasing an app with the key already loaded for users to use.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.