I have a template sensor that displays the time half an hour before sun set.
sensor:
- platform: template
sensors:
sun_sun_time_sunset_offset_template:
value_template: '{{ (as_timestamp(states.sun.sun.attributes.next_setting) -1800) | timestamp_custom("%H:%M") }}'
I want to display it on a SSD1306 display on an ESPHome managed nodemcu.
In ESPHome I defined the sensor:
sensor:
- platform: homeassistant
id: sun_sun_time_sunset_offset_template
entity_id: sensor.sun_sun_time_sunset_offset_template
internal: true
and added this sensor to the display lambda
lambda: |-
it.printf( 0, 8, id(my_font1), "%s", id(sun_sun_time_sunset_offset_template).state);
The error I get is:
src/main.cpp: In lambda function:
src/main.cpp:466:84: warning: format '%s' expects argument of type 'char*', but argument 6 has type 'double' [-Wformat=]
it.printf( 0, 8, my_font1, "%s", sun_sun_time_sunset_offset_template->state);
I don’t understand how to set it correct.