leiaz / python-awox-mesh-light Goto Github PK
View Code? Open in Web Editor NEWPython package to control Awox mesh light bulbs.
License: MIT License
Python package to control Awox mesh light bulbs.
License: MIT License
Hi Leiaz,
I tested adding and removing groups as described in a previous post and it works well.
The data for the C_MESH_GROUP command is :
- First byte : 1 to add group, 0 to remove group
- Second an third bytes : Group's mesh id in little endian order. Third byte is 0x80. Group ids are in the form 0x80xx.
- Limit is 10 group id assigned per devices
My question is for the awox standard awox remote control intégration.
Even with a remote preconfigured on a device, the group list defined by C_MESH_GROUP is empty by default. So a remote doesn't seem to work with the same process. I'd like to pair a remote to devices without any previous remote configuration.
Here are my wild guesses based on my tests:
As you seem to know the protocol quite well, do you have an idea ?
Regards
Is there some way to get password from the app? I captured packets with Bluetooth HCI snoop log in Android dev options.
Btw thanks for this library it works great.
EDIT 1: I cant set mesh password. It throws this error:
Connected.
Receiced notification from characteristic 00010203-0405-0607-0809-0a0b0c0d1912
Received message : b'\xd6\xd9~\x00\x00\x963\xdc`\x01X\x80\x03\x7f\x7fd\xff\x00\x00\x00'
Mesh network settings change failed : bytearray(b'\x0e')
Disconnecting.
Code:
import awoxmeshlight
import logging
logger = logging.getLogger("awoxmeshlight")
logger.setLevel(logging.DEBUG)
handler = logging.StreamHandler ()
handler.setLevel(logging.DEBUG)
logger.addHandler (handler)
light = awoxmeshlight.AwoxMeshLight ("A4:C1:38:44:06:58")
light.connect()
light.setMesh("PixtxaLightNet", "IeY3johvoosh","4556572782865925")
light.disconnect()
Light doesnt do anything after that
EDIT 2: I just fixed it by changing setMesh name, pass and key: light.setMesh("mesh_name", "mesh_pwd", "mesh_key")
Hello,
I tried to use your code for the same Awox light bulb as you described ans it works, i'm able to manage the light but after some time, the light starts to change it's brigthness/color like a preset but i didn't asked for.
I was wondering if the setMesh is mandatory or not ?
Did you faced this problem ?
Having trouble finding out the BT-Address of my Awox Smartlight (by EGLO), as it seems to provide a random BT-Address to the Awox (android) software. That's what I found out analyzing btsnoop_hci.log from my android device. Does this mean that it is impossible to connect to the Bulb without the Awox software? Or should I try to reset the bulb with the Awox software hoping that this way I can find out a valid BT-Address?
I was testing my program and it worked pretty well (could connect, change color, turn off,...)
But now, I can't connect to my EGLOPanel anymore : if my light is paired with AWOX App, I'll have a "Failed to connect to peripheral" error. When I disconnect my light from the app and turn off bluetooth on my phone, I have a "Device disconnected" error, even though I can still detect my light with bluetoothctl. I still have this problem after resetting my panel and unplugging it.
Any idea ?
Hi, thanks for the awox-meshlight project. It has been really helpfull.
However, someone earlier pointed out that it can be (and will be on the raspberry pi) a bit slow. Are there any options to make the connection faster? I want only my raspberry pi to control the light so I thought of just not disconnecting but that threw an assertion Error...
Is it possible to use 'normal' bluetooth instead of BLE? Or change the address type? I get this error randomly:
Failed to connect to peripheral A4:C1:38:21:28:92, addr type: public
Sometimes it connects, sometimes it does not. Do you have any clue?
Thanks in advance!
Hello,
You did some awesome work. However, I have a question concerning the password. I haven't set up any password on the lightbulb, except the one from the account but it's linked to the awox website I guess (so, not related to the lightbulb connection). Which one do you use? When I use an empty one, I receive some error at the line:
([ a ^ b for (a,b) in zip(m_n, m_p) ])
Does anything (like 0000) works?
Hello Leiaz,
Thank you for your work. I have an issue when I test your example :
root@debian:~/python-awox-mesh-light# python3 test.py Traceback (most recent call last): File "test.py", line 4, in <module> mylight.connect () File "/root/python-awox-mesh-light/awoxmeshlight/__init__.py", line 113, in connect self.btdevice.connect (self.mac) File "/usr/local/lib/python3.5/dist-packages/bluepy/btle.py", line 408, in connect self._connect(addr, addrType, iface) File "/usr/local/lib/python3.5/dist-packages/bluepy/btle.py", line 402, in _connect "Failed to connect to peripheral %s, addr type: %s" % (addr, addrType)) bluepy.btle.BTLEException: Failed to connect to peripheral A4:C1:38:79:0B:6C, addr type: public
Remove all association (remote,smartphone) is mandatory ?
Best regards
I have written some Python using awoxmeshlight, and can see that I can connect (I think!).
I used the function dir() to see the elements within awoxmeshlight, but if I try to call e.g. AwoxMeshLight.readStatus() then it crashes as does any other method- and if I try to get the value of e.g. red/ ... it crashes. However, I can read the password, mesh name and the mac address.
I could only get connect to work with retries.
I have looked for examples and found no examples using e.g. on/ off/ readStatus/ ...
Therefore, my only guide has been to look at the source, which is why I don't understand why I cannot access e.g. white_brightness/ turn the lamp on or off ....
Many thanks for any help.
PyCryptodome before 3.6.6 has an integer overflow vulnerability (Legrandin/pycryptodome#198)
Hi i had some problems with bluepy instalation on HA, i think bluepy have no more sup.
So i adapted the code to use bleak and pycryptodome..
if anyone can/need test it, its working.. not at 100%, no notifications.. wop
Hi Leiaz,
Great work! This is working for me for 2 different devices.
I have a few questions you may be able to answer :
I managed to read notification result to get meaningful information.
This is the code to parse the return of decrypt_packet method in notification handle
def parseResult(self, message):
message = "".join("%02x" % b for b in message)
result = {}
result['debug'] = message
meshid = int(message[6:8], 16)
mode = int(message[24:26], 16)
if mode < 40 and meshid == 0: # filter some messages that return something else
result['status'] = mode%2
modestring = ''
if mode==1 or mode==5:
modestring = 'White'
mode=1
elif mode==3:
modestring = 'Color'
elif mode==7:
modestring = 'Transition'
if mode%2 == 1:
result['mode'] = mode
result['modestring'] = modestring
result['whitetemperature'] = int(int(message[28:30], 16)*100/127) # convert to value from 0 to 100
result['whitebrightness'] = int(int(message[26:28], 16)*100/127) # convert to value from 0 to 100
result['color'] = "#" + message[32:38]
result['colorbrightness'] = int(int(message[30:32], 16)*100/64) # convert to value from 0 to 100
return result
But I've got it to run with my EGLOpanel and the Remote with the RaspberryPi (but without the Awox-App, but that's ok). Thanks!!!
I've renamed init.py to awoxmeshlight.py, so "import awoxmeshlight" works. Also I changed Line 3 to "import packetutils as pckt", because "from . import ..." didn't work.
Reset the light (hold PowerOn + Fav. 1) and the remote (hold PowerOn + ColorCyicle) and connect the remote to the light again (hold PowerOn). Now hold PowerOn and the blue button for a few seconds, so the remote switches to Bluetooth-mode. Use BT-app (nRF-Connect or so) to get the mac and name (both will have the same name, its "R-" followed by the last 6 digits of the remotes mac-address). Password will be "1234".
For the remote:
import awoxmeshlight
myremote = awoxmeshlight.AwoxMeshLight ("A4:C1:38:75:24:93", "R-752593", "1234") #change to your remotes data
myremote.connect()
myremote.setMesh("PixtxaLightNet", "IeY3johvoosh","4556572782865925") #better change all of them
myremote.disconnect()
[After setMesh(...) the program didn't work, but the data was set, so i killed the task]
For the light:
import awoxmeshlight
mylight = awoxmeshlight.AwoxMeshLight ("A4:C1:38:78:62:74", "R-752593", "1234") #change to your lights data
mylight.connect()
mylight.setMesh("PixtxaLightNet", "IeY3johvoosh","4556572782865925") #same as on the remote
mylight.disconnect()
[After setMesh(...) the program didn't work, but the data was set, so i killed the task]
Now you can run a simple test script:
import awoxmeshlight
import time
mylight = awoxmeshlight.AwoxMeshLight ("A4:C1:38:78:62:74", "PixtxaLightNet", "IeY3johvoosh")
mylight.connect()
mylight.setColor(0x00, 0xFF, 0x00) #green
mylight.setColorBrightness(0x01) #dark
time.sleep(1)
mylight.setColorBrightness(0x64) #bright
time.sleep(1)
mylight.setPreset(0) #colorchange
mylight.setSequenceFadeDuration(500)
mylight.setSequenceColorDuration(500)
time.sleep(15)
mylight.setWhite(0x00, 0x7F) #coldwhite
time.sleep(1)
mylight.setWhite(0x73, 0x63) #warmwhite
time.sleep(1)
mylight.off()
time.sleep(1)
mylight.on()
mylight.disconnect()
Thanks for your work, Leiaz! It helped me a lot. AwoX- and EGLO-Support told me, it wouldn't be possible to do this.
Hello everybody,
I know it's a long shot (since it's been more than a year since the last issue) but hey, one can hope! :)
I have an EGLO Fraioli-Z ceiling light (https://www.eglo.com/uk/pendant-light-fraioli-z-900081.html) smart light, which is controlled by the new application "AwoX HomeControl".
I have tried to use this script (great job by the way!) with a raspberry pi, but it appears that things might have changed as far a the way commands/packets are made. By finding out the mesh client id and password, I am able to connect via the script, but any command sent results in nothing happening.
The connect process appears to be working correctly, something I am able to verify via other ble debugging applications (eg BlueSee, nRF etc), by supplying the packet formed to the correct characteristic UUID and reading back the response. Other than that though, no commands appear to be working.
Are you aware of any possible changes that might have taken place? Has anyone else tried this script with a new Eglo/AwoX device (eg connect Z series)? If there is anyone else interested, I'm more than willing to supply any relevant information needed :)
Cheers!
Hi,
pip install failes with
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in
from pip import main
ImportError: cannot import name main
what to do?
Hi,
I bought an EGLO Connect Salobrena C LED Panel with AWOX Chipset. I can run your scripts and set the different colors and adjust brightness from commandline. Works fine but is very slow, so I tried to set the values by gatttool, but this doesn't work.
Lamp turned off via mylight.off()
write commands from hcidump
ATT: Write cmd (0x52) handle 0x001b value 0x0c 0xbe 0x63 0x12 0x58 0x8d 0x3d 0xd4 0xec 0x1a 0x5d 0x64 0x3d 0x6d 0x66 0x00 0x42 handle 0x001b value 0cbe6312588d3dd4ec1a5d643d6d660042 ATT: Write cmd (0x52) handle 0x0012 value 0x00 handle 0x0012 value 00 ATT: Write cmd (0x52) handle 0x0015 value 0xcd 0x9c 0x4c 0x7f 0x40 0x5a 0xb4 0xec 0xbd 0xb8 0x0a 0x88 0xda 0xb9 0xff 0xa1 0x64 0xec 0x57 0xa3 handle 0x0015 value cd9c4c7f405ab4ecbdb80a88dab9ffa164ec57a3
[XX:XX:XX:XX:XX:XX][LE]> connect
Attempting to connect to XX:XX:XX:XX:XX:XX
Connection successful
[XX:XX:XX:XX:XX:XX][LE]> char-read-hnd 0x0012
Characteristic value/descriptor: 00
[XX:XX:XX:XX:XX:XX][LE]>
Lamp turned on via mylight.on()
write commands from hcidump
ATT: Write cmd (0x52) handle 0x001b value 0x0c 0x1c 0x28 0xe3 0x09 0x4b 0xb5 0x36 0xef 0x3f 0x96 0x25 0xc9 0x14 0xe3 0x37 0x39 handle 0x001b value 0c1c28e3094bb536ef3f9625c914e33739 ATT: Write cmd (0x52) handle 0x0012 value 0x01 handle 0x0012 value 01 ATT: Write cmd (0x52) handle 0x0015 value 0xf0 0x6d 0x0a 0x6c 0x19 0xd4 0x69 0x03 0x6c 0xd1 0xe4 0x48 0x6f 0x20 0xbc 0x02 0x64 0x4f 0x3b 0xc4 handle 0x0015 value f06d0a6c19d469036cd1e4486f20bc02644f3bc4
[XX:XX:XX:XX:XX:XX][LE]> connect
Attempting to connect to XX:XX:XX:XX:XX:XX
Connection successful
[XX:XX:XX:XX:XX:XX][LE]> char-read-hnd 0x0012
Characteristic value/descriptor: 01
[XX:XX:XX:XX:XX:XX][LE]>
So this seems to work, the values are set when lamp is on or off. Next i tried to turn on the Panel from gatttool.
[XX:XX:XX:XX:XX:XX][LE]> char-write-req 0x0012 01
Characteristic value was written successfully
[XX:XX:XX:XX:XX:XX][LE]>
I think this should turn on the lamp, but nothing happens, same with following command.
[XX:XX:XX:XX:XX:XX][LE]> char-write-cmd 0x0012 01
Am I missing something? I don't know if i have to set the other values like "0x001b" and "0x0015" before and/or after setting the ON value.
Can someone please point me into the right direction? 😕
THX
Hey Leiaz,
I get an error when I try to interact with my bulb. It works well to connect and disconnect but when I try to do setMesh(), light.off() or something else it raises an AssertionError and I've no idea why.
Ignoring this and continuing executing the script doesn't work and the error still exists.
Help would be awesome.
Regards
I didnt see it at:
https://pypi.org/search/?q=awox
Please also tag versions,
I can help if you want to automate CD/CI or get inspiration from thoses changes:
rzr/awox-mesh-light-webthing@2bd9d19
rzr/awox-mesh-light-webthing@2bd9d19
rzr/awox-mesh-light-webthing@a7134d1
Then I'll depend on yours
Thanks
When executing the example script for setting the mesh configuration I receive an unknown failure. Running the same script on the remote works fine. The problem seems to only happen with the setMesh
command, other commands such as setColor
works fine.
Light is RGBW Eglo LED panel.
Any idea what is the error code about?
Script,
import awoxmeshlight
import logging
logger = logging.getLogger("awoxmeshlight")
logger.setLevel(logging.DEBUG)
handler = logging.StreamHandler ()
handler.setLevel(logging.DEBUG)
logger.addHandler (handler)
mylight = awoxmeshlight.AwoxMeshLight ("xx:xx:xx:xx:xx:xx", "R-ACCXXX", "1234")
mylight.connect()
mylight.setMesh("PixtxaLightNet", "IeY3johvoosh","4556572782865925")
mylight.disconnect()
Output,
Connected.
Receiced notification from characteristic 00010203-0405-0607-0809-0a0b0c0d1912
Received message : b'\x18\x82\x12\x00\x00,\x15\xdc`\x01\xdd\x11\x01\x7f\x11d\xff\x003\x00'
Mesh network settings change failed : bytearray(b'\x0e')
Disconnecting.
Hi. I am trying to control my ESMLzm_c9 light bulb (firmware 1.0.192, hardware 4.62) with my Raspberry Pi.
I seem to be able to connect to the light bulb, when it is unpaired or when it is paired with my awox control app (I got the mesh name and password from home assistant plugin connected to my awox account). The pairing procedure seems to work (writing to pair UUID, then reading it to get the bulb's key), but any command I send afterwards is just ignored by the lightbulb.
I "btsnooped" my phone when controlling the bulb from the app : I can see the pair packet going out, and I can even re-generate this packet from the python script (make_pair_packet) with the mesh name and password + the nonce from the snooped payload. Both the pair packet from my phone, and the re-generated pair packet from "make_pair_packet" coincide.
However, after connecting, when I try a command like "light.off()" for example, the light stays on. The command sent by my phone to switch on and off the light is encrypted all right, but its length is different from the one generated by the script (17 Bytes sent by my phone, vs. 20 Bytes from the "make_command_packet" function), which makes me think that the command interface is different.
I got the snooped pair reply from the bulb and built the session key to try and decrypt the other snooped command messages, and reverse engineer the interface, to maybe add it to this library, but no luck so far. Maybe the nonce or session key generation methods have changed as well.
Anyway, do you think it could be a version issue or a different model ? Where did you find the information about the bulb command protocol & packet format ?
Hello!
I have recently installed your repo in order to integrate for my home assistant but so far it's been extremely unreliable .
I only have 1 bluetooth lamp (Eglo 11569 g95) and when the commands work it usually takes about 5 seconds ornso to respond .
Often they don't work at all as the script fails to connect , especially if I just ran a command in the last 10 seconds (but not limited to this)
I am running on a rpi3 with ubuntu and using the rpi3 built in bluetooth .
Any clue?
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.