-
Notifications
You must be signed in to change notification settings - Fork 638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AI Light #113
Comments
The AiLight has 1MByte flash memory, enough for the firmware (~400-ish kilobytes) and the filesystem. The reason for the 128K SPIFFS size is to allow enough room for OTA updates, and believe me, you will need OTA with this device. It should work with 128K (all the ESPurna configuration are set to 128K). The first error I guess it was probably due to not being in flash mode, or maybe a loose connection. The second one (after you flashed the filesystem using 256K size) is almost granted due to the firmware being unable to locate the filesystem since it was looking for it on the last 128K. You have to flash both the firmware and filesystem using the same configuration. |
Original comment by Michael (Bitbucket: nnelgleahcim, GitHub: Unknown): My apologies, I did not disconnect the power from the AI LIGHT after flashing the espurna code. The first time I immediately tried to "Select Tools > ESP8266 Sketch Data Upload" at which point I received the SPIFFS Upload failed! message. By power cycling the device, after the initial flashing of the espurna code, I was able to "Select Tools > ESP8266 Sketch Data Upload" with SPIFFS set to 128K and all worked as expected! Thank you very much for mentioning that the device may not have been in flash mode!!! |
Original comment by Michael (Bitbucket: nnelgleahcim, GitHub: Unknown): I have the espurna firmware installed on the AI Light, but sadly am stuck on how to use it. I tried using the web interface, but no matter what I do the bulb will not respond by lighting up. I'm thinking that I need to turn the light on somehow, but haven't been able to do so. I've toggled the light on and off multiple times, but it will not turn on or change color, even though I click "update" the web interface. Secondarily, I tried communicating with the light via MQTT, but have not made much progress there either. Thus far this is what I have tried:
Still no illumination. Have I formatted my MQTT request properly? Is there something else I need to do to get the light to turn on, beyond using the web interface? Thank you for any help that you may be able to provide. Once I get everything working I plan to do a full writeup on the Home Assistant web site. |
Original comment by Pal (Bitbucket: kalavai, GitHub: Unknown): Michael, I'm having the same issue with my AI LIGHT, if you find any answer please let me know also. Thanks, |
Original comment by Michael (Bitbucket: nnelgleahcim, GitHub: Unknown): Hi Pal, Sorry to hear you're having trouble too. If I find any solutions I'll certainly let you know. Regards, |
Original comment by Michael (Bitbucket: nnelgleahcim, GitHub: Unknown): Thank you very much for that Emmanuel! I'm going to give 1.6.7 a try now and will report back. |
Original comment by Michael (Bitbucket: nnelgleahcim, GitHub: Unknown): I was able to get the web interface of 1.6.7 to work properly and change colors on my AI Light, once I modified some errors compiling in the Arduino environment. I'll do a bit more testing and share any learnings. |
Original comment by Michael (Bitbucket: nnelgleahcim, GitHub: Unknown): Also, the 1.6.8 web interface also seems to work well with the AI Light. The only changes I needed to make were in relay.ino: function relaySetup(), I modified as follows in order to get it to compile:
I'll start testing MQTT shortly to see if I'm able to get that working too. |
Original comment by Michael (Bitbucket: nnelgleahcim, GitHub: Unknown): Per Emmanuel Tatto's feedback it appears that 1.6.9 does not properly support AI LIGHT via the Web or MQTT. I've found that I'm able to connect to an MQTT broker with 1.6.9, but not able to turn the AI LIGHT on/off or change colors. The Web works with 1.6.8 for AI LIGHT, but I'm not able to connect to an MQTT broker. I've been able to turn the AI LIGHT on and off using the following commands, but that's about it:
I may be incorrect, but I don't see api support in the code to change the light color in this version. At this point I'm done for now and am hoping for some code fixes before doing anything else with the AI LIGHT. |
You have currently two ways to change the light color: web interface of MQTT. From the web interface it's a matter of choosing the color from the color wheel. Via MQTT you have to do something like this:
In version 1.7.0 you will be able to change it also via a REST request. |
Original comment by Michael (Bitbucket: nnelgleahcim, GitHub: Unknown): Thank you Xose. Sadly for me mosquitto_pub does not seem to work with 1.6.9. I am connected, I issue the below MQTT command, no errors are shown, but unfortunately I see no light.
|
Is your AiLight connected to the MQTT broker? If so you should see several messages from it (hostname, version, ip, ...). Also, the bulb has to be both ON and a color set (different from #000000).
|
Original comment by Markus Ulsass (Bitbucket: db9fun111, GitHub: Unknown): It isn't working for me either with 1.69. No Web and MQTT-control and also no Alexa integration. But I get the "normal" MQTT-traffic when publishing commands and receiving status messages while being subscribed to /test/switch/# Any idea what has changed from 1.67/ 1.68 to 1.69 which could be the cause for not responding? |
Indeed there was a bug in the code. |
Original comment by Michael (Bitbucket: nnelgleahcim, GitHub: Unknown): I upgraded to version 1.7.0. Thank you very much for that latest version! I'm still having trouble with command line updates. The web interface works fine, but now the following no longer seems to work:
I also tried the following with no success, even though it says CONNECTED on the web status page:
For the MQTT root topic should I be using: "/test/switch/{identifier}/" (disregard the quotes) when using the above mosquitto_pub command lines? Thank you so much for any pointers you may be able to provide. |
Original comment by Markus Ulsass (Bitbucket: db9fun111, GitHub: Unknown): Thanks for updating the code. I had to change "#define AI_LIGHT" else it would throw an error (in hardware.ino) while compiling with the Arduino IDE. Alexa Integration is working, you can control the bulb via the webpage and I can also send MQTT commands. curl (HTTP REST) isn't working for me. Funny thing: If you send mqtt commands it overturns Alexa commands, e.g. setting a color with MQTT would overturn Alexa commands. Might have to do something how MQTT is handled? @nnelgleahcim Did you test it without "-u username -P password" (because you are using those variables against your MQTT-broker) and adjusted the "AI_LIGHT_06068E" to your specific lamp? EDIT: After some more tests, it seems MQTT is broken somehow. After some time it wouldn't accept new commands. |
There is a bug in HTTP requests. It's fixed in dev branch and will release it tonight if I can. Also, the bulb is not reporting the status (ON/OFF) correctly. I'm looking to fix it right now. |
Original comment by Markus Ulsass (Bitbucket: db9fun111, GitHub: Unknown): @xoseperez Yes I'm monitoring the MQTT messages and they look good. UDP debugging is enabled, but there are no messages which look suspcious. The lamp is just not reacting as expected. |
Original comment by Michael (Bitbucket: nnelgleahcim, GitHub: Unknown): After downloading version 1.7.0 and making the below changes I was able to get the AI Light working as expected.
From there I was able to issue to following API commands to turn ON my AI Light, change the color to GREEN, and turn it OFF:
I was struggling with MQTT until I realized, after seeing the debug output, that the MQTT message requires a space in the words "AI LIGHT" and not an underscore. After changing my MQTT message format to include a space I was able to turn ON my AI Light, change the color to RED and then turn it OFF with the following MQTT commands (Don't forget to change 06068E with your own CHIP ID, also the username and password are optional if you don't use MQTT security):
|
Just released version 1.7.1 which fixes the bug in the registerAPI method. |
Original comment by Michael (Bitbucket: nnelgleahcim, GitHub: Unknown): Thank you very much Xose! I had a chance to use the AI Light a bit and was disappointed to find that espurna didn't work with Home Assistant very well. After reviewing the espurna debug output I learned that the Home Assistant MQTT Light component publishes MQTT RGB color commands in the following format: {"color": "238,0,32"}, while espurna seems to recognize MQTT RGB color commands in the following format: {"color": "#256bf2"}. I spent a lot of time searching the Home Assistant forums looking for a way to modify the MQTT RGB publishing format and wasn't able to find anything. Perhaps I missed something and someone far more clever than I knows of a anther way, but I simply couldn't find a way to format the Home Assistant MQTT publishing of RGB colors. With that said, I modified the espurna function color_rgb2array in light.ino to differentiate between color payloads that began with a #. I created a quick hack to read the format based on whether the color payload started with a # or not. I'm sure more intelligent format detection could be implemented, such as looking for XX, XX, XX type formatting, but this was a quick proof of concept that showed that it works. I would like to make a feature request to include this capability in espurna, but I leave it to you as to whether it makes sense. In the meantime, I've implemented the following with great sucess. I was able to communicate with espurna using the Home Assistant MQTT Light component, using the color picker, as well as the espurna web interface. Additionaly the mosquitto_pub and curl commands work too, provided that a leading # is used in front of the RGB color. Please see below for my hack:
I used the following within my Home Assistant configuration.yaml file and I'm really pleased with how nicely everything works now:
|
Absolutely. It makes sense. |
Original comment by Michael (Bitbucket: nnelgleahcim, GitHub: Unknown): Excellent. Thank you so much Xose!!! |
Original comment by Sacha Telgenhof (Bitbucket: stelgenhof, GitHub: stelgenhof): Michael, I managed to get this AI light working with Home Assistant. However not using Espurna this time (sorry). In Home Assistant I am using the MQTT JSON Light component which uses JSON for its payload. It works very well and I managed to code all pieces like brightness, rgb colors, white value level and color temperature. (Updated with screenshot) |
No worries. The dev branch of ESPurna should work well with Home Assistant now, maybe you can give it a try. Not as complete as your solution thou. One thing I have read is that is generally not adviced to drive the white LEDs and the RGB LEDs at the same time, have you had any trouble with that? |
Original comment by Sacha Telgenhof (Bitbucket: stelgenhof, GitHub: stelgenhof): I haven't had any issues so far running both the RGB and the White LED's. Then again, I haven't done a long run yet... BTW, Big thanks for all your work and articles Xose! They are a valuable resource and inspiration :) |
Original comment by Michael (Bitbucket: nnelgleahcim, GitHub: Unknown): Hi Sacha, Very nice work! I would love to see more of how you did it! Agreed, I'm a big fan of Xose and his work as well! |
Original comment by Michael (Bitbucket: nnelgleahcim, GitHub: Unknown): FYI, I included a How To: writeup of the Ai Light in the Home Assistant Forums. |
Original comment by Sacha Telgenhof (Bitbucket: stelgenhof, GitHub: stelgenhof): Thanks Michael for the nice write up. I am refactoring some of my code, so will make it available later. Lots of bugs in it, haha |
Original comment by Michael (Bitbucket: nnelgleahcim, GitHub: Unknown): Hi Sacha, sure thing. No worries, bugs are inevitable. :-) |
Original comment by Sacha Telgenhof (Bitbucket: stelgenhof, GitHub: stelgenhof): Hi Michael, Finally got it done. Have a look at my github repos: https://github.com/stelgenhof/AiLight. I created a library/class that encapsulates the MY9291 LED driver from Xose. It contains a function named 'setColorTemperature'. Have a look at the code to see how it is done. Basically color temperature is pretty straightforward. It will set a white color based on the given temperature (e.g 2700K) and converts that to the equivalent RGB values. The conversion is based on the algorithm of Tanner Helland (See the code for the sources). Whether this is perfect/accurate I don't know: it depends partly on the quality of the LED's. However I get a nice 'warm' color if I set the slider in Home Assistant all the way to the right :) Please have a look and let me know what you think. Happy to hear recommendations and improvements (Don't use in production yet, haha). |
@nnelgleahcim Nice write-up. Thank you! @stelgenhof, I will test your library for sure. I'd like to use it in ESPurna too if you don't mind (once you feel it's ready for production). |
Original comment by Michael (Bitbucket: nnelgleahcim, GitHub: Unknown): @xoseperez Thank you very much! @stelgenhof The code looks great! Thank you very much for taking the time to share it. I look forward to trying it out very soon! |
Original comment by Sacha Telgenhof (Bitbucket: stelgenhof, GitHub: stelgenhof): @xoseperez Sure! Please be my guest to use the library or parts of it (it's open source MIT license). After all you did most of the ground work. |
Version 1.8.0 borrows code from Sacha's project as well as some other contributions to different light devices supported. |
Removing milestone: 1.8.0 (automated comment) |
Originally reported by: Michael (Bitbucket: nnelgleahcim, GitHub: Unknown)
Hi Xose,
I was able to compile and upload espurna code to the AI Light using the recommended settings in the documentation of 1M (128K SPIFFS), but when I tried to "Select Tools > ESP8266 Sketch Data Upload" I received the following error:
As a work around I tried changing the Flash Size to 1M (256K SPIFFS) and everything seemed to uploaded perfectly. The documentation may need to be adjusted?
Edit: Maybe that wasn't such a good work around after all. I'm able to connect to AI LIGHT_06XXXE, but when I try visiting "http://espurna.local" I receive a page not found error.
Thank you again for all your hard work!!!
The text was updated successfully, but these errors were encountered: