An E-Ink Display - HomeAssistant Data

The next focus is how can we present data that we are interested in onto our E-Ink display screen. One of the things I want to use the display for is to show information on the energy usage of our home. Within Home Assistant I have access to info like the current house battery level, energy imported from the grid, energy exported and the current costs.

So within ESPHome you can expose home assistant data by defining entries in the sensor section of the YAML file as follows :

sensor:
# solis/solar sensors
  - platform: homeassistant
    entity_id: sensor.solis_remaining_battery_capacity
    id: house_battery

  - platform: homeassistant
    entity_id: sensor.solis_daily_on_grid_energy
    id: electricity_exported

  - platform: homeassistant
    entity_id: sensor.solis_energy_today
    id: solar_prod_1

  - platform: homeassistant
    entity_id: sensor.solis_energy_today_2
    id: solar_prod_2
  
# octopus sensors
  - platform: homeassistant
    entity_id: sensor.octopus_energy_electricity_XXcurrent_accumulative_consumption
    id: electricity_imported

  - platform: homeassistant
    entity_id:  sensor.octopus_energy_electricity_XX_current_accumulative_cost
    id: electricity_cost

  - platform: homeassistant
    entity_id:   sensor.octopus_energy_electricity_XX_export_current_rate
    id: electricity_export_rate

# tesla sensors
  - platform: homeassistant
    entity_id: sensor.mr_blue_sky_battery_level
    id: tesla_battery

# andersen charger sensors
  - platform: homeassistant
    entity_id: sensor.andersena2lastcharge
    id: last_car_charge

entity_id is the named entity within your Home Assistant instance. id is the local reference to that value. To retrieve my car charger data I used the sensor described in Monitoring Anderssen Konnect A2.

To access these values from within your lambda, when trying to access numeric values you use the following form :

id(house_battery).state

String values are of the form :

(id(forecast_condition_now).state).c_str()

The lambda code then uses printf format, eg.

it.printf(x_loc, y_loc, id(textfont), "House Battery %.0f %%",id(house_battery).state);

it.printf(x_loc, y_loc, id(textfont), "%s", (id(forecast_hour_h8).state).c_str() );