Refactor initial debug logging to one action

This commit is contained in:
mike 2023-12-27 21:09:03 -08:00
parent 467fcd30e3
commit 914b9f7449

View File

@ -229,12 +229,14 @@ trigger:
action: action:
# Action #0 # Action #0
- alias: "Debug log whether the enabled_helper was set" - alias: "Initial debug logging"
if: if:
- condition: template - condition: template
value_template: "{{ debug_mode == true }}" value_template: "{{ debug_mode == true }}"
then: then:
- if:
- alias: "Debug log whether the enabled_helper was set"
if:
- condition: template - condition: template
value_template: "{{ not enabled_helper == None }}" value_template: "{{ not enabled_helper == None }}"
then: then:
@ -248,45 +250,26 @@ action:
name: "Enabled helper" name: "Enabled helper"
message: "Enabled helper is not set." message: "Enabled helper is not set."
# Action #1
- alias: "Debug log the enabled_helper name" - alias: "Debug log the enabled_helper name"
if: service: logbook.log
- condition: template
value_template: "{{ debug_mode == true }}"
then:
- service: logbook.log
data: data:
name: "Enabled helper" name: "Enabled helper"
message: "Enabled helper name is: {{ enabled_helper }}" message: "Enabled helper name is: {{ enabled_helper }}"
# Action #2
- alias: "Debug log the current delay_seconds value" - alias: "Debug log the current delay_seconds value"
if: service: logbook.log
- condition: template
value_template: "{{ debug_mode == true }}"
then:
- service: logbook.log
data: data:
name: "Delay seconds" name: "Delay seconds"
message: "Delay seconds is: {{ states[delay_seconds_helper].state }}" message: "Delay seconds is: {{ states[delay_seconds_helper].state }}"
# Action #3
- alias: "Debug log the on_just_before_off_seconds value" - alias: "Debug log the on_just_before_off_seconds value"
if:
- condition: template
value_template: "{{ debug_mode == true }}"
then:
service: logbook.log service: logbook.log
data: data:
name: "Debug: On just before off seconds" name: "Debug: On just before off seconds"
message: "On just before off is: {{ on_just_before_off_seconds }} " message: "On just before off is: {{ on_just_before_off_seconds }} "
# Take actions based on whether the "Enabled helper" was just toggled on or off # Take actions based on whether the "Enabled helper" was just toggled on or off
# Action #4 # Action #1
- if: - if:
- condition: trigger - condition: trigger
id: id:
@ -389,6 +372,7 @@ action:
# Take actions based on whether Motion is detected # Take actions based on whether Motion is detected
# Action #2
- alias: "Refuse to do anything if the enabled-helper says we're OFF." - alias: "Refuse to do anything if the enabled-helper says we're OFF."
if: if:
- condition: template - condition: template