setStatus doesn't work #1
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Dear sqozz,
Thanks for the great repo. I can successfully retrieve data from the Voltcraft, however, I cannot change the status of the device (i.e. turn it on or off).
In the comments, you write:
However, I don't understand how this works...
setStatus
only accepts integers between 0 and 255, but none of the integers within this range change the status of the device.Do you have any ideas how to solve this?
Thanks in advance!!!
All the best,
Pol van Rijn
P.S.: If German is more convenient for you, you can also reply in German,
Hey there! Awesome to see some interest in this lib. Unfortunately I've to warn you that it might not be in a state to use it without some python knowledge.
In your particular case it sounds to me like the password for your sockets is wrong.
Give it a try with the following line before calling
setStatus
:Afterwards you should be able to toggle your plug with:
The lib allows you also to change the default to something else which I'd recommend for security-reasons (take a look into example.py how to achieve this).
However I'd still like to explain what these two lines you found mean.
The two lines you mentioned are the raw data dump of the bluetooth communication. So let's have a look at the
setStatus
function:Byte 0 ("0f") is a magic byte defined by the vendor. We can ignore it since this is handled in
BTLEMessage
. Byte 1 ("06") is the length of the command - again, calculated by BTLEMessage on the fly.Next,
cmd
is set to the third byte ("03") which is used as command indicator in the message. 0x03 means in this case: switch the socket.Then
payload
is set to four bytes ("00 ?? 00 00"). The second of those four bytes indicated the socket status to switch to. It can have the value 0x00 (aka "off") or anything >0x00 to indicate "on". As you can see, this byte is also the parameter ofsetStatus
.Then comes the checksum ("05") and again two magic bytes defined by the vendor ("ff ff"). These bytes are once again filled in and calculated by
BTLEMessage
.In short:
Feel free to ping me on chaos.social or freenode if you've further questions :)
P.S. sorry for the late reply, was kind of surprised somebody uses this project ^^