Sun next.noon not possible in ESPhome display?

For solar panel users, the time of the next higest elevation of the sun is interessant on a ePaper display but only sunrise, sunset, azimut and elevation are supported ? Is that true?
In HA i can see it.

You can get any HA info in esphome. See ESPHome — ESPHome

That’s true, however you can import the Home Assistant sensor state into ESPHome

Also you have sunrise and sunset. Midday is halfway between.

I was hoping someone would say that, but i am not skilled enough yet.
I was trying this.

sun:
  latitude: 53.00543°
  longitude: 11.75032°

text_sensor:
  - platform: sun
    name: Sun Next Sunrise
    type: sunrise
    id: sunris
    format: "%H:%M"

  - platform: sun
    name: Sun Next Sunset
    type: sunset
    id: sset
  

sensor:
  - platform: sun
    name: Sun Elevation
    type: elevation
  - platform: sun
    name: Sun Azimuth
    type: azimuth

  - platform: homeassistant
    name: "Sonnenmittag"
    id: sunnoon
    entity_id: sensor.sun_next_noon
.
.
.
display:
  - platform: waveshare_epaper
    cs_pin: 15
    dc_pin: 27
    busy_pin: 25
    reset_pin: 26
    model: 7.50inv2
    # modell A
    update_interval: 60s
    reset_duration: 2ms

    lambda: |

     it.printf(100, 115, id(icon_font125), TextAlign::TOP_LEFT, "\U000F0599");
     it.printf(400, 115, id(font0), TextAlign::TOP_CENTER, "Sonnenaufgang: %s Uhr", id(sunris).state.c_str());
     it.printf(400, 150, id(font0), TextAlign::TOP_CENTER, "Noon:  %f Uhr", id(sunnoon).state);

%f gives me nan
%s kills the WiFi connection

i would like only %H:%M

Thanks for any help.

Try using strftime instead of printf.

it.strftime(400, 150, id(font0), "Noon: %H:%M Uhr ", id(sunnoon).state); // no known conversion for argument 5 from 'float' to 'esphome::ESPTime
     it.strftime(400, 150, id(font0), "Noon: %H:%M Uhr ", id(sunnoon).now()); // 'class esphome::homeassistant::HomeassistantSensor' has no member named 'now'

Who is wiser than ChatGPT? :nerd_face:

sensor:
  - platform: homeassistant
    id: sun_next_rising_sensor
    entity_id: sensor.sun_next_rising

  - platform: homeassistant
    id: sun_next_setting_sensor
    entity_id: sensor.sun_next_setting

  - platform: homeassistant
    id: sun_next_noon_sensor
    entity_id: sensor.sun_next_noon

text_sensor:
  - platform: template
    name: "Sun Data"
    id: sun_data_text_sensor
    lambda: |-
      return {{"Next Rising:", id(sun_next_rising_sensor).state, "\n",
               "Next Setting:", id(sun_next_setting_sensor).state, "\n",
               "Next Noon:", id(sun_next_noon_sensor).state}};

lambda : |- 
   it.print(0,0,id(font_24),Color::BLACK,TextAlign::TOP_LEFT,id(sun_data_text_sensor));

error: could not convert ‘{{“Next Rising:”, sun_next_rising_sensor->esphome::homeassistant::HomeassistantSensor::.esphome::sensor::Sensor::state, “\012”, “Next Setting:”, sun_next_setting_sensor->esphome::homeassistant::HomeassistantSensor::.esphome::sensor::Sensor::state, “\012”, “Next Noon:”, sun_next_noon_sensor->esphome::homeassistant::HomeassistantSensor::.esphome::sensor::Sensor::state}}’ from ‘’ to ‘esphome::optional<std::__cxx11::basic_string >’
“Next Noon:”, id(sun_next_noon_sensor).state}};

Before you try and reinvent the wheel, maybe you should try the search boxes first… There has been an advanced Sun integration available in Hacs for like 4 years now and it provides the data/sensors for exactly what you are seeking and a lot more.

1 Like

Please don’t post chatgpt.

1 Like

Thanks Justin, just what i was searching for i am very new with HA.