EDIMAX Smart Plug SP-1101W – Python API Update

In a previous post, I already tried to describe how the scheduling format of the EDIMAX Smart plug is to be encoded. Actually I think what was described there was confusing and not a 100% correct. Thus, here some additions and corrections. (Actually, all is pretty simple, since each minute of the day is represented by a bit. Every character in the schedule string represents four of the bits).

Also the code on github is updated.

General XML Format

When retrieving the schedules from the Plug, the following XML is returned:

<?xml version="1.0" encoding="UTF8"?>
<SMARTPLUG id="edimax">
<CMD id="get">
<SCHEDULE>
<Device.System.Power.Schedule.0 value="ON">F80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</Device.System.Power.Schedule.0>
<Device.System.Power.Schedule.1 value="ON">000000000000000FFFFFFFC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</Device.System.Power.Schedule.1>
<Device.System.Power.Schedule.2 value="OFF">000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</Device.System.Power.Schedule.2>
<Device.System.Power.Schedule.3 value="OFF">000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FFFFFFFFFFFFFFF000000000000000000000000000000000000000000000</Device.System.Power.Schedule.3>
<Device.System.Power.Schedule.4 value="OFF">000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</Device.System.Power.Schedule.4>
<Device.System.Power.Schedule.5 value="OFF">000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</Device.System.Power.Schedule.5>
<Device.System.Power.Schedule.6 value="OFF">000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</Device.System.Power.Schedule.6>
</SCHEDULE>
</CMD>
</SMARTPLUG>

For each day an entry like this is included:

<Device.System.Power.Schedule.X value="ON">...</Device.System.Power.Schedule.X>

X = 0 is Sunday, X = 1 is Monday, X = 6 is Saturday. The “value” attribute is “ON” if the schedule for this day is active or “OFF” if disabled. The data of the “Device.System.Power.Schedule.X” tag is 360 characters long. Each hour is represented by 15 characters, thus 360 characters = 24h. For further discussion we will focus on that 360 characters (let’s call this „packed schedule“.

Packed Schedule Format in Detail

Once again, we have 360 characters representing 24 hours. Thus 15 characters represent 1 hour. This again tells us, that one characters needs to represent 4 minutes to allow us to represent every minute of an hour.

The interesting question now is: how is the 60 minute information encoded (packed) into 15 characters? Well this is very simple. Each character represents four bits (or four minutes). If a bit is set, the minute is set. Then if one transforms each 4-bit value into its corresponding hex value, and if this hex values are joined together, the 15 character string for each hour could be build. By joining together all the 15 characters hour values, we get a whole days schedule.

The above could be best illustrated by example.

To schedule the minute from 00:00 – 00:01 the bits for the first hour would look like this:

1000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

Which would be in hex:

8 0 0 0 0 0 0 0 0 0 0 0 0 0 0

And for 00:00 – 00:02:

1100 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

Again in hex:

C 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Now 00:00 – 00:03:

1110 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

In hex:

E 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Then 00:00 – 00:04:

1111 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

In hex:

F 0 0 0 0 0 0 0 0 0 0 0 0 0 0

The same for the next for bytes with 00:00 – 00:05:

1111 1000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

In hex:

F 8 0 0 0 0 0 0 0 0 0 0 0 0 0

… And so forth

Leave a Reply

You must be logged in to post a comment.