ESPHome device how to read other sensor value from HA?

I’m a bit stuck.

I have an ESP32 with a RG-9 rain sensor running ESPHome. In HA I have a Shelly Plus 2pm “cover” device that I want to control an electric opening rooflight.

The Rainsensor is going to be battery operated and I want it to use a deep sleep interval of a few minutes, then wake up and check HA to see if the Rooflight is open or not. If it is not open, I want the rain sensor to go back to sleep. If it is open then I will start checking for rain and if/when the rain comes tell HA close the rooflight. Then the rainsensor can go back to the deep-sleep cycle.

I’ve worked out most of what I need in ESPHome but what I can’t figure out from the docs is how do I “read” the status of the Shelly cover that is in HA?

I have created a homeassistant text sensor in my ESPHome device, but what I can’t work out is how to get it actually trigger a “read”… Hopefully I’m being dense and missing something obvious…

text_sensor:
  - platform: homeassistant
    name: "Utility_Rooflight"
    entity_id: cover.utility_rooflight
    on_value:
      then:
        - lambda: |-
            ESP_LOGD("main", "The current status is %s", x.c_str());
        - output.turn_on: gpio_1

If that entity state is changed, then esphome will see it.

Thanks, but how do I trigger the ESPHome device to “request” the current state, rather than waiting for it to change?

It should just read it when the API connects I think?

What do you see in the logs? What do you see for the Utility_Rooflight sensor in HA? Sometimes you could miss it in the logs during boot.

You could also try importing it as a binary sensor rather than a text sensor.

I don’t believe you can manually request an update, but it should happen on boot.