Hi, I’m trying to follow the example in the LVGL cookbook aorund climate control.
I’ve also read the issue on GitHub about using on_change.
But the spinbox always starts with the lower range value no matter what I do (10 in the code below).
How do I get the initial value to be what is from the sensor?
This is my sensor code (just added the lmbda to see the value which is always correct)
- platform: homeassistant
id: office_thermostat
entity_id: climate.office
attribute: temperature
on_value:
- lvgl.spinbox.update:
id: spinbox_id
value: !lambda return x;
- lambda: |-
char temp_str[32];
snprintf(temp_str, sizeof(temp_str), "%.2f", x); // Format float to string with 2 decimal places
ESP_LOGI("Temperature", "Temperature: %s", temp_str);
and this is my widget code
- id: thermostat_control
widgets:
- obj:
align: BOTTOM_MID
y: -50
layout:
type: FLEX
flex_flow: ROW
flex_align_cross: CENTER
width: SIZE_CONTENT
height: SIZE_CONTENT
widgets:
- button:
id: spin_down
on_click:
- lvgl.spinbox.decrement: spinbox_id
widgets:
- label:
text: "-"
- spinbox:
id: spinbox_id
align: CENTER
text_align: CENTER
width: 50
range_from: 10
range_to: 35
step: 0.5
rollover: false
digits: 3
decimal_places: 1
on_change:
then:
- homeassistant.action:
action: climate.set_temperature
data:
temperature: !lambda return x;
entity_id: climate.office
- button:
id: spin_up
on_click:
- lvgl.spinbox.increment: spinbox_id
widgets:
- label:
text: "+"
Many thanks in advance
Dave