lubeda / EsphoMaTrix

A simple DIY status display with an 8x32 RGB LED panel implemented with esphome.io and Home Assistant
MIT License
217 stars 23 forks source link

Adding auto-adjust brightness #101

Closed dennisse closed 1 year ago

dennisse commented 1 year ago

This adds auto-adjustable brightness.

State (on/off) is stored in a global variable. There's a switch to enable/disable the function from HA.

Brightness is calculated from the ambient light sensor. Looking at the illuminance-table at wikipedia, it seems reasonable to divide ambient light by 4 and add a bit, so the algorithm I've used is: x / 4 * 1.1. Also, to avoid setting a new brightness every 10 seconds, we only adjust brightness if it is off by more than 2%.

dennisse commented 1 year ago

What do you think is a more reasonable max? 220 (~85%)? :)

brianhanifin commented 1 year ago

@dennisse You could add a number entity that sets the max brightness (and perhaps a minimum brightness). That way everyone can set it to what works in their personal room.

dennisse commented 1 year ago

Alright. I've added aab_min and aab_max as globals to control minimum and maximum broghtness, and added aab_add to control how much to boost the brightness with. Also, I renamed autoadjust_brightness to aab_enable for consistency.

I'm reluctant to add this as something that shows up in HA. My feeling is that these aren't variables you'll play around with very often, and if you're playing around with esphome you can change these when you set up the device. I don't want this to be too complicated. I think it's enough to be able to turn autoadjustable brightness on/off in HA.

lubeda commented 1 year ago

nice thanx