ESPHome display dates from other entities

So I have been trying to make an e-paper ESP32 driven dashboard. I am amble to pull in the current date and other information just fine. However, I am trying to pull in a forecast for the next 3 days with the day’s names (“Mon”, “Wed”, etc). I have tried a few different ways of doing this so I am happy to try others.

I can see that the state of the entity is a timestamp.

In my ESPHome Yaml I have tried adding it as a sensor and a text_sensor at different times.

text_sensor:

  - platform: homeassistant
    id: weather_now_icon
    entity_id: sensor.pirateweather_current_icon

  - platform: homeassistant
    id: weather_icon_d1
    entity_id: sensor.pirateweather_icon_1d

  - platform: homeassistant
    id: forecast_d1_day
    entity_id: sensor.pirateweather_time_1d

However, no matter what way I try to put that on the ESPHome screen I cannot get it to work. Yes I have read the date stuff on ESPHome’s support pages, the difference is I am not pulling the default HA time and instead a different timestamp from a sensor in HA.

Second to last line has latest iteration, but don’t let that stop you from suggesting something else. All iterations so far have resulted in displaying “0x0p+0”

    lambda: |-
      // Map weather states to MDI characters.
      std::map<std::string, std::string> weather_icon_map
        {
          {"cloudy", "\U000F0590"},
          {"cloudy-alert", "\U000F0F2F"},
          {"cloudy-arrow-right", "\U000F0E6E"},
          {"fog", "\U000F0591"},
          {"hail", "\U000F0592"},
          {"hazy", "\U000F0F30"},
          {"hurricane", "\U000F0898"},
          {"lightning", "\U000F0593"},
          {"lightning-rainy", "\U000F067E"},
          {"clear-night", "\U000F0594"},
          {"night-partly-cloudy", "U000F0F31"},
          {"partlycloudy", "\U000F0595"},
          {"partly-lightning", "\U000F0F32"},
          {"partly-rainy", "\U000F0F33"},
          {"partly-snowy", "\U000F0F34"},
          {"partly-snowy-rainy", "\U000F0F35"},
          {"pouring", "\U000F0596"},
          {"rainy", "\U000F0597"},
          {"snowy", "\U000F0598"},
          {"snowy-heavy", "\U000F0F36"},
          {"snowy-rainy", "\U000F067F"},
          {"sunny", "\U000F0599"},
          {"clear-day", "\U000F0599"},
          {"sunny-alert", "\U000F0F37"},
          {"sunny-off", "\U000F14E4"},
          {"sunset", "\U000F059A"},
          {"sunset-down", "\U000F059B"},
          {"sunset-up", "\U000F059C"},
          {"tornado", "\U000F0F38"},
          {"windy", "\U000F059D"},
          {"windy-variant", "\U000F059E"},
        };
      // Top Row of Dashboard
      it.print(it.get_width(), 0, id(small), TextAlign::TOP_RIGHT, "My City");
      it.strftime(it.get_width(), 33, id(small), TextAlign::TOP_RIGHT, "%a, %b %d", id(homeassistant_time).now());
      it.printf(0, 4, id(font_mdi_large), "%s", weather_icon_map[id(weather_now_icon).state.c_str()].c_str());
      it.printf(60, 0, id(medium), "%.0f°", id(temp_now).state);
      it.printf(0, 65, id(tiny), "Feels like %.0f°", id(feels_like).state);
      it.printf(5, 86, id(tiny), "Precip %.0f%%", id(today_precip_chance).state);
      // Middle Row of Dashboard
      it.printf(100, 125, id(tiny), id(forecast_d1_day).state.strftime("%a"));
      it.printf(100, 145, id(font_mdi_large), "%s", weather_icon_map[id(weather_icon_d1).state.c_str()].c_str());


For anyone who runs into this problem, I solved it in a somewhat indirect way.

First. I made an Input Text helper in Home assistant.

Second. I made an Automation. The Automation triggers daily at 3am (picked a time). This then triggers an input text set value that grabs the pirate weather sensor datetime value and changes it to the format that I want to display on the ESPHome Dashboard. It then sets the input text value to that formatted value.

alias: "ESP: Weather Helper Setting"
description: ""
triggers:
  - trigger: time
    at: "03:00:00"
conditions: []
actions:
  - action: input_text.set_value
    metadata: {}
    data:
      value: "{{ as_datetime(states('sensor.pirateweather_time_1d')).strftime('%a') }}"
    target:
      entity_id: input_text.pw_day_1_name
mode: single

Next, on the ESPHome Weather Dashboard Yaml I added a text sensor set to this helper value.

  - platform: homeassistant
    id: forecast_d1_day
    entity_id: input_text.pw_day_1_name

Finally, in the lambda function that displays items on Home Assistant I was able to print the day name as I desired.

      it.printf(100, 125, id(tiny), id(forecast_d1_day).state.c_str());