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,14 +229,16 @@ 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:
- condition: template - alias: "Debug log whether the enabled_helper was set"
value_template: "{{ not enabled_helper == None }}" if:
- condition: template
value_template: "{{ not enabled_helper == None }}"
then: then:
- service: logbook.log - service: logbook.log
data: data:
@ -248,45 +250,26 @@ action:
name: "Enabled helper" name: "Enabled helper"
message: "Enabled helper is not set." message: "Enabled helper is not set."
- alias: "Debug log the enabled_helper name"
# Action #1 service: logbook.log
- alias: "Debug log the enabled_helper name"
if:
- 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 }}"
- alias: "Debug log the current delay_seconds value"
# Action #2 service: logbook.log
- alias: "Debug log the current delay_seconds value"
if:
- 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 }}"
- alias: "Debug log the on_just_before_off_seconds value"
# Action #3 service: logbook.log
- alias: "Debug log the on_just_before_off_seconds value" data:
if: name: "Debug: On just before off seconds"
- condition: template message: "On just before off is: {{ on_just_before_off_seconds }} "
value_template: "{{ debug_mode == true }}"
then:
service: logbook.log
data:
name: "Debug: 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