if the solar_voltage gets higher than 22V the MAX7219 gets values over 15.
How can i limit the output of the filter so it never goes higher than 15? (Thats the brightes value for the MAX…)
Or could i use the sun.sunset /sun.sunrise in the filter?
Goal is to turn the display dark when day is gone.
So if it would be easier with the sun value i go that way.
can filter accept sunrise ? or only number values?
I have tried both variants, the sun variant works but it doesn’t look so good, just too much brightness switching. Technical ok but not for human eys.
So i tried your first variant and this seems to be it!
If there are more different brightness steps needed, one can just add another block.
So here my finished code, maybe someone else find it useful:
esphome:
name: pool_temp
platform: ESP8266
board: d1_mini
# Enable Home Assistant API
api:
password: "xxxxxxxx"
ota:
password: "xxxxxxxx"
wifi:
networks:
- ssid: "xxxxxxxx 2"
password: "xxxxxxxx"
- ssid: "xxxxxxxx 3"
password: "xxxxxxxx"
manual_ip:
static_ip: 192.168.2.254
gateway: 192.168.2.1
subnet: 255.255.252.0
web_server:
port: 80
dallas:
- pin: GPIO05
update_interval: 30s
sensor:
- platform: dallas
address: 0x8001212f15e6c228
name: "POOL Luft Temp"
id: "DS18B20_1"
- platform: dallas
address: 0x1001212ecab08628
name: "POOL Wasser Temp"
id: "DS18B20_2"
- platform: dallas
address: 0x8b01212f137c8e28
name: "POOL Solar Temp"
id: "DS18B20_3"
- platform: dallas
address: 0x6601212f0084db28
name: "POOL Heizung Temp"
id: "DS18B20_4"
- platform: homeassistant
name: "Pool Temp Display Brightness"
id: "max7219_bright"
entity_id: "sensor.solar_input_voltage" # Data comes over MQTT of my MPPT-Charger over HA
on_value:
then:
lambda: |-
if (id(max7219_bright).state < 10.0) # if Solar-Voltage less than 10V it is nearly dark
{
auto call = id(brightness).make_call();
call.set_value(0); # Set MAX7219 Brightness to 0 (this is not off, but the lowest Brightness)
call.perform();;
}
else if ((id(max7219_bright).state > 10.0) and (id(max7219_bright).state <= 20.0))
{
auto call = id(brightness).make_call();
call.set_value(5);
call.perform();;
}
else if ((id(max7219_bright).state > 20.0) and (id(max7219_bright).state <= 28.0))
{
auto call = id(brightness).make_call();
call.set_value(12);
call.perform();;
}
else
{
auto call = id(brightness).make_call();
call.set_value(15);
call.perform();;
}
number:
- platform: template
id: brightness
optimistic: true
min_value: 0
max_value: 15
step: 1
spi:
clk_pin: 14
mosi_pin: 13
display:
- platform: max7219
cs_pin: 04
num_chips: 2
intensity: 1
lambda: |-
it.set_intensity(id(max7219_bright).state);
it.printf(0, " ");
it.printf(1, "%.1f", id(DS18B20_1).state);
it.printf(4, " ");
it.printf(5, "%.1f", id(DS18B20_2).state);
it.printf(8, " ");
it.printf(9, "%.1f", id(DS18B20_4).state);
it.printf(12, " ");
it.printf(13, "%.1f", id(DS18B20_3).state);