How to display a Home Assistant sensor value on an OLED screen

Context:
I’m building a HA wireless yoghurt maker as a project. 97% finished but I’m struggling with a step.
I have set up a climate entity in HA where I can set the desired temp for the maker to hold at and a timer.

The climate entity is ‘climate.yoghurtmaker’ and I need to pull the temperature value that is set in the dashboard. I am trying to display the set temp and the actual temp on the OLED screen.

I understand that I need to use the -platform: homeassistant code to pull in the sensor data to the ESP8266 that will run the code on the device. What I can’t figure out is where that code goes.

If I add the following under the configuration.yaml, I get an error;

  - platform: homeassistant
    id: yoghurtmaker_settemp
    entity_id: climate.yoghurtmaker
    attribute: temperature
    internal: true

If I add it to the yaml for the ESP8266, it tells me that I need to use the Home Assistant Sensor component.

I’ve tried following some examples but I can’t get it to work. Any ideas?

There is no climate platform for homeassistant in esphome, like there is for sensor.

You could break the HA climate entity out into current_temperature and temperature with HA template sensors, then import them to esphome via homeassistant sensors.

OK, thats a new one for me. I’ll need to figure that one out and come back.

Thanks for confirming that I’m not needlessly banging my head on the wall though. :smiley:

OK, that was a great tip. thank you. I now have the Developer Tools showing the value that is set in the dashboard.

On teh yaml for the ESP8266, it is throwing an error and although I have spent some time reading the it.printf manual, I can’t figure out if this is a HA error or not.

In Dev Tools, the sensor is shown as ‘sensor.yoghurt_settemp’. Lets say the value is 104.

In the ESP yaml is:

display:
  - platform: ssd1306_i2c
    model: "SH1106 128x64"
    reset_pin: D0 #GPIO16
    address: 0x3C
    lambda: |-
      it.printf(0, 0, id(font1), "%.1f °F", id(yoghurtmaker_temperature).state);
      it.printf(0, 20, id(font1), "%.1f °F", ??(yoghurt_settemp).state);

Where the ?? are, I can’t figure out what needs to go there. Line above works OK but that is pulling temp data directly from the dallas connected to the board. The bottom line is trying to pull the data from the HA template sensor but ‘id’ creates an error that the id cannot be found (I created a unique_id: entry in the template) and neither does ‘sensor(yoghurt_settemp).state);’

What am I missing?

Have you imported the ha sensor to esphome?

sensor:
  - platform: homeassistant
    entity_id: the ha enitity id
    id: yoghurt_settemp

Then I ihink you’ll want to print

id(yoghurt_settemp).state
1 Like
dallas:
  - pin: D5 #GPIO14
    update_interval: 15s
i2c:
  sda: D2
  scl: D1

display:
  - platform: ssd1306_i2c
    model: "SH1106 128x64"
    reset_pin: D0 #GPIO16
    address: 0x3C
    lambda: |-
      it.printf(0, 0, id(font1), "%.1f ºF", id(yoghurtmaker_temperature).state);
      it.printf(0, 20, id(font1), "%.1f ºF", id(yoghurt_settemp).state);
      
switch:
  - platform: restart
    name: Yoghurt Maker Restart  

  - platform: gpio
    pin:
      number: D6 #GPIO12
      inverted: yes
    restore_mode: Restore_Default_Off
    name: "Yoghurt Maker Heater"
    id: yoghurtmaker_heater

  - platform: gpio
    pin:
      number: D7 #GPIO13
      inverted: yes
    restore_mode: Restore_Default_Off
    name: "Yoghurt Maker Timer"
    id: yoghurtmaker_timer

sensor:
  - platform: dallas
    address: 0x773c01b5567f8028
    name: "Yoghurt Maker Temperature"
    id: yoghurtmaker_temperature
    device_class: "temperature"
    state_class: "measurement"
    unit_of_measurement: "ºF"
    accuracy_decimals: 1
    filters:
      - filter_out: nan
      - lambda: return x * (9.0/5.0) + 32.0;
      
  - platform: homeasssistant
    entity: yoghurt_settemp
    id: yoghurt_settemp

When I add the -platform: homeassistant section, I get 'Platform not found: ‘sensor.homeassistant’.

I copied and pasted…one too many ‘s’ in homeassistant. LOL.

entity: turned out to be 'entity_id: and required ‘sensor.yoghurt_settemp’

Seems to have resolved now. Deeply grateful @nickrout

Sorry about that, I was on my tablet, not the easiest to type on. I changed it in my post, just in case someone else attempts to copy.

No apologies, please. You are a superstar in this community and you helped me to overcome the frustration and push forward and learn new stuff.

I’m almost done with this project so I might see if I can figure out blueprints so I can share. Seems there are no decent yoghurt makers out there with decent functionality.

1 Like

But esphome supports attributes since mid 2021:

Essentially makes this obsolete:

And allows the same by only using something like that in esphome:

# Example configuration entry
sensor:
  - platform: homeassistant
    id: current_temperature
    entity_id: climate.living_room
    attribute: current_temperature
1 Like

I didn’t realise you could do that, I thought it had to be an attribute of a ha sensor, didn’t realse you could use the attribute from a different domain. Obviously my reading skills let me down.

Sorry for the delay, I got dragged off on other stuff.

So, am I interpreting correctly here that the climate yaml can now go in the ESPhome yaml file and I then access that from a climate card in the HA dashboard?

That would make things way easier but then, when the device is offline, would throw a ‘device not found’ error but somewhere in the back of my mind I think there is a conditional card that I may be able to use to only show that control when the device is online.

I’ll check it out.

Well, I could go back and delete that last post but I think it might help someone else with the same thought to leave it there.

Climate stays in the configuration.yaml but no need to break out the sensors with templates in the configuration.yaml. THAT is the part that ESPhome can do directly now.