ESPhome forced DS18b20 reading

Hello

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: https://esphome.io/guides/automations.html?highlight=update#component-update-action

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

Thx

Part of my yaml for the better understanding:

substitutions:
  upper_devicename: "Livingroom"
  lower_devicename: "livingroom"

dallas:
  - pin: GPIO2
    update_interval: 180s

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

###### Home Assistant Livingroom Thermostat Text State
text_sensor:
  - 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
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;
        }
        else
        {
        return {};
        }
    on_state:
      - while:
          condition:
            binary_sensor.is_on: ha_livingroom_thermostat_sensor_binary
          then:
          - 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