In the following code, the formatted logger.log always reports zero (which doesn’t surprised me). Unless, I un-Rem the delay. Then, the logger correctly reports the reality of the HA binary sensor.
However, delays are never a good strategy. Something, somewhere can change and the delay will be ineffectual.
What other methods (or whatever they are called in yaml) besides id().state are available that I could find useful? Maybe it would return NaN rather than zero if the value has not been retrieved from the HA server yet.
esphome:
name: "esp32-adc-sleep"
on_boot:
- logger.log: "Waiting for the API to connect..."
- wait_until:
condition:
api.connected:
- if:
condition:
api.connected:
then:
- logger.log: "API Connected"
else:
- logger.log: "API NOT Connected"
- logger.log: "I'm in the on_boot code..."
#- delay: 10s
- logger.log:
format: 'Prevent Sleep Flag set to: %i'
args: [id(prevent_deep_sleep).state]
# - I'd like to find a "wait_until" to avoid the (above) Rem'd delay: 10s
Regards, Martin
PS _ Dispite hunting around binary_sensor file reference I’ve not been able to find any clues…