MyDlink-API-Python
MyDlink-API-Python copied to clipboard
Change Status of Power Switch
Hello, thanks for your great work. Is it possible to change the State of Power Switches (DSP-w118)? Thanks for your reply
Alex
Changing the status would probably require further digging into the API. But you should be able to read the switch state with a modification of the example. Works for DSP-W218.
import argparse
import logging
from mydlink_api.mydlink import MyDlink
if __name__ == "__main__":
logger = logging.getLogger(None)
logger.setLevel(logging.INFO)
parser = argparse.ArgumentParser(description="API to Connect MyDlink Cloud Devices")
parser.add_argument('-e', '--email', dest='email', help='MyDlink email example [email protected]')
parser.add_argument('-p', '--password', dest='password', help='MyDlink password example Start123')
parser.add_argument('-pr', '--proxy', dest='proxy', help='Porxy Url with or without credational')
args = parser.parse_args()
mydlink = MyDlink(password=args.password, email=args.email, proxy=args.proxy, disable_unverified_https_warn=False)
device_list_json = mydlink.get_device_list()
device_info_json = mydlink.get_device_details(mac=device_list_json[0]['mac'],mydlink_id=device_list_json[0]['mydlink_id'])
logging.info("Status:"+str(device_info_json['change_cache']['setting_change'][0]['metadata']['value']))