I have the following pair of automations that I would love to combine to streamline and eliminate an automation. For the life of me, I cannot figure out how to trigger the process. The conditions to decide actions could stay the same.
The first automation boots my Unraid backup server at a set time on a set day of the week and turns on a helper switch. Once booted unraid fires up a script to trigger the backup process.
Start automation:
alias: Unraid Backup trigger Start backup
description: Turn Backup on and end
triggers:
- at: "02:00:00"
trigger: time
conditions:
- condition: time
weekday:
- mon
- fri
- sat
- wed
actions:
- choose:
- conditions:
- condition: state
entity_id: switch.backup
state: "off"
sequence:
- data: {}
target:
entity_id: switch.backup
action: switch.turn_on
- data: {}
target:
entity_id: input_boolean.switch_unraid_backup_auto
action: input_boolean.turn_on
- data:
message: Unraid backup triggered
title: Unraid backup started
action: notify.mobile_app_matt_s10
mode: single
Once this process is completed, the backup has run and the drives have spun down and the power draw has dropped below 71 watts for 4 minutes on my monitored power switch the following happens… A call to the server shuts down the system via the Unraid API, the input_boolean is turned off and a notification is sent that the process is completed.
Process complete automation:
alias: Backup Unraid Backup Complete
description: Determine backups complete and shutdown
triggers:
- entity_id:
- sensor.tg_04_energy_power_2
for:
hours: 0
minutes: 4
seconds: 0
below: 71
trigger: numeric_state
conditions:
- condition: state
entity_id: input_boolean.switch_unraid_backup_auto
state: "on"
actions:
- action: button.press
metadata: {}
target:
entity_id: button.backup_shutdown_system
data: {}
- data:
message: Backup run completed
title: Backup server shutdown
action: notify.mobile_app_matt_s10
- action: input_boolean.turn_off
metadata: {}
target:
entity_id: input_boolean.switch_unraid_backup_auto
data: {}
mode: single
So, I can still trigger on start time and day, but what I am worried about is the power draw trigger. Sometimes I have the server booted and if the drives spin down the power off criteria could be met… I could maybe use the input_boolean being off as a condition to not shut the server down, but I think the automation would still try to trigger when ever the power level is low whether it does anything or not? Am I overthinking this? Looking for suggestions.
Thanks Matt