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).
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,
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:
~~~~
# 0f 06 03 00 01 00 00 05 ff ff -> on
# 0f 06 03 00 00 00 00 04 ff ff -> off
~~~~
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:
socket.login("0000")
Afterwards you should be able to toggle your plug with:
socket.setStatus(True)# Onsocket.setStatus(False)# Off
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 of setStatus.
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.
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 ^^
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`:
```
socket.login("0000")
```
Afterwards you should be able to toggle your plug with:
```python
socket.setStatus(True) # On
socket.setStatus(False) # Off
```
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:
```python
def setStatus(self, status):
print("SetStatus:", status)
# 0f 06 03 00 01 00 00 05 ff ff -> on
# 0f 06 03 00 00 00 00 04 ff ff -> off
cmd = bytearray([0x03])
payload = bytearray([0x00, status, 0x00, 0x00])
msg = self.BTLEMessage(self, cmd, payload)
msg.send()
```
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 of `setStatus`.
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:
```text
0x0f -> magic byte
0x06 -> length of command + payload + checksum
0x03 -> command
0x00 -> payload
0x01 -> payload and parameter of setStatus
0x00 -> payload
0x00 -> payload
0x05 -> checksum
0xff -> magic byte
0xff -> magic byte
```
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 ^^
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 ^^