Closed tuvok81 closed 10 months ago
Yes, it is possible, and this example shows you how. The username and password are the e-mail and password you use to log into the TP-Link mobile app.
AH ok thank you but i think i have a other fail ..
python tapo_p110.py Traceback (most recent call last): File "/home/websdr/Downloads/tapo_p110.py", line 61, in <module> asyncio.run(main()) File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete return future.result() File "/home/websdr/Downloads/tapo_p110.py", line 15, in main client = ApiClient(tapo_username, tapo_password) TypeError: argument 'tapo_username': 'NoneType' object cannot be converted to 'PyString'
It looks like it's complaining that the tapo_username variable is empty.
The example is trying to read it from an environment variable. Have you set the environment variables? The README has a section on that.
I'm not that good at programming things... I'll see if I can find something
thanks
hm i dont no .. iam to stupid for this manual ..
On Linux/Mac you can give values to environment variables like this
export TAPO_USERNAME=your-tapo-@email.com
export TAPO_PASSWORD=your-tapo-password
export IP_ADDRESS=192.168.1.XXX
On Windows you can do it with
set TAPO_USERNAME=your-tapo-@email.com
set TAPO_PASSWORD=your-tapo-password
set IP_ADDRESS=192.168.1.XXX
OK .. i have add the username and password and Ip here
tapo_username = os.getenv("@gmx.de")
tapo_password = os.getenv("**")
ip_address = os.getenv("192.168.168.21")
and where i add the export lines? at the top of the script? i use Linux Ubunut .. and SORRY for the many stupid questions..
OK i have see my poetry make some things ..
pipx upgrade poetry poetry is already at latest version 1.6.1 (location: /root/.local/pipx/venvs/poetry)
poetry install
The lock file is not compatible with the current version of Poetry.
Upgrade Poetry to be able to read the lock file or, alternatively, regenerate the lock file with the poetry lock
command.
no idea
Puhh.. i have no idea .. what i do here ..
Compiling tokio-macros v2.1.0
Compiling num_cpus v1.16.0
Compiling base16ct v0.2.0
Compiling base64 v0.21.4
Compiling lazy_static v1.4.0
Compiling tapo v0.7.4 (/home/websdr/Downloads/tapo/tapo)
Compiling tokio v1.33.0
Compiling pretty_env_logger v0.5.0
Finished dev [unoptimized + debuginfo] target(s) in 2m 07s
Running target/debug/examples/tapo_p110
Error: NotPresent
websdr@wmk:~/Downloads/tapo$ cargo run --example tapo_p110
Finished dev [unoptimized + debuginfo] target(s) in 0.21s
Running target/debug/examples/tapo_p110
Error: NotPresent
Looks like the environment variables are still not read properly.
Try the following:
examples/tapo_p110
back to the original version:
let tapo_username = env::var("TAPO_USERNAME")?;
let tapo_password = env::var("TAPO_PASSWORD")?;
let ip_address = env::var("IP_ADDRESS")?;
cargo run --example tapo_p110
execute the following commands @mihai-dinculescu suggested above on your Linux shell using your own credentials and the IP of your device:
export TAPO_USERNAME=your-tapo-@email.com
export TAPO_PASSWORD=your-tapo-password
export IP_ADDRESS=192.168.1.XXX
cargo run --example tapo_p110
AHH thanks it run!! but .... the cargo run have disable the plug .. and the maschine goes offline where is on the plug hmm
2023-10-15T11:22:11.527Z INFO tapo_p110 > Energy data (hourly): EnergyDataResult { local_time: 2023-10-15T13:22:10, data: [13, 14, 13, 14, 13, 14, 13, 14, 14, 13, 14, 13, 16, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], start_timestamp: 1697328000, end_timestamp: 1697414399, interval: 60 } 2023-10-15T11:22:11.572Z INFO tapo_p110 > Energy data (daily): EnergyDataResult { local_time: 2023-10-15T13:22:10, data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 191, 486, 186, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], start_timestamp: 1696118400, end_timestamp: 1696118400, interval: 1440 }
OK the last step is the poetry Problem @pwoerndle can you help here?
poetry shell
Spawning shell within /home/websdr/.cache/pypoetry/virtualenvs/tapo-Vr2UzEfI-py3.10
websdr@wmk:~/Downloads/tapo/tapo-py$ . /home/websdr/.cache/pypoetry/virtualenvs/tapo-Vr2UzEfI-py3.10/bin/activate
(tapo-Vr2UzEfI-py3.10) websdr@wmk:~/Downloads/tapo/tapo-py$ export TAPO_USERNAME=*gmx.de
(tapo-Vr2UzEfI-py3.10) websdr@wmk:~/Downloads/tapo/tapo-py$ export TAPO_PASSWORD=*
(tapo-Vr2UzEfI-py3.10) websdr@wmk:~/Downloads/tapo/tapo-py$ export IP_ADDRESS=192.168.10.5
(tapo-Vr2UzEfI-py3.10) websdr@wmk:~/Downloads/tapo/tapo-py$ python examples/tapo_p110.py
Traceback (most recent call last):
File "/home/websdr/Downloads/tapo/tapo-py/examples/tapo_p110.py", line 7, in <module>
from tapo import ApiClient, EnergyDataInterval
ModuleNotFoundError: No module named 'tapo'
I'm not super familiar with the python build, but did you run poetry install
before running poetry shell
?
If your just interested in trying out and you don't need to build from source, you could also just use pip
to install the tapo module and then run the example.
pip install tapo
export TAPO_USERNAME=your-tapo-@email.com
export TAPO_PASSWORD=your-tapo-password
export IP_ADDRESS=192.168.1.XXX
python examples/tapo_p110.py
i haved do pip install tapo and poetry install .. before i run .. i have not copy this from the shell sorry
Hello Guys, my first question is .. is this possible to read with the python script the Energy data from the device? When yes.. where i get the Username and Passwort... in the App i can not find them thanks