Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for TPLink Tapo plugs #132

Closed
wants to merge 1 commit into from

Conversation

fsnuxer
Copy link

@fsnuxer fsnuxer commented Mar 31, 2021

Add support for TPLink Tapo plugs.
Thanks to https://github.com/fishbigger/TapoP100 Library
Disclaimer : I'm no python coder
Works for me at least ;)

#90

@Arksine
Copy link
Owner

Arksine commented Apr 2, 2021

Thanks. At the moment I am not accepting contributions to the power plugin that requires dependencies. I have plans to add support for MQTT integration which should allow Moonraker to interact with nearly all devices like this though a 3rd party. I also plan to implement a 3rd party plugin interface that will allow users to register their own power modules, with the caveat that the plugin developer will be responsible for maintaining it.

@fsnuxer
Copy link
Author

fsnuxer commented Apr 2, 2021

Fair enough. (I guess in this case the library used could be included or copy/pasted since it's very small.)

Another solution (for this plug and other) could be a generic "external command" system ?
=> call a cli command just with an ON / OFF / STATUS parameter ?
And each and every plug could work without adding a dependency for moonraker - and without requiring an mqtt setup : just an external program/script glue...

@Arksine
Copy link
Owner

Arksine commented Apr 2, 2021

If the implementation can be added without the dependency I would be open to merging. After all, this is how the tplink smartplug implementation works. We would just need to make sure that the license is compatible and any borrowed code is properly credited.

Given that moonraker provides remote access with the ability to modify your configuration files I am not comfortable with supporting configurable CLI commands. I suspect that someone will end up implementing it in a 3rd party plugin, however my position will be to discourage it.

@NpFaith
Copy link

NpFaith commented Aug 23, 2021

@fsnuxer Can you provide the configuration code? I'm new in the Klipper universe and I have p100 smartplug. Thanks in advance

@fsnuxer
Copy link
Author

fsnuxer commented Aug 24, 2021

@fsnuxer Can you provide the configuration code? I'm new in the Klipper universe and I have p100 smartplug. Thanks in advance

Hello. Not sure if the code is still ok since I'm not using it anymore.
( The patch included updated documentation.md ;) )

[power mytapoplug]
type: tplink_tapo
email: youremailusedwhenyouregisteredtheplug
password: yourpasswordusedwhenyouregisteredtheplug
address: ip.of.the.plug

@Arksine
Copy link
Owner

Arksine commented Aug 24, 2021

Moonraker does not currently support Tapo plugs. As mentioned above, support could be added however it needs to be done without the fishbigger TapoP100 dependency. I wasn't specific as to the issues with the library, so for clarity I will elaborate:

  • The TapoP100 package relies on the requests module to make http requests. These are synchronous/blocking requests and they will block Moonraker's asyncio event loop. There are numerous ways around this, however the best solution is probably to use Tornado's async http client.
  • The package also depends on pycryptodome. This isn't a problem for a Raspberry Pi or common x86 linux distros like Ubuntu as they will have prebuilt wheels. Many other SBCs running Armbian will need to build the wheel for this package and it would be important to validate that a) the wheel can be built in a timely manner and b) the wheel can be built without any additional dependencies or user intervention.

@NpFaith
Copy link

NpFaith commented Aug 24, 2021

@Arksine I'm noob in this, it is possible for you to explain with more detail the right way to put moonraker communicating with Tapo P100? I'm enjoying allot Klipper, thanks for the help.

@NpFaith
Copy link

NpFaith commented Aug 24, 2021

@fsnuxer thanks for the help

@Arksine
Copy link
Owner

Arksine commented Aug 25, 2021

@NpFaith An interested developer would need to write an implementation that accesses the Tapo P100 APIs using asynchronous HTTP requests. They would need to be familiar with asyncio, Moonraker's component API, and the Tapo P100 API. Unfortunately I there isn't much more detail I can add, these are items the developer would need to research. If there are specific implementation questions with regard to Moonraker I would be happy to answer them.

@NpFaith
Copy link

NpFaith commented Aug 25, 2021

@Arksine I'm not a programmer, I understand algorithmic logic but I have no knowledge of these languages, as I managed to get it to work through the octoprint I thought that with a few little tricks it would be the same in moonraker. My knowledge is really limited. I don't want to use octoprint because I prefer Fluidd, what I need to be fine-tuned for me is to work with the smartplug tapo p100. What languages ​​do you need to know to be able to make the connection between smartplug and moonraker? Thanks anyway and if I need more help I'll talk to you.

@Arksine
Copy link
Owner

Arksine commented Aug 25, 2021

Octoprint very likely has a 3rd party plugin that supports the Tapo P100. Unfortunately there is no way to trick support into Moonraker if you want the device visible in Fluidd, support must be added to the power component, which is what this Pull Request attempted to do. Moonraker is written Python, specifically targeting CPython 3.7+.

@julianvolden
Copy link

Hi there, any updates on TPlink Tapo plugs?

Currently i have a tapo p115 plug i want to use

@Arksine
Copy link
Owner

Arksine commented Sep 6, 2024

It should be possible to support Tapo plugs with the generic http implementation. Since Moonraker is no longer accepting HTTP specific implementations I am closing this. Thanks.

@Arksine Arksine closed this Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants