LED-ClockShelf
LED-ClockShelf copied to clipboard
Explanation of Light Sensor Values
After setting up the clock and getting the clock to behave the way I want (dim slightly as it gets dark, brighten as the room is brighter), I realize I do not have a firm understanding of how these values work. For me, the LIGHT_SENSOR_SENSITIVITY made the most sense in terms of how it affected brightness, but still not sure of the range (0-255) and how that translates to control. Similarly, what are the ranges of the min and max and how does that affect the brightness?
* \brief AnalogRead value if the light sensor reads complete darkness
*/
#define LIGHT_SENSOR_MIN 3000
/**
* \brief AnalogRead value if the light sensor reads the brightest
*/
#define LIGHT_SENSOR_MAX 0
/**
* \brief Value between 0 and 255 that determines how much the light sensor values can influence the led brightness
*/
#define LIGHT_SENSOR_SENSITIVITY 30
I too would like to know the optimal settings for these. I completed my clock a few days ago and things are working great so far, but it would be fun to tweak things further.
@florianL21, I made several bug fixes and would like to push back as it might help others in the future. I was unable to create a branch or push anything so I created a fork instead. Maybe consider updating permissions here so others can suggest fixes.
- Fixed issue where clock color would default to WIFI_CONNECTION_SUCCESSFUL_COLOR only. It now uses HOUR_COLOR and MINUTE_COLOR as intended.
- Improved light sensor configuration by changing LIGHT_SENSOR_SENSITIVITY control (0-255) to be percentage-based (0-100); this makes it much easier to understand and control. It will dim the LEDs by up to X-percentage when the light sensor detects low light. For example: With LIGHT_SENSOR_PERCENTAGE at 85 and DEFAULT_CLOCK_BRIGHTNESS at 128, if the light sensor detects complete darkness (4095), brightness will be reduced to 19 (15% of 128). This works so much better than before, and it's predictable.
- Along with the above change I updated logic in DisplayManager so LIGHT_SENSOR_MIN and LIGHT_SENSOR_MAX would function correctly. I noticed that several uses (including myself) had to reverse these values because it was dimming the wrong way. The correct setting for these should be (at least based on my sensor) LIGHT_SENSOR_MIN = 4095, LIGHT_SENSOR_MAX = 0. Yes, it's the opposite of what you would think.
- In several places I noticed hardcoded brightness values in main.cpp. I updated these to DEFAULT_CLOCK_BRIGHTNESS so everything is more consistent and predictable.
By the way, @florianL21, thank you so much for what you have created. I know it has been 4 or 5 years since you wrote most of this, but there are still people making the DIY machines clock. 🥇
I would very much like to convert this project to ESPHome -- but I'll have to see how much free time I have in the near future to help with that.
@Iraithium I've seen you have been busy and I am happy to hear that you made some improvements. I'm more than happy to have you contribute them to the repo :) I believe with github a fork is the correct way to contribute to a repo. You should have the option in your fork to create a pull request to the upstream repo which I can then review and approve. For example in one of my forked repos there is a button on the main page of the repo on top of the page which is labeled "Contribute". If this is not there then indeed I have to check the permissions of this repo again.
As for the further improvements and conversion to ESPHome, this is something similar to what I have been thinking about doing myself as well, especially to get away from using blynk as I am not a fan of cloud services. I have thought of multiple ways on how to do that over the years:
- Initially I wanted to make the whole project dynamically configurable via it's own web interface similar to what WLED is doing. There is some work done in the dynamic config branch, which is functional as far as I remember, but still has some bugs. But this won't be of much use with ESPHome.
- I am not super familiar what is needed to get some code to connect with HA over the ESPHome protocol, and I have done quite some searching. As far as I can tell there is no library that they offer which can be used to "add ESPHome" to an existing project. Instead it seems to me that it has to happen the other way around, which is making the codebase into a custom component and then including that in an ESPHome config file.
- Another avenue to explore would be to make use of the new Matter APIs from Espressif. This would even have the benefit of users using other smart home systems like google home or alexa to be able to use it. But I have even less experience with that approach.
In any case, I am very happy to see that this project is still enjoyed by lots of people and I do still intend to help out as much as I can.
And thank you for the improvements and fixing some of my bugs :)
hello,
I have been reconfiguring mqtt on my watch for a few weeks now, but I can't really program and most of it was generated by Chatgpt, so there will still be work to be done there. I have also changed the previous settings on my watch. But maybe you would like to take a look at the idea and implementation?
@Iraithium I've seen you have been busy and I am happy to hear that you made some improvements. I'm more than happy to have you contribute them to the repo :) I believe with github a fork is the correct way to contribute to a repo. You should have the option in your fork to create a pull request to the upstream repo which I can then review and approve. For example in one of my forked repos there is a button on the main page of the repo on top of the page which is labeled "Contribute". If this is not there then indeed I have to check the permissions of this repo again.
As for the further improvements and conversion to ESPHome, this is something similar to what I have been thinking about doing myself as well, especially to get away from using blynk as I am not a fan of cloud services. I have thought of multiple ways on how to do that over the years:
- Initially I wanted to make the whole project dynamically configurable via it's own web interface similar to what WLED is doing. There is some work done in the dynamic config branch, which is functional as far as I remember, but still has some bugs. But this won't be of much use with ESPHome.
- I am not super familiar what is needed to get some code to connect with HA over the ESPHome protocol, and I have done quite some searching. As far as I can tell there is no library that they offer which can be used to "add ESPHome" to an existing project. Instead it seems to me that it has to happen the other way around, which is making the codebase into a custom component and then including that in an ESPHome config file.
- Another avenue to explore would be to make use of the new Matter APIs from Espressif. This would even have the benefit of users using other smart home systems like google home or alexa to be able to use it. But I have even less experience with that approach.
In any case, I am very happy to see that this project is still enjoyed by lots of people and I do still intend to help out as much as I can.
And thank you for the improvements and fixing some of my bugs :)
Thanks @florianL21. I put the PR in. Have a look and let me know. The changes are relatively small.
Yes, I was reading the same things about ESPHome with making a custom component. It should be possible since ESPHome was built on PlatformIO and it would make integration with Home Assistant easier. I have somewhere around 30 ESPHome devices already and I love them. I'll look into it.
I'm 100% with you on using cloud services. I avoid using them where possible and do quite a bit of self hosting on my homebuilt cluster. I was tempted to experiment with Blynk but decided against it.
hello,
I have been reconfiguring mqtt on my watch for a few weeks now, but I can't really program and most of it was generated by Chatgpt, so there will still be work to be done there. I have also changed the previous settings on my watch. But maybe you would like to take a look at the idea and implementation?
I used to have many MQTT devices, but over time I transitioned away because I found MQTT unreliable. Instead of communicating directly with Home Assistant it goes through a self-hosted broker or you have to use the cloud. Retiring my MQTT broker was the primary reason I moved away from Tasmota. ESPHome is much nicer as their API talks to Home Assistant directly.
But anyway ... my primary reason for posting was to say that I have a fully working version for ESPHome and Home Assistant now. This project was the inspiration, but this ESPHome version is basically new code. I tried to convert this project directly, but it was very difficult with all the recent ESPHome changes. They recently deprecated Custom Components entirely and their documentation on External Component, their structure and pattern, was extremely limited. Their approach was basically "copy one of the existing components and figure it out" -- Haha. To speed things up I used AI (Grok) to do the heavy lifting. I created three separate projects. The first one actually worked for running the clock, but I was unable to create the necessary components for Home Assistant integration (number, switch, light, select). The biggest hurdle was the Python code. The Python essentially acts as a preprocessor, generating the necessary C++ code based on the configuration. I found quite a few bugs along the way, primarily with ESPHome's Light component. You would think each component would operate the same way as far as creating new entities, but it doesn't.
To make a long story short, I essentially used the working parts of one attempt with the working parts of another to create a single working version. But becuse of the issues with the 'Light' component, there is no color picker for Home Assistant, it's just a select list of colors to choose from, but it works for now. My goal was to be able to control basic functionality through Home Assistant, and I accomplished that. The only thing it's lacking is the animations that @florianL21 created and there's no alarm mode or timer mode. I can probably add more features in the future. My version only supports 12 hours (32 segments). If you wanted 24 hours (37 segments) you would have to make some changes in the C++.
@Iraithium very nice, do you plan to release the HA integration code?
@Iraithium very nice, do you plan to release the HA integration code?
Sorry for the late reply. Yes, you can find the ESPHome version here.
https://github.com/Iraithium/esphome-led-clock-shelf
Please try it out and let me know how it goes.