jasonacox / tuyapower

Python module to read status and energy monitoring data from Tuya based WiFi smart devices. This includes state (on/off), current (mA), voltage (V), and power (wattage).
MIT License
136 stars 20 forks source link

Question: is this tuya python module read only from tuya compatible devices ? #28

Open adrianmak opened 1 year ago

adrianmak commented 1 year ago

Can I use this module to change a smart plug power state ?

jasonacox commented 1 year ago

Hi @adrianmak ! This module is for reading power only. However, it uses and is based on tinytuya which does allow you to change state:

import tinytuya

# Connect to Device
d = tinytuya.OutletDevice(
    dev_id='DEVICE_ID_HERE',
    address='IP_ADDRESS_HERE',
    local_key='LOCAL_KEY_HERE', 
    version=3.3)

# Get Status
data = d.status() 
print('set_status() result %r' % data)

# Turn On
d.turn_on()

# Turn Off
d.turn_off()