Hello Friends!
I have some logging and Home Assistant actions I’m trying to run within the on_boot automation for an ESP32 S3 module. The HA actions I’m trying to run are notify actions.
The boot actions I have configured on local switches (nested in IF - THEN - ELSE blocks) are working as expected but I cannot get any log entries or notifications from within the on_boot automation.
I understand the HA actions rely on the Native API being connected so I have tried several different priorities for the on_boot automation. 600 (default), 300, 150, 10, -10, and -100.
I know my approach is valid because this block of code works just fine. It’s part of a separate template switch configuration in the same device:
on_turn_off:
- logger.log:
level: WARN
format: "Water automation has been disabled."
tag: "automation"
- homeassistant.action:
action: notify.mobile_app_...
data:
title: "Water Automation Disabled"
message: "Water automation has been disabled."
I’ve included the yaml below incase someone sees something I’m overlooking. There is a lot going on here but I know most of it is working because of the state of entities after the boot sequence has completed.
on_boot:
- priority: -100
then:
- logger.log:
level: INFO
format: "Starting Well Automation Controller boot sequence..."
tag: "boot"
- if:
any: # Check for leak conditions on boot
- binary_sensor.is_on: well_leak
- binary_sensor.is_on: distribution_leak
then:
- switch.template.publish:
id: water_automation
state: OFF
- switch.turn_off: well_pump
- switch.turn_on: pressure_disconnect
- switch.turn_on: tank_discharge_close
- homeassistant.action:
action: notify.mobile_app_...
data:
title: "Water Leak Detected!"
message: "See the notification panel for more details."
- homeassistant.action:
action: notify.persistent_notification
data:
title: "Water Leak Detected!"
message: |-
A water leak has been detected by the well automation controller during startup.
To prevent water damage, the well pump has been disabled, the pressure pump disconnected,
and the tank discharge valve closed.
Please investigate and resolve the leak condition before re-enabling water automation.
else:
- if:
condition: # Disable well automation if the tank is full on boot
binary_sensor.is_on: tank_full
then:
- switch.template.publish:
id: water_automation
state: OFF
- switch.turn_off: well_pump
- homeassistant.action:
action: notify.mobile_app_...
data:
title: "Water Tank is at Maximum Capacity"
message: "See the notification panel for more details."
- homeassistant.action:
action: notify.persistent_notification
data:
title: "Water Tank is at Maximum Capacity"
message: |-
The water storage tank was detected to be full during startup of the well automation controller.
To prevent overfilling, well pump automation has been disabled.
Investigation into why the Pump_Off trigger did not function properly is recommended.
else:
if:
condition: # If the tank level is low on boot, enable automation, set tank mode to fill, and turn off the pressure pump.
binary_sensor.is_off: low_water_shutdown
then:
- switch.template.publish:
id: water_automation
state: ON
- switch.template.publish:
id: tank_mode
state: OFF #fill mode
- switch.turn_on: pressure_disconnect
- homeassistant.action:
action: notify.mobile_app_...
data:
title: "Water Tank Volume is Low"
message: "See the notification panel for more details."
- homeassistant.action:
action: notify.persistent_notification
data:
title: "Water Tank Volume is Low"
message: |-
The water storage tank level was detected to be low during startup of the well automation controller.
The pressure pump has been disconnected to prevent damage from running dry.
Investigation into the low water condition is recommended.
else: # No issues were found. Enable water automation and set tank mode based on well pump trigger state.
- logger.log:
level: INFO
format: "Well Automation Controller started successfully with no issues found. Enabling water automation."
tag: "boot"
- switch.template.publish: #<-- This block executes fine.
id: water_automation
state: ON
- if:
condition:
binary_sensor.is_off: trigger_well_pump_on
then:
- switch.template.publish:
id: tank_mode
state: OFF #fill mode
else:
- switch.template.publish: #<-- The tank is mostly full right now so this block executes fine.
id: tank_mode
state: ON #drain mode
- homeassistant.action:
action: notify.mobile_app_...
data:
title: "Water Automation Enabled"
message: "The controller has successfully started and water automation is enabled."
- homeassistant.action:
action: notify.persistent_notification
data:
title: "Water Automation Enabled"
message: |-
The well automation controller has successfully started and water automation is enabled.
Tank mode has been set based on the current water level sensor states.
- logger.log:
level: INFO
format: "Notifications should have been sent by now."
tag: "boot"
If you made it this far, thank you for taking the time to look at this. I do appreciate any thoughts and comments.