EDIMAX Smart Plug SP-1101W – Simple Python API

I puzzled the findings from my previous posts regarding the EDIMAX Smart plug (Basics, Scheduling) together and uploaded a simple Python API for the plug to my github. More details are available in the README of the project.

EDIMAX SP-W1101W

EDIMAX SP-W1101W

To give a quick impression of the API, here some examples (full code is here):

Set/Get plug state

# import plug API
from ediplug.smartplug import SmartPlug

# create plug object for plug with IP 172.16.100.75, login admin and password 1234
p = SmartPlug("172.16.100.75", ('admin', '1234'))

# change state of plug to ON
p.state = "ON"
print("Plug is now: ", p.state)

# change state of plug to OFF
p.state = "OFF"
print("Plug is now: ", p.state)

Set/Get scheduling

# import plug API
from ediplug.smartplug import SmartPlug

# create plug object for plug with IP 172.16.100.75, login admin and password 1234
p = SmartPlug("172.16.100.75", ('admin', '1234'))

# write schedule for one day to plug (Saturday, 11:15 - 11:45)
p.schedule = {'state': u'ON', 'sched': [[[11, 15], [11, 45]]], 'day': 6}

# query and print current schedule
print(p.schedule.__str__())

# write schedule for one week
p.schedule = [
        {'state': u'ON', 'sched': [[[1, 0], [1, 30]]], 'day': 0},
        {'state': u'ON', 'sched': [[[2, 0], [2, 30]]], 'day': 1},
        {'state': u'ON', 'sched': [[[3, 0], [3, 30]]], 'day': 2},
        {'state': u'ON', 'sched': [[[4, 0], [4, 30]]], 'day': 3},
        {'state': u'ON', 'sched': [[[5, 0], [5, 30]]], 'day': 4},
        {'state': u'ON', 'sched': [[[6, 0], [6, 30]]], 'day': 5},
        {'state': u'ON', 'sched': [[[7, 0], [7, 30]]], 'day': 6},
    ]

# query and print current schedule
print(p.schedule.__str__())

Leave a Reply

You must be logged in to post a comment.