How to publish sensor states at boot?

You should be able to put something int he “on boot” of ESPHome config:

Something like below - but to get status, you would probably need to make a template… and you would have to do it for each sensor… :

esphome:
  # ...
  on_boot:
    priority: -10
    # ...
    then:
      - mqtt.publish:
          topic: !lambda |-
            if (id(reed_switch).state) return "topic1";
            else return "topic2";
          payload: !lambda |-
            return id(reed_switch).state ? "YES" : "NO";

Not very pretty… but I think that would work.
I’ll look and see if I can find anything cleaner…

DeadEnd