initial commit
This commit is contained in:
671
blueprints/automation/leofabri/appliance-status-monitor.yaml
Normal file
671
blueprints/automation/leofabri/appliance-status-monitor.yaml
Normal file
@@ -0,0 +1,671 @@
|
||||
blueprint:
|
||||
name: Monitor the state of an appliance - by leofabri
|
||||
description: "`- Version: 2.1.1 -`\n\nThis automation can detect and monitor the
|
||||
state of your appliances by observing their power consumption.\nThis automation
|
||||
blueprint is universal and very versatile. You can use it with anything that consumes
|
||||
energy: a washing machine, a dishwasher, your fridge, the TV, etc. I refer to
|
||||
the appliance's operations with the generic word job. A job could be anything
|
||||
(washing, rinsing...).\n\nYou can pair this project with other automations and
|
||||
services. I designed it with flexibility in mind. For instance, if you want to
|
||||
\ send alerts when the washing machine is not resuming a job, you want to send
|
||||
TTS notifications, or if your fridge is somehow not working and de-icing you
|
||||
can see that happening. All you needed is just a little bit of creativity. You
|
||||
can use the state machine and the custom actions to extend it.\n\nThe state machine:\n*
|
||||
**<ins>unplugged</ins>** - The appliance is no longer powered. It happens when
|
||||
the user manually turns off the smart socket (from HA or the socket itself).\n*
|
||||
**<ins>idle</ins>** - There is no pending job, the machine is powered but idling.\n*
|
||||
**paused** - Indicates that a job is pending (incomplete cycle), but the appliance
|
||||
is not performing it. The inhibitors of these state are the ***detached_overload***
|
||||
and ***unplugged*** states. In this condition the power consumption is lower than
|
||||
the finishing power threshold. The appliance must be off (maybe the user turned
|
||||
it off manually, or maybe the job needs some time to recover). The blueprint is
|
||||
waiting for the appliance to resume. **Pro Tip!** You could also use this to diagnose
|
||||
and warn if a job is not resumed after x minutes.\n* **<ins>detached_overload</ins>**
|
||||
- This happens when, during a cycle, the appliance used too much power and was
|
||||
suspended. It is also technically unplugged but we don't say that.\n* **<ins>job_ongoing</ins>**
|
||||
- Triggered in two cases:\n * when a new job cycle begins: the previous one is
|
||||
completed, and the Starting Power threshold is surpassed.\n * when a job is resumed.\n\n*
|
||||
**<ins>job_completed</ins>** - Triggered when the current incomplete job cycle
|
||||
is finished. The appliance consumes less than the Finishing Power threshold (with
|
||||
the possibility of selecting for how long) \n\n<strong>First setup?</strong> <i>[Follow
|
||||
the instructions](https://github.com/leofabri/hassio_appliance-status-monitor)</i>"
|
||||
domain: automation
|
||||
input:
|
||||
appliance_socket:
|
||||
name: Appliance Smart Socket
|
||||
description: '(*REQUIRED)
|
||||
|
||||
|
||||
The socket that is used to control this appliance.'
|
||||
default: []
|
||||
selector:
|
||||
entity:
|
||||
domain: switch
|
||||
multiple: false
|
||||
appliance_power_sensor:
|
||||
name: Appliance Power Consumption
|
||||
description: '(*REQUIRED)
|
||||
|
||||
|
||||
The power entity with the current power absorption in Watts.'
|
||||
default: []
|
||||
selector:
|
||||
entity:
|
||||
domain: sensor
|
||||
multiple: false
|
||||
appliance_starting_power_threshold:
|
||||
name: Starting power threshold
|
||||
description: '(*REQUIRED)
|
||||
|
||||
|
||||
Power threshold above which we assume the appliance has started a new job
|
||||
or is resuming the current one (job_ongoing state).'
|
||||
default: 5
|
||||
selector:
|
||||
number:
|
||||
min: 1.0
|
||||
max: 100.0
|
||||
unit_of_measurement: W
|
||||
mode: slider
|
||||
step: 1.0
|
||||
appliance_finishing_power_threshold:
|
||||
name: Finishing power threshold
|
||||
description: '(*REQUIRED)
|
||||
|
||||
|
||||
Power threshold below which we assume the appliance has finished a job (job_completed
|
||||
state).'
|
||||
default: 3
|
||||
selector:
|
||||
number:
|
||||
min: 1.0
|
||||
max: 100.0
|
||||
unit_of_measurement: W
|
||||
mode: slider
|
||||
step: 1.0
|
||||
appliance_suspended_sensor:
|
||||
name: Appliance Suspended entity
|
||||
description: '(OPTIONAL)
|
||||
|
||||
|
||||
An input_number variable that turns into a value > 0 when an overload occurs.
|
||||
That would indicate that the machine was disconnected.'
|
||||
default: []
|
||||
selector:
|
||||
entity:
|
||||
domain: input_number
|
||||
multiple: false
|
||||
appliance_state_machine:
|
||||
name: Appliance State Machine
|
||||
description: '(*REQUIRED | Helper | Name: <i><strong><your_appliance_name>_state_machine</strong></i>
|
||||
| [?](https://github.com/leofabri/hassio_appliance-status-monitor/blob/main/home%20assistant/packages/your_appliance_name.yaml#L18))
|
||||
|
||||
|
||||
The State Machine entity of this appliance.'
|
||||
default: []
|
||||
selector:
|
||||
entity:
|
||||
domain: input_select
|
||||
multiple: false
|
||||
appliance_job_cycle:
|
||||
name: Appliance Job Cycle
|
||||
description: '(*REQUIRED | Helper | Name: <i><strong><your_appliance_name>_job_cycle</strong></i>
|
||||
| [?](https://github.com/leofabri/hassio_appliance-status-monitor/blob/main/home%20assistant/packages/your_appliance_name.yaml#L9))
|
||||
|
||||
|
||||
A sensor that stores whether the appliance is still in a job cycle or not.<br>
|
||||
|
||||
This has to be a boolean (so: 0 or 1).<br> <strong>off</strong> -> the appliance
|
||||
is not performing any job<br> <strong>on</strong> -> the job is incomplete.
|
||||
<br>
|
||||
|
||||
<strong>Note that this entity does not provide any information about the detailed
|
||||
status of the machine (like an overload stuation). For that, you need the
|
||||
state machine.</strong> <br>'
|
||||
default: []
|
||||
selector:
|
||||
entity:
|
||||
domain: input_boolean
|
||||
multiple: false
|
||||
delayed_job_completion_timer:
|
||||
name: Delayed Job Completion timer
|
||||
description: '(*REQUIRED | Helper | Name: <i><strong><your_appliance_name>_delayed_job_completion_timer</i></strong>
|
||||
| [?](https://github.com/leofabri/hassio_appliance-status-monitor/blob/main/home%20assistant/packages/your_appliance_name.yaml#L2))
|
||||
|
||||
|
||||
The timer that will allow to ''wait'' & ''see'' before assuming that a job
|
||||
has been completed'
|
||||
default: []
|
||||
selector:
|
||||
entity:
|
||||
domain: timer
|
||||
multiple: false
|
||||
automation_self_trigger:
|
||||
name: Automation Self-triggering entity
|
||||
description: '(*REQUIRED | Helper | Name: <i><strong><your_appliance_name>_automation_self_trigger</i></strong>
|
||||
| [?](https://github.com/leofabri/hassio_appliance-status-monitor/blob/main/home%20assistant/packages/your_appliance_name.yaml#L13))
|
||||
|
||||
|
||||
This entity is in charge of triggering the execution of the automation when
|
||||
it changes from off -> on.
|
||||
|
||||
Sometimes, if the power consumption of the appliance is perfectly steady,
|
||||
no other trigger will work, but this will.
|
||||
|
||||
This variable allows the automation to call itself when some conditions are
|
||||
met.'
|
||||
default: []
|
||||
selector:
|
||||
entity:
|
||||
domain: input_boolean
|
||||
multiple: false
|
||||
delayed_job_completion_duration:
|
||||
name: Delayed Job Completion duration
|
||||
description: '(OPTIONAL | Helper | <i><strong>Suggested: 0, Default: 0 | DISABLED</strong></i>)
|
||||
|
||||
|
||||
During a job cycle, some appliances may intermittently use less power than
|
||||
the finishing power threshold, thus entering the job_completed state (even
|
||||
when the job is not finished).
|
||||
|
||||
With this value set, the automation will wait for the indicated time in seconds,
|
||||
and see if in that timespan the power consumption rises.
|
||||
|
||||
...
|
||||
|
||||
<strong>WARNING:</strong> Setting a duration introduces a delay on the transition
|
||||
to the ''job_completed'' state. Please make sure that you really need this,
|
||||
or leave it 0 if unsure.'
|
||||
default: 0.0
|
||||
selector:
|
||||
number:
|
||||
min: 0.0
|
||||
max: 900.0
|
||||
step: 1.0
|
||||
unit_of_measurement: seconds
|
||||
mode: slider
|
||||
actions_new_job_cycle_begins:
|
||||
name: Action(s) when a new job cycle begins
|
||||
description: 'Executed when the appliance starts a new job cycle (<strong>idle
|
||||
-> job_ongoing</strong> state). Note that here the job cycle indicator is
|
||||
off, which means that no previous job has to be completed.
|
||||
|
||||
...
|
||||
|
||||
**WARNING:** Just use non-blocking actions in this space! No delays, actionable
|
||||
notifications, TTS, waits, or anything that takes time to execute. Please
|
||||
consider that the permanence in this state could last for a limited amount
|
||||
of time (seconds, potentially!). This section is meant to be used to trigger
|
||||
other things.
|
||||
|
||||
If you really need to trigger long operations, a clean solution is to dispatch
|
||||
the work by calling other services or using the State Machine entity to wake
|
||||
up other external automations.'
|
||||
default: []
|
||||
selector:
|
||||
action: {}
|
||||
actions_job_cycle_resumes:
|
||||
name: Action(s) when a job cycle resumes
|
||||
description: 'Executed when a pending job cycle is resumed (<strong>paused |
|
||||
unplugged | detached_overload -> job_ongoing</strong> state). Note that in
|
||||
this situation, the job cycle indicator is still on. That''s how I know that
|
||||
the appliance is resuming and not startig a job.
|
||||
|
||||
...
|
||||
|
||||
**WARNING:** Just use non-blocking actions in this space! No delays, actionable
|
||||
notifications, TTS, waits, or anything that takes time to execute. Please
|
||||
consider that the permanence in this state could last for a limited amount
|
||||
of time (seconds, potentially!). This section is meant to be used to trigger
|
||||
other things.
|
||||
|
||||
If you really need to trigger long operations, a clean solution is to dispatch
|
||||
the work by calling other services or using the State Machine entity to wake
|
||||
up other external automations.'
|
||||
default: []
|
||||
selector:
|
||||
action: {}
|
||||
actions_job_cycle_ends:
|
||||
name: Action(s) when a job cycle is finished
|
||||
description: 'Executed when the appliance finishes a job cycle (<strong>job_ongoing
|
||||
-> job_completed</strong> state).
|
||||
|
||||
...
|
||||
|
||||
**WARNING:** Just use non-blocking actions in this space! No delays, actionable
|
||||
notifications, TTS, waits, or anything that takes time to execute. Please
|
||||
consider that the permanence in this state could last for a limited amount
|
||||
of time (seconds, potentially!). This section is meant to be used to trigger
|
||||
other things.
|
||||
|
||||
If you really need to trigger long operations, a clean solution is to dispatch
|
||||
the work by calling other services or using the State Machine entity to wake
|
||||
up other external automations.'
|
||||
default: []
|
||||
selector:
|
||||
action: {}
|
||||
actions_unplugged_overload:
|
||||
name: Action(s) when an overload occurs
|
||||
description: 'Executed when the appliance is detected as unplugged (because
|
||||
of an overload situation).
|
||||
|
||||
...
|
||||
|
||||
**WARNING:** Just use non-blocking actions in this space! No delays, actionable
|
||||
notifications, TTS, waits, or anything that takes time to execute. Please
|
||||
consider that the permanence in this state could last for a limited amount
|
||||
of time (seconds, potentially!). This section is meant to be used to trigger
|
||||
other things.
|
||||
|
||||
If you really need to trigger long operations, a clean solution is to dispatch
|
||||
the work by calling other services or using the State Machine entity to wake
|
||||
up other external automations.'
|
||||
default: []
|
||||
selector:
|
||||
action: {}
|
||||
actions_paused_after_overload:
|
||||
name: Action(s) when the overload situation is solved, now paused
|
||||
description: 'Executed when the state changes from <strong>detached_overload
|
||||
-> paused</strong> (NOT resuming the job).
|
||||
|
||||
...
|
||||
|
||||
**WARNING:** Just use non-blocking actions in this space! No delays, actionable
|
||||
notifications, TTS, waits, or anything that takes time to execute. Please
|
||||
consider that the permanence in this state could last for a limited amount
|
||||
of time (seconds, potentially!). This section is meant to be used to trigger
|
||||
other things.
|
||||
|
||||
If you really need to trigger long operations, a clean solution is to dispatch
|
||||
the work by calling other services or using the State Machine entity to wake
|
||||
up other external automations.'
|
||||
default: []
|
||||
selector:
|
||||
action: {}
|
||||
actions_resuming_after_overload:
|
||||
name: Action(s) when the overload situation is solved, now resuming
|
||||
description: 'Executed when the state changes from <strong>detached_overload
|
||||
-> job_ongoing</strong> (resuming the previous job).
|
||||
|
||||
...
|
||||
|
||||
**WARNING:** Just use non-blocking actions in this space! No delays, actionable
|
||||
notifications, TTS, waits, or anything that takes time to execute. Please
|
||||
consider that the permanence in this state could last for a limited amount
|
||||
of time (seconds, potentially!). This section is meant to be used to trigger
|
||||
other things.
|
||||
|
||||
If you really need to trigger long operations, a clean solution is to dispatch
|
||||
the work by calling other services or using the State Machine entity to wake
|
||||
up other external automations.'
|
||||
default: []
|
||||
selector:
|
||||
action: {}
|
||||
actions_paused_after_unplugged:
|
||||
name: Action(s) when the appliance is plugged back in, now paused
|
||||
description: 'Executed when the state changes from <strong>unplugged -> paused</strong>
|
||||
(NOT resuming the job).
|
||||
|
||||
...
|
||||
|
||||
**WARNING:** Just use non-blocking actions in this space! No delays, actionable
|
||||
notifications, TTS, waits, or anything that takes time to execute. Please
|
||||
consider that the permanence in this state could last for a limited amount
|
||||
of time (seconds, potentially!). This section is meant to be used to trigger
|
||||
other things.
|
||||
|
||||
If you really need to trigger long operations, a clean solution is to dispatch
|
||||
the work by calling other services or using the State Machine entity to wake
|
||||
up other external automations.'
|
||||
default: []
|
||||
selector:
|
||||
action: {}
|
||||
source_url: https://github.com/leofabri/hassio_appliance-status-monitor/blob/main/appliance-status-monitor.yaml
|
||||
variables:
|
||||
appliance_socket: !input appliance_socket
|
||||
appliance_suspended_sensor: !input appliance_suspended_sensor
|
||||
delayed_job_completion_duration: !input delayed_job_completion_duration
|
||||
delayed_job_completion_timer: !input delayed_job_completion_timer
|
||||
trigger:
|
||||
- platform: state
|
||||
entity_id: !input appliance_power_sensor
|
||||
id: power_event
|
||||
- platform: state
|
||||
entity_id: !input appliance_socket
|
||||
id: socket_state_change_event
|
||||
- platform: state
|
||||
entity_id: !input appliance_state_machine
|
||||
from: detached_overload
|
||||
to: paused
|
||||
id: paused_after_overload_event
|
||||
- platform: state
|
||||
entity_id: !input appliance_state_machine
|
||||
from: unplugged
|
||||
to: paused
|
||||
id: paused_after_unplugged_event
|
||||
- platform: state
|
||||
entity_id: !input appliance_state_machine
|
||||
from: detached_overload
|
||||
to: job_ongoing
|
||||
id: resuming_after_paused_overload_event
|
||||
- platform: state
|
||||
entity_id: !input automation_self_trigger
|
||||
from: 'off'
|
||||
to: 'on'
|
||||
id: automation_self_triggered
|
||||
- platform: event
|
||||
event_type: timer.finished
|
||||
event_data:
|
||||
entity_id: !input delayed_job_completion_timer
|
||||
id: job_completed_timer_finished
|
||||
- platform: homeassistant
|
||||
event: start
|
||||
id: home_assistant_started_event
|
||||
- platform: event
|
||||
event_type:
|
||||
- automation_reloaded
|
||||
id: automation_reloaded_event
|
||||
condition:
|
||||
- condition: or
|
||||
conditions:
|
||||
- condition: trigger
|
||||
id: power_event
|
||||
- condition: trigger
|
||||
id: socket_state_change_event
|
||||
- condition: trigger
|
||||
id: paused_after_overload_event
|
||||
- condition: trigger
|
||||
id: paused_after_unplugged_event
|
||||
- condition: trigger
|
||||
id: resuming_after_paused_overload_event
|
||||
- condition: trigger
|
||||
id: automation_self_triggered
|
||||
- condition: trigger
|
||||
id: job_completed_timer_finished
|
||||
- condition: trigger
|
||||
id: home_assistant_started_event
|
||||
- condition: trigger
|
||||
id: automation_reloaded_event
|
||||
action:
|
||||
- service: input_boolean.turn_off
|
||||
data: {}
|
||||
target:
|
||||
entity_id: !input automation_self_trigger
|
||||
- choose:
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: '{{ appliance_suspended_sensor|length > 0 }}'
|
||||
- condition: and
|
||||
conditions:
|
||||
- condition: template
|
||||
value_template: '{{ states(appliance_suspended_sensor) | float > 0.0 }}'
|
||||
- condition: state
|
||||
entity_id: !input appliance_job_cycle
|
||||
state: 'on'
|
||||
sequence:
|
||||
- condition: not
|
||||
conditions:
|
||||
- condition: state
|
||||
entity_id: !input appliance_state_machine
|
||||
state: detached_overload
|
||||
- service: input_select.select_option
|
||||
data:
|
||||
option: detached_overload
|
||||
target:
|
||||
entity_id: !input appliance_state_machine
|
||||
- choose: []
|
||||
default: !input actions_unplugged_overload
|
||||
- choose:
|
||||
- conditions:
|
||||
- condition: state
|
||||
entity_id: !input appliance_job_cycle
|
||||
state: 'on'
|
||||
- condition: template
|
||||
value_template: '{% if appliance_suspended_sensor|length > 0 %}{{ states(appliance_suspended_sensor)
|
||||
| float <= 0.0 }}{% else %}true{% endif %}'
|
||||
- condition: template
|
||||
value_template: '{{ states(appliance_socket) == ''on'' }}'
|
||||
- condition: numeric_state
|
||||
entity_id: !input appliance_power_sensor
|
||||
below: !input appliance_finishing_power_threshold
|
||||
- condition: or
|
||||
conditions:
|
||||
- condition: state
|
||||
entity_id: !input appliance_state_machine
|
||||
state: detached_overload
|
||||
- condition: state
|
||||
entity_id: !input appliance_state_machine
|
||||
state: unplugged
|
||||
- condition: not
|
||||
conditions:
|
||||
- condition: state
|
||||
entity_id: !input appliance_state_machine
|
||||
state: paused
|
||||
sequence:
|
||||
- service: input_select.select_option
|
||||
data:
|
||||
option: paused
|
||||
target:
|
||||
entity_id: !input appliance_state_machine
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: '{{ states(appliance_socket) == ''off'' }}'
|
||||
- condition: not
|
||||
conditions:
|
||||
- condition: template
|
||||
value_template: '{{ appliance_suspended_sensor|length > 0 }}'
|
||||
- condition: and
|
||||
conditions:
|
||||
- condition: template
|
||||
value_template: '{% if appliance_suspended_sensor|length > 0 %}{{ states(appliance_suspended_sensor)
|
||||
| float > 0.0 }}{% else %}false{% endif %}'
|
||||
- condition: state
|
||||
entity_id: !input appliance_state_machine
|
||||
state: detached_overload
|
||||
sequence:
|
||||
- condition: not
|
||||
conditions:
|
||||
- condition: state
|
||||
entity_id: !input appliance_state_machine
|
||||
state: unplugged
|
||||
- service: input_select.select_option
|
||||
data:
|
||||
option: unplugged
|
||||
target:
|
||||
entity_id: !input appliance_state_machine
|
||||
- choose:
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: '{{ states(delayed_job_completion_timer) == ''active'' }}'
|
||||
sequence:
|
||||
- service: timer.cancel
|
||||
data: {}
|
||||
target:
|
||||
entity_id: !input delayed_job_completion_timer
|
||||
- conditions:
|
||||
- condition: trigger
|
||||
id: paused_after_overload_event
|
||||
sequence:
|
||||
- choose: []
|
||||
default: !input actions_paused_after_overload
|
||||
- conditions:
|
||||
- condition: trigger
|
||||
id: paused_after_unplugged_event
|
||||
sequence:
|
||||
- choose: []
|
||||
default: !input actions_paused_after_unplugged
|
||||
- conditions:
|
||||
- condition: trigger
|
||||
id: resuming_after_paused_overload_event
|
||||
sequence:
|
||||
- choose: []
|
||||
default: !input actions_resuming_after_overload
|
||||
default:
|
||||
- choose:
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: '{{ states(appliance_socket) == ''on'' }}'
|
||||
- condition: numeric_state
|
||||
entity_id: !input appliance_power_sensor
|
||||
above: !input appliance_starting_power_threshold
|
||||
sequence:
|
||||
- choose:
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: '{{ states(delayed_job_completion_timer) == ''active''
|
||||
}}'
|
||||
sequence:
|
||||
- service: timer.cancel
|
||||
data: {}
|
||||
target:
|
||||
entity_id: !input delayed_job_completion_timer
|
||||
- condition: not
|
||||
conditions:
|
||||
- condition: state
|
||||
entity_id: !input appliance_state_machine
|
||||
state: job_ongoing
|
||||
- service: input_select.select_option
|
||||
data:
|
||||
option: job_ongoing
|
||||
target:
|
||||
entity_id: !input appliance_state_machine
|
||||
- choose:
|
||||
- conditions:
|
||||
- condition: state
|
||||
entity_id: !input appliance_job_cycle
|
||||
state: 'off'
|
||||
sequence:
|
||||
- service: input_boolean.turn_on
|
||||
data: {}
|
||||
target:
|
||||
entity_id: !input appliance_job_cycle
|
||||
- choose: []
|
||||
default: !input actions_new_job_cycle_begins
|
||||
default:
|
||||
- choose: []
|
||||
default: !input actions_job_cycle_resumes
|
||||
- conditions:
|
||||
- condition: state
|
||||
entity_id: !input appliance_state_machine
|
||||
state: job_ongoing
|
||||
- condition: state
|
||||
entity_id: !input appliance_job_cycle
|
||||
state: 'on'
|
||||
- condition: template
|
||||
value_template: '{{ states(appliance_socket) == ''on'' }}'
|
||||
- condition: numeric_state
|
||||
entity_id: !input appliance_power_sensor
|
||||
below: !input appliance_finishing_power_threshold
|
||||
sequence:
|
||||
- choose:
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: '{{ states(delayed_job_completion_timer) != ''active''
|
||||
}}'
|
||||
- condition: not
|
||||
conditions:
|
||||
- condition: trigger
|
||||
id: job_completed_timer_finished
|
||||
sequence:
|
||||
- service: timer.start
|
||||
data: {}
|
||||
target:
|
||||
entity_id: !input delayed_job_completion_timer
|
||||
- choose:
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: '{{ delayed_job_completion_duration > 0 }}'
|
||||
sequence:
|
||||
- choose:
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: "{% if states(delayed_job_completion_timer) == 'active'
|
||||
%}\n {% set t_expiring_date = state_attr(delayed_job_completion_timer,
|
||||
'finishes_at') %}\n {% set t_remaining_sec = 0 if t_expiring_date
|
||||
== None else (as_datetime(t_expiring_date) - now()).total_seconds()
|
||||
| int %}\n {% set t_total_duration = state_attr(delayed_job_completion_timer,
|
||||
'duration') %}\n {% set duration_split = t_total_duration.split(':')
|
||||
%}\n {% set t_total_duration_sec = (duration_split[0] | int *
|
||||
3600) + (duration_split[1] | int * 60) + (duration_split[0] | int)
|
||||
%}\n {% set t_elapsed_sec = (t_total_duration_sec - t_remaining_sec)
|
||||
| int %}\n {{ t_elapsed_sec < (delayed_job_completion_duration)
|
||||
| int }}\n{% else %}\n {{0}}\n{% endif %}"
|
||||
sequence:
|
||||
- delay:
|
||||
seconds: "{% if states(delayed_job_completion_timer) == 'active'
|
||||
%}\n {% set t_expiring_date = state_attr(delayed_job_completion_timer,
|
||||
'finishes_at') %}\n {% set t_remaining_sec = 0 if t_expiring_date
|
||||
== None else (as_datetime(t_expiring_date) - now()).total_seconds()
|
||||
| int %}\n {% set t_total_duration = state_attr(delayed_job_completion_timer,
|
||||
'duration') %}\n {% set duration_split = t_total_duration.split(':')
|
||||
%}\n {% set t_total_duration_sec = (duration_split[0] | int
|
||||
* 3600) + (duration_split[1] | int * 60) + (duration_split[0]
|
||||
| int) %}\n {% set t_elapsed_sec = (t_total_duration_sec - t_remaining_sec)
|
||||
| int %}\n {% set t_remaining = ((delayed_job_completion_duration)
|
||||
| int) - t_elapsed_sec %}\n \n {{ 1 + t_remaining }}\n{% else
|
||||
%}\n {{ 1 + (delayed_job_completion_duration) | int }}\n{% endif
|
||||
%}"
|
||||
- service: input_boolean.turn_on
|
||||
data: {}
|
||||
target:
|
||||
entity_id: !input automation_self_trigger
|
||||
- condition: template
|
||||
value_template: '{{0}}'
|
||||
default: []
|
||||
- service: input_boolean.turn_off
|
||||
data: {}
|
||||
target:
|
||||
entity_id: !input appliance_job_cycle
|
||||
- service: input_select.select_option
|
||||
data:
|
||||
option: job_completed
|
||||
target:
|
||||
entity_id: !input appliance_state_machine
|
||||
- choose:
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: '{{ states(delayed_job_completion_timer) == ''active''
|
||||
}}'
|
||||
sequence:
|
||||
- service: timer.cancel
|
||||
data: {}
|
||||
target:
|
||||
entity_id: !input delayed_job_completion_timer
|
||||
- choose: []
|
||||
default: !input actions_job_cycle_ends
|
||||
- choose:
|
||||
- conditions:
|
||||
- condition: or
|
||||
conditions:
|
||||
- condition: trigger
|
||||
id: automation_self_triggered
|
||||
- condition: template
|
||||
value_template: '{{ delayed_job_completion_duration <= 0 }}'
|
||||
sequence:
|
||||
- delay:
|
||||
minutes: 1
|
||||
- service: input_boolean.turn_on
|
||||
data: {}
|
||||
target:
|
||||
entity_id: !input automation_self_trigger
|
||||
default:
|
||||
- choose:
|
||||
- conditions:
|
||||
- condition: state
|
||||
entity_id: !input appliance_job_cycle
|
||||
state: 'off'
|
||||
- condition: not
|
||||
conditions:
|
||||
- condition: state
|
||||
entity_id: !input appliance_state_machine
|
||||
state: idle
|
||||
sequence:
|
||||
- service: input_select.select_option
|
||||
data:
|
||||
option: idle
|
||||
target:
|
||||
entity_id: !input appliance_state_machine
|
||||
mode: restart
|
||||
max_exceeded: silent
|
||||
trace:
|
||||
stored_traces: 10
|
||||
Reference in New Issue
Block a user