I have a tft screen set up using LVGL. I have a label where I want to display the current temperature. I get the temp from HA using a sensor: I have tried many things to get the lvgl.label.update to take the temp but I just get errors or the wrong value.
here is what i have
on_click:
lvgl.label.update:
id: display_temperature
text:
format: “%.1f °C”
args: [ ‘id(current_temperature).state’ ]
any help would be appreciated!
sensor:
- platform: homeassistant
id: current_temperature
entity_id: sensor.home_ist
internal: true
on_value:
- lvgl.label.update:
id: display_temperature
text:
format: "%.1f °C"
args: [ 'id(current_temperature)' ]
lvgl:
displays:
- cyd
touchscreens:
- touch
buffer_size: 25%
color_depth: 16
bg_color: red
pad_all: 0
border_width: 0
border_color: ha_blue
outline_width: 0
shadow_width: 0
text_font: roboto40
align: center
style_definitions:
- id: default_style # choose an ID for your definition
bg_color: 0x010101 #black
text_color: 0xffffff #white
align: CENTER
text_align: CENTER
- id: red_style # choose an ID for your definition
bg_color: 0x000000 #black
text_color: 0xff0000 #red
align: CENTER
text_align: CENTER
pages:
- id: main_page
pad_all: 0
widgets:
- obj:
styles: default_style
align: CENTER
width: 480
height: 320
layout:
type: GRID
grid_columns: [fr(25),fr(50),fr(25)]
grid_rows: [fr(7),fr(29),fr(7),fr(25),fr(7),fr(25)]
widgets:
- label:
grid_cell_row_pos: 0
grid_cell_column_pos: 1
grid_cell_x_align: STRETCH
grid_cell_y_align: STRETCH
border_width: 1
border_color: 0xffffff
text: "Target Temperature"
text_font: roboto10
text_align: CENTER
- button:
styles: red_style
id: temp_up
border_width: 1
border_color: 0xffffff
grid_cell_row_pos: 1
grid_cell_column_pos: 0
grid_cell_x_align: STRETCH
grid_cell_y_align: CENTER
widgets:
- label:
text: "\U0000F379" # temp up
text_font: icon_font_34
on_click:
- lvgl.label.update:
id: display_temperature
text:
format: "%.1f °C"
args: [ 'id(current_temperature).state' ]
- label:
text: "--.- °C"
id: display_temperature
text_font: roboto40
text_align: CENTER
grid_cell_row_pos: 1
grid_cell_column_pos: 1
grid_cell_x_align: STRETCH
grid_cell_y_align: STRETCH
border_width: 1
border_color: 0xffffff
- button:
id: temp_down
grid_cell_row_pos: 1
grid_cell_column_pos: 2
grid_cell_x_align: STRETCH
grid_cell_y_align: CENTER
border_width: 1
border_color: 0xffffff
widgets:
- label:
text: "\U0000F37a" # temp down
text_font: icon_font_34
text_align: CENTER
text_color: 0x0000ff
on_click:
- lvgl.label.update:
id: display_temperature
text:
format: "%.1f °F"
args: [ 'id(current_temperature)' ] [quote="cormiersa, post:1, topic:823830, full:true"]
I have a tft screen set up using LVGL. I have a label where I want to display the current temperature. I get the temp from HA using a sensor: I have tried many things to get the lvgl.label.update to take the temp but I just get errors or the wrong value.
here is what i have
on_click:
- lvgl.label.update:
id: display_temperature
text:
format: "%.1f °C"
args: [ 'id(current_temperature).state' ]
any help would be appreciated!
[/quote]
So the error is what is displayed. I expected “20.5 °C” but when it first resets I get two empty squars a dot and one empty square and °C. basically " . °C" then on temp_up button push I get “nan °C” and on temp_down button push I get “1.8 °F”. buttons were set up to test different args: to find the correct one.