How to manually publish state

I want to wake up wifi and then publish state, and then disable wifi. below is the code, Is the line of code “- delay: 10s” necessary? Will the wifi component automatically wait for the publish command to be executed before enter deep sleep command?

wifi:
  enable_on_boot: false
  on_connect:
    then:
      - lambda: |-
          id(xxxx).publish_state(xxxx);
      - delay: 10s
      - deep_sleep.enter: xxxx

on_xxxx:
  - wifi.enable:

You might get more responses if you publish whole yaml redacting your passwords and encryption codes. More info sparks more interest. Explain what you are trying to do. :+1:

1 Like

You may want to look at the “api connected” triggers/conditions (assuming you are using the api).