Hi there!
I’m pretty new to HA and ESPHome and I’m in the process to building a small e-ink dashboard where I want to display room temperatures and have a little icon shown if any of the radiatior thermostats are set to “heat”.
For that purpose I have bought some cheap Hama smart radiatior thermostats. I can see them in HA and they seem to work fine.
I have not yet managed to get any detailed attributes from the thermostat integration in HA, so I cannot set up any sort if binary sensor. But I have also managed to read out their state (which is either “heat” or “off”) from a text_sensor (see image).
Is there a way to do a if condition that compares the value like this for example?
if (id(humidity_bedroom).state.cr_str() === "heat")) {
it.printf(x, y, id(font_icons_tiny), TextAlign::BASELINE_LEFT, ICON_fire);
}
The full code of my YAML is the following:
substitutions:
run_time: 1min
sleep_time: 20min
esphome:
name: lilygo-1
platform: ESP32
board: esp32dev
# Enable Home Assistant API
api:
encryption:
key: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
ota:
password: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Lilygo-1 Fallback Hotspot"
password: "xxxxxxxxxxxxxxxxxxxxxxx"
captive_portal:
# Enable logging
logger:
spi:
clk_pin: 18
mosi_pin: 23
time:
- platform: homeassistant
id: homeassistant_time
sensor:
- platform: homeassistant
entity_id: sensor.lumi_lumi_weather_temperature
id: temp_bedroom
- platform: homeassistant
entity_id: sensor.lumi_lumi_weather_temperature_2
id: temp_livingroom
- platform: homeassistant
entity_id: sensor.lumi_lumi_weather_humidity
id: humidity_bedroom
- platform: homeassistant
entity_id: sensor.lumi_lumi_weather_humidity_2
id: humidity_livingroom
- platform: homeassistant
entity_id: sensor.energieverbrauch_total
id: energie_tagesgesamt
- platform: homeassistant
entity_id: climate.thermostat_wohnzimmer_thermostat
id: thermostat_wohnzimmer
on_value: # Actions to perform once data for the last sensor has been received
then:
- script.execute: all_data_received
text_sensor:
# sun/moon
- platform: homeassistant
entity_id: climate.thermostat_wohnzimmer_thermostat
id: thermostat
internal: true
script:
- id: all_data_received
then:
- component.update: t5_display
font:
- file: "gfonts://Roboto"
id: roboto
size: 15
- file: "gfonts://Roboto"
id: roboto_medium
size: 12
- file: "gfonts://Roboto"
id: roboto_small
size: 9
- file: "fonts/Context Ultra Condensed SSi Ultra Condensed.ttf"
id: context_big
size: 32
# material UI icons - from https://pictogrammers.github.io/@mdi/font/5.3.45/
- file: 'fonts/materialdesignicons-webfont.ttf'
id: font_icons
size: 130
glyphs:
- "\U000F0594" # clear-night
- "\U000F0590" # cloudy
- "\U000F0591" # fog
- "\U000F0592" # hail
- "\U000F0593" # lightning
- "\U000F067E" # lightning-rainy
- "\U000F0F31" # night-partly-cloudy
- "\U000F0595" # partly-cloudy
- "\U000F0596" # pouring
- "\U000F0597" # rainy
- "\U000F0F36" # snowy
- "\U000F067F" # snowy-rainy
- "\U000F0599" # sunny
- "\U000F059D" # windy
- "\U000F059E" # windy-variant
- "\U000F0F38" # exceptional
- file: 'fonts/materialdesignicons-webfont.ttf'
id: font_icons_small
size: 24
glyphs:
# weather
- "\U000F0594" # clear-night
- "\U000F0590" # cloudy
- "\U000F0591" # fog
- "\U000F0592" # hail
- "\U000F0593" # lightning
- "\U000F067E" # lightning-rainy
- "\U000F0F31" # night-partly-cloudy
- "\U000F0595" # partly-cloudy
- "\U000F0596" # pouring
- "\U000F0597" # rainy
- "\U000F0F36" # snowy
- "\U000F067F" # snowy-rainy
- "\U000F0599" # sunny
- "\U000F059D" # windy
- "\U000F059E" # windy-variant
- "\U000F0F38" # exceptional
- "\U000F054B" # umbrella
- "\U000F0238" # fire
# moon phases
- "\U000F0F61" # moon-first-quarter
- "\U000F0F62" # moon-full
- "\U000F0F63" # moon-last-quarter
- "\U000F0F64" # moon-new
- "\U000F0F65" # moon-waning-crescent
- "\U000F0F66" # moon-waning-gibbous
- "\U000F0F67" # moon-waxing-crescent
- "\U000F0F68" # moon-waxing-gibbous
# other icons
- "\U000F10C2" # Temperature High
- "\U000F10C3" # Temperature Low
- "\U000F02E3" # Bed
- "\U000F04B9" # sofa
- "\U000F09A0" # shower
- "\U000F00ED" # calendar
- "\U000F104D" # cottage
- "\U000F06D9" # garage
- "\U000F06A1" # terrace
- "\U000F19A3" # mainentance
- "\U000F140B" # energy
# battery
- "\U000F008E" # bat empty
- "\U000F007A" # bat 10
- "\U000F007B" # bat 20
- "\U000F007C" # bat 30
- "\U000F007D" # bat 40
- "\U000F007E" # bat 50
- "\U000F007F" # bat 60
- "\U000F0080" # bat 70
- "\U000F0081" # bat 80
- "\U000F0082" # bat 90
- "\U000F0079" # bat 100
- file: 'fonts/materialdesignicons-webfont.ttf'
id: font_icons_tiny
size: 18
glyphs:
- "\U000F005E" # arrow-up-thick
- "\U000F0046" # arrow-down-thick
- "\U000F0238" # fire
display:
- platform: waveshare_epaper
id: t5_display
cs_pin: 5
dc_pin: 17
busy_pin: 4
reset_pin: 16
model: 2.90inv2
# update_interval: 1min
update_interval: never
full_update_every: 1
rotation: 90
lambda: |-
// icon constants
#define ICON_temp_high "\U000F10C2"
#define ICON_temp_low "\U000F10C3"
#define ICON_umbrella "\U000F054B"
#define ICON_sofa "\U000F04B9"
#define ICON_bed "\U000F02E3"
#define ICON_shower "\U000F09A0"
#define ICON_up "\U000F005E"
#define ICON_down "\U000F0046"
#define ICON_sun "\U000F0599"
#define ICON_calendar "\U000F00ED"
#define ICON_cottage "\U000F104D"
#define ICON_garage "\U000F06D9"
#define ICON_terrace "\U000F06A1"
#define ICON_maintenance "\U000F19A3"
#define ICON_fire "\U000F0238"
#define ICON_energy "\U000F140B"
// positioning constants
#define xRes 256
#define yRes 128
#define xCenter (xRes/2 + 60) // X position center
#define pad 10
#define celsiusSuperscript 5
#define rowHeight 24
#define temperatureCol 65
#define humidityCol 100
#define heaterCol 115
#define weatherCol 120
#define weatherTempCorr 15
// Test positioning constants
#define xTopLeft -15
#define yTopLeft 0
#define xTopRight 256
#define yTopRight 0
#define xLowerLeft 0
#define yLowerLeft 128
#define xLowerRight 256
#define yLowerRight 128
// helper variables
int y = 0;
// Temperature Living Room
y = 60;
it.printf(pad, y, id(font_icons_small), TextAlign::BASELINE_LEFT, ICON_sofa);
if (!isnan(id(temp_livingroom).state)) {
it.printf(temperatureCol, y, id(roboto), TextAlign::BASELINE_RIGHT, "%.1f", id(temp_livingroom).state);
it.printf(temperatureCol, y - celsiusSuperscript, id(roboto_small), TextAlign::BASELINE_LEFT, "°C");
}
if (!isnan(id(humidity_livingroom).state)) {
it.printf(humidityCol, y, id(roboto_medium), TextAlign::BASELINE_RIGHT, "%.0f", id(humidity_livingroom).state);
it.printf(humidityCol, y, id(roboto_small), TextAlign::BASELINE_LEFT, "%%");
}
it.printf(heaterCol, y, id(roboto_medium), TextAlign::BASELINE_LEFT, id(thermostat).state.c_str());
// Show fire symbol when heater is on
// it.printf(heaterCol, y, id(font_icons_tiny), TextAlign::BASELINE_LEFT, ICON_fire);
// Temperature Bedroom
y += rowHeight;
it.printf(pad, y, id(font_icons_small), TextAlign::BASELINE_LEFT, ICON_bed);
if (!isnan(id(temp_bedroom).state)) {
it.printf(temperatureCol, y, id(roboto), TextAlign::BASELINE_RIGHT, "%.1f", id(temp_bedroom).state);
it.printf(temperatureCol, y - celsiusSuperscript, id(roboto_small), TextAlign::BASELINE_LEFT, "°C");
}
if (!isnan(id(humidity_bedroom).state)) {
it.printf(humidityCol, y, id(roboto_medium), TextAlign::BASELINE_RIGHT, "%.0f", id(humidity_bedroom).state);
it.printf(humidityCol, y, id(roboto_small), TextAlign::BASELINE_LEFT, "%%");
}