ESPhome forced DS18b20 reading


I hope someone can help me. I have a generic thermostat in the HA. I have DS18b20 on ESP8266+ESPhome which is sending the temperature values in every 180 seconds. I would like more frequent (30s) temperature readings when the HA thermostat is turned on (idle/heat). I can manage this thing with DHT11 but the DS18b20 not supported by this method:

- lambda: 'id(my_component).update();'

I got compile error:

src/main.cpp: In lambda function: src/main.cpp:84:31: error: ‘class esphome::sensor::DallasTemperatureSensor’ has no member named ‘update’ livingroom_temperature->update();

I saw in the description it is not a bug:

There is any other solution to force the DS18b20 reading? Or any other idea?


Part of my yaml for the better understanding:

  upper_devicename: "Livingroom"
  lower_devicename: "livingroom"

  - pin: GPIO2
    update_interval: 180s

  - platform: dallas
    name: ${upper_devicename} Temperature
    id: ${lower_devicename}_temperature
    address: 0x38041750ED77FF29

###### Home Assistant Livingroom Thermostat Text State
  - platform: homeassistant
    name: "HA Livingroom Thermostat text State"
    id: ha_livingroom_thermostat_sensor_text
    entity_id: climate.livingroom
    internal: true

###### Home Assistant Livingroom Thermostat Text --> Binary Sensor
  - platform: template
    name: "HA Livingroom Thermostat binary State"
    id: ha_livingroom_thermostat_sensor_binary
    internal: true
    lambda: |-
        if (id(ha_livingroom_thermostat_sensor_text).state == "off")
        return false;
        else if (id(ha_livingroom_thermostat_sensor_text).state == "heat")
        return true;
        else if (id(ha_livingroom_thermostat_sensor_text).state == "idle")
        return true;
        return {};
      - while:
            binary_sensor.is_on: ha_livingroom_thermostat_sensor_binary
          - delay: 30s
          - lambda: 'id(${lower_devicename}_temperature).update();'
  • For dallas the update does not sit in the sensor itself, but in the central hub. That’s why the update_interval is also specified there.
  • Please use component.update action instead of the raw lambda.

Works like a charm. Thanks