Last active
June 19, 2024 08:54
-
-
Save c-kick/31ffbdd3520c65833577648c2b96b289 to your computer and use it in GitHub Desktop.
Appliance Status Monitor - Blueprint for Home Assistant - Forked from (v2.1.1) leofabri's appliance status monitor (https://github.com/leofabri/hassio_appliance-status-monitor) with a few added features: job_planned state, power/standby state indicator, job complete indicator. See description inside blueprint for instructions and added features.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
blueprint: | |
name: Monitor the state of an appliance - modded by hnldesign | |
source_url: https://gist.github.com/c-kick/31ffbdd3520c65833577648c2b96b289 | |
description: "`- Version: 0.0.7 -`\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* | |
**<ins>paused</ins>** - 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_planned</ins>** <sup>new</sup> - The appliance has a scheduled/programmed job, but it | |
has not yet started (enhanced idle state).\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 | |
MODIFICATIONS BY KLAAS LEUSSINK (2024) - BASED ON v2.1.1\n\n* | |
**<ins>Added Power state indicator</ins>**\n* | |
**<ins>Added Job complete indicator</ins>**\n* | |
**<ins>Added Job Planned (scheduled/programmed) state</ins>**\n* | |
**<ins>Added Job Cycle Time helper</ins>**\n\n\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 | |
# START MODIFICATIONS HNLDESIGN | |
appliance_programmed_power_threshold: | |
name: Programmed power threshold | |
description: '(OPTIONAL) <sup>New!</sup> | |
Power threshold above which we assume the appliance has been programmed | |
to run a job, but is not yet running it (job_planned state). This needs | |
to be higher than zero, and lower than the Starting power threshold. | |
Leave at (or set to) zero to disable.' | |
default: 0.0 | |
selector: | |
number: | |
min: 0.0 | |
max: 50.0 | |
unit_of_measurement: W | |
mode: slider | |
step: 0.1 | |
# END MODIFICATIONS | |
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.0 | |
selector: | |
number: | |
min: 1.0 | |
max: 100.0 | |
unit_of_measurement: W | |
mode: slider | |
step: 0.1 | |
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.0 | |
selector: | |
number: | |
min: 1.0 | |
max: 100.0 | |
unit_of_measurement: W | |
mode: slider | |
step: 0.1 | |
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 | |
# START MODIFICATIONS HNLDESIGN | |
appliance_standby_state: | |
name: Appliance Power State | |
description: '(*REQUIRED | Helper | Name: <i><strong><your_appliance_name>_standby</strong></i>) <sup>New!</sup> | |
An input_boolean that switches on when the appliance is using more than 0.1 Watt, | |
(and off when dropping below that) to indicate that it is switched on (regardless | |
if it''s performing any jobs). Especially useful if your smart socket rarely | |
switches off, and appliance power is controlled by the appliance''s own power switch. | |
<br> | |
This has to be a boolean (so: 0 or 1).<br> | |
<strong>off</strong> -> the appliance is not using any power, and is considered to be switched off<br> | |
<strong>on</strong> -> the appliance is using > 0.1 Watt power, and is considered powered on (stand-by at the very least).' | |
default: [] | |
selector: | |
entity: | |
domain: | |
- input_boolean | |
multiple: false | |
appliance_job_complete_state: | |
name: Appliance Job Cycle Complete State | |
description: '(*REQUIRED | Helper | Name: <i><strong><your_appliance_name>_job_complete</strong></i>) <sup>New!</sup> | |
An sensor (input_boolean) that switches on when the appliance has completed a cycle | |
(job_completed), and stays on for 1 minute, or until the machine leaves the idle state.' | |
default: [] | |
selector: | |
entity: | |
domain: | |
- input_boolean | |
multiple: false | |
appliance_job_cycle_time: | |
name: Appliance Job Cycle Time | |
description: '(*REQUIRED | Helper | Name: <i><strong><your_appliance_name>_cycle_time</strong></i>) <sup>New!</sup> | |
A counter (input_number) that keeps track of the time it takes for a cycle to complete. | |
Will update once the appliance enters the ''job_completed'' state.' | |
default: [] | |
selector: | |
entity: | |
domain: | |
- input_number | |
multiple: false | |
# END MODIFICATIONS | |
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 | |
# START MODIFICATIONS BY HNLDESIGN | |
appliance_programmed_power_threshold: !input appliance_programmed_power_threshold | |
appliance_starting_power_threshold: !input appliance_starting_power_threshold | |
appliance_finishing_power_threshold: !input appliance_finishing_power_threshold | |
appliance_job_complete_state: !input appliance_job_complete_state | |
appliance_job_cycle_time: !input appliance_job_cycle_time | |
# END MODIFICATIONS | |
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 | |
# START MODIFICATIONS BY HNLDESIGN | |
- platform: state | |
entity_id: !input appliance_job_complete_state | |
to: 'on' | |
for: | |
minutes: 1 | |
id: job_completed_1_min | |
- platform: state | |
entity_id: !input appliance_state_machine | |
from: 'job_ongoing' | |
to: 'job_completed' | |
id: cycle_complete | |
# END MODIFICATIONS | |
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 | |
# START MODIFICATIONS BY HNLDESIGN | |
- condition: trigger | |
id: job_completed_1_min | |
- condition: trigger | |
id: cycle_complete | |
# END MODIFICATIONS | |
action: | |
- service: input_boolean.turn_off | |
data: {} | |
target: | |
entity_id: !input automation_self_trigger | |
# START MODIFICATIONS HNLDESIGN | |
- choose: | |
- conditions: | |
- condition: trigger | |
id: cycle_complete | |
sequence: | |
- service: input_number.set_value | |
target: | |
entity_id: !input appliance_job_cycle_time | |
data: | |
value: "{{ ((trigger.to_state.last_changed|as_timestamp - trigger.from_state.last_changed|as_timestamp) | int / 60) | int }}" | |
- choose: | |
- conditions: | |
- condition: trigger | |
id: job_completed_1_min | |
sequence: | |
- service: input_boolean.turn_off | |
data: {} | |
target: | |
entity_id: !input appliance_job_complete_state | |
- choose: | |
- conditions: | |
- condition: and | |
conditions: | |
- condition: template | |
value_template: '{{ states(appliance_socket) == ''on'' }}' | |
- condition: numeric_state | |
entity_id: !input appliance_power_sensor | |
above: 0.1 | |
sequence: | |
- service: input_boolean.turn_on | |
data: {} | |
target: | |
entity_id: !input appliance_standby_state | |
default: | |
- service: input_boolean.turn_off | |
data: {} | |
target: | |
entity_id: !input appliance_standby_state | |
- service: input_boolean.turn_off | |
data: {} | |
target: | |
entity_id: !input appliance_job_complete_state | |
# END MODIFICATIONS | |
- 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.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.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 | |
# START MODIFICATIONS HNLDESIGN | |
- service: input_boolean.turn_off | |
data: {} | |
target: | |
entity_id: !input appliance_job_complete_state | |
# END MODIFICATIONS | |
- 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.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 | |
# START MODIFICATIONS HNLDESIGN | |
- service: input_boolean.turn_off | |
data: {} | |
target: | |
entity_id: !input appliance_job_complete_state | |
# END MODIFICATIONS | |
- 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: | |
# START MODIFICATIONS HNLDESIGN | |
- conditions: | |
- condition: template | |
value_template: '{{ appliance_programmed_power_threshold | float(0) > 0.0 }}' | |
- condition: template | |
value_template: '{{ states(appliance_socket) == ''on'' }}' | |
- condition: template | |
value_template: '{{ states(appliance_job_complete_state) == ''off'' }}' | |
- condition: state | |
entity_id: !input appliance_job_cycle | |
state: 'off' | |
- condition: numeric_state | |
entity_id: !input appliance_power_sensor | |
above: !input appliance_programmed_power_threshold | |
below: !input appliance_starting_power_threshold | |
sequence: | |
- service: input_select.select_option | |
data: | |
option: job_planned | |
target: | |
entity_id: !input appliance_state_machine | |
# END MODIFICATIONS | |
- 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 | |
# START MODIFICATIONS HNLDESIGN | |
- service: input_boolean.turn_off | |
data: {} | |
target: | |
entity_id: !input appliance_job_complete_state | |
# END MODIFICATIONS | |
- 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 | |
# START MODIFICATIONS HNLDESIGN | |
- service: input_boolean.turn_on | |
data: {} | |
target: | |
entity_id: !input appliance_job_complete_state | |
# END MODIFICATIONS | |
- 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment