We used TP-Link Tapo WLAN Smart Socket, Smart Home Wi-Fi Socket for controlling the Humidifier, Fan for regulating the humidity inside the tents. Each tent is equipped with individual Humidifier, Fan both are connected to smart plug, water tank with capacity of 60 Litres. Using the output function in mycodo we can turn on, off the humidifiers, fan at required time. Follow these steps for adding the smart socket as output to the mycodo
Step 1. Navigate to mycodo IP address in a browser
Step 2. Click "Setup"
Step 2 Screenshot
Step 3. Click on "Output"
Step 3 Screenshot
Step 4. Click "Output: Select One" dropdown list
Step 4 Screenshot
Step 5. Select "On/Off: Python Code [PYTHON]" in the dropdown list
Step 5 Screenshot
Step 6. Click Add button after selecting the "On/Off: Python Code [PYTHON]"
Step 6 Screenshot
Step 7. Click on the Gear icon in the newly added output device
<p align=”center”>Step 7 Screenshot </p>
Step 8. In the new screen Click on the "On Command" field and delete all its content
Step 8 Screenshot
step 9. Paste the following code snippet into the text box
sys.path.insert(1, '/usr/local/lib/python3.9/dist-packages')
from PyP100 import PyP100 #pip install PyP100
log_string = "ID: {id}: ON".format(id=output_id)
self.logger.info(log_string)
p100 = PyP100.P100("smart plug ip address", "tplink user id", "password") #Creating a P100 plug object
p100.handshake() #Creates the cookies required for further methods
p100.login() #Sends credentials to the plug and creates AES Key and IV for further methods
p100.turnOn() #Sends the turn on request
#end code smart plug on
step 10. Then Click on the "Off Command" field and delete all its contents then paste the following code snippet
Step 10 Screenshot
#off code snippet
# Copyright (C) 2022, 2023 Harish Gundelli
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
sys.path.insert(1, '/usr/local/lib/python3.9/dist-packages')
from PyP100 import PyP100
log_string = "ID: {id}: OFF".format(id=output_id)
self.logger.info(log_string)
p100 = PyP100.P100("smart plug ip address", "tplink user id", "password") #Creating a P100 plug object ,replace ip address and userid , password.
p100.handshake() #Creates the cookies required for further methods
p100.login() #Sends credentials to the plug and creates AES Key and IV for further methods
p100.turnOff() #Sends the turn off request
p100.getDeviceInfo()
Step 11. Click on save button and wait for the mycodo then click on the close button
Step 11 Screenshot 1
Step 11 Screenshot 2
Step 12. Then verify the output using on, off buttons in the newly added output device
Step 12 on Screenshot
Step 12 off Screenshot
You have successfully added smart plug as output.