Closed titilambert closed 6 years ago
Hi, Is only one issue, i'm not really python expert, never did the things you mention. I start to play with python after i saw the mysql/php implementation drawbacks and when somebody suggeste in one issue to take in consideration the programming language replacement. Now because the number of lines is too big i start to perform some seggragation, but is not easy to do this with the functions that use the bridge_config dict. If you know how to clean my code i will be happy to merge your pull requests.
Thanks for your answer ! Sorry I was not clear, I can do that ! My question was more about are you opened to that kind of thing ? If yes, I can start a fork/branch and make some merge requests ;)
Yes, this will be an improvement for sure.
Marius.
@mariusmotea I would suggest split this repository in two repositories:
BridgeEmulator
folder as root)Maybe you should also move the web-ui source, but I didn't read the code yet
Hi,
But what will be the benefit of this split? I'm thinking about the current issues, people will not know exactly if one issue is related to bridge or the lights, etc.
Marius.
I see ! So I just changed the folder structure. You can see it here: https://github.com/titilambert/diyHue What do you think about this ?
Is ok, only issue is to correct the actual links to images folder.
@mariusmotea Hello, I started splitting the HueEmulator3.py
file in the huebridgeemulator
folder.
My main issue today is to understand how this is working to validating I didn't break anything.
So for now, the daemon is starting, I can go the web page but it's kind of empty:
What did I miss ? Thanks !
start HueEmulator3.py script manually, i believe there are some errors when you open this page.
What do yo mean "some errors" ? In fact, I'm just wondering what I should get ? (my configuration is empty and I never used hueEmulator before ) I started the daemon, then what I have to do ? I have a yeelight bulb and a hue bridge. How can I add them to hueemulator config ? Thanks !
Ohh. I was believed that your lights are not displayed. Is fine to not have any lights displayed if there are no lights/rooms.
Marius.
Perfect, How can I add my yeelight bulb ?
Enable lan mode on the bulb, i write how in wiki. Then once the bulb is connected to your wifi network perform a light search from hue application.
OK so, the bulb is configured correctly, but how i can perform a light search ? I don't see any button in the UI
You need the android/iphone hue application
ho ! ok ! thanks ! This is really helpful !
How can I simulate a hue button click ? The hue app can not join because the button was never join ?
Access emulatorip/touchlink to allow 30seconds for apps to pair with the emulator
Default credentials Hue/Hue
Where did you define this credentials ?
Example, in browser: 192.168.8.10/hue/linkbutton Hue is the user and password
Perfect ! Thansk !
I can see yeelight bulb ! Now I will try to control it
Good luck
Success ! I can control my yeelight bulb ! Now I will try to really clean the code !
I have a fork with a branch called OpenWrt which works on lede 17.01 perfectly in GL-MT300A
Hello ! I got yeelight and Hue working ! I don't have any other devices continue the development :/ I just put a small documentation here to test it: https://github.com/titilambert/diyHue#new-folder-structure As you can see I tried clean up this wonderful project by:
What next:
@mariusmotea What do you think about this ? If you like this new structure, how do you want to proceed to do think huge change in the main repository ?
I'm in vacation a few days, but now i browse your code and looks much better than mine. I will perform a test when i will arrive home. I made a commit after you started to work on this project, it is included? It is related to sunrise and sunset calculations using the astral module for python.
@titilambert i don't want to look like i don't appreciate your effort and ask too much, but i want to ask you if you know how to create that dtls server with psk for Hue Entertainment in python. Currently i spent hard time with wolfssl library to create this service in C, but i don't have experience and i did not manage to have a successful compile.
Hello ! No worries ! I don't have any experience with dtls but I'm sure I can help you with that. I guess we can do it un python. I found this: https://gist.github.com/manuels/8852953
What do you want to priorized ? Refectoring or dtls ? I think we should complete the refactoring as soon as possible.
I don't know if I got your last commit, if not, I could try to port it to this new structure.
Let me know when you come back.
Let's finish the current migration then we can focus more on dtls. There are some libraries in python, the problem is that non offer support for DTLS server with PSK and that rare cipher used by hue entertainment
The examples from python-gnutls are not made with psk. The requirements for hue entertainment are:
Only DTLS mode version 1.2 with Pre-Shared Key (PSK) Key exchange method with TLS_PSK_WITH_AES_128_GCM_SHA256 set as Cipher Suite is supported.
@mariusmotea Do you want to create a new branch in your repository where I could push my changes then, you will be able to push also in this branch ?
Yes please. You can use develop branch as well.
@mariusmotea could you create a new branch in your repo called "refactor" ? will create a PR to this branch (including your last changes)
@mariusmotea I just applied your last patch (daylight sensor) to my branch.
@titilambert i create the new branch
I think we should create a new class: Registry The configuration is in fact a registry where groups/devices/sensors/... are registered and where theirs states are stored. At the end of the refactoring we should (kind of) "never" edit directly the "config.json" dictionnary as we are doing today.
I start to test the installation. The first issue is the lack of https. On official page of hue api was announced that http is not considered legacy and the developers have one year to switch to https. Now both services are running on original hue bridge. Can we start a new thread for https with the certificate from this repo?
Hello ! Ho ! I didn't know that ! I would suggest to not handle https directly from your source code. It should be handled by a true http server like nginx. Also you should NOT provide a certificate, this imply insecure https connection. We should provide command lines to generate the certificate or use a service like "let's encrypt" to get it. At the end, we should use ngnix running in docker to handle https. I will try to add this today.
Original Hue Bridge use nginx for https relay to http, but i try to keep this standalone and independent as much as possible. By providing the cert + key you are right, is insecure like http, but currently here we are. Original Hue Bridge generate a self signed certificate with serial number as CN (generated from mac address + 4 constant letters in the middle), but i doubt the applications check the CN as the ssl of this certificate will always fail. Hug don't support https to add it as second thread like i did?
Hi the efforts from @titilambert looked very promising. Any progress on there, it's quiet for a while?
I'm closing this as there is now an issue for each of the mentioned refactoring categories. Chat can happen in those or on slack. Feel free to open more issue for additional categories @titilambert
Hello ! I just found your project, and this is really awesome ! The only issue is the python code structure. So I'm creating this issue to know if you're open to a huge python code cleaning:
__pycache__
folderWhat do you think about this ?