I have setup a ESPhome node for which changes the brightness of the Aquarium lights via esphome automation. Connected a lcd_pcf8574 display to it. Now am trying to display the current brightness level on the display using the lambda function. The value I get is between 0-1, e.g 70% brightness is displayed as 0.7. I want to display it as a percentage. e.g Brightness 70%. How do I do that? with filters maybe?
display:
- platform: lcd_pcf8574
dimensions: 16x2
address: 0x27
id: lcd
lambda: |-
switch (id(page)){
case 1:
// Print the current time
it.strftime("Time is %c", id(sntp_time).now());
// Result for 10:06 on august 21st 2018 -> "It is 10:06 on 21.08.2018"
break;
case 2:
it.printf(0, 0, "ESP32 Halleffect: %.1fΒ΅T", id(halleffect).state);
break;
case 3:
it.printf(0, 0, "brightness: %.1f", id(AqauriumLight).current_values.get_brightness());
break;
}
I didnβt realize you can do switch case statements in a lambda. I thought I read somewhere that there was a feature request for that, do you know how long thatβs been possible?
I think Iβve only used switch case a handful of times and that was in my Arduino days. I just remembered seeing a feature request for it but I looked again, it was a request to use it directly in esphome not a lambda. Itβs all good to know though. No one ever complained about knowing to much.