Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chaptergy/3313000dbc3af114e53b184a09dac9e5 to your computer and use it in GitHub Desktop.
Save chaptergy/3313000dbc3af114e53b184a09dac9e5 to your computer and use it in GitHub Desktop.
appliance-notifications.yaml
blueprint:
name: Appliance Actions
description: >
# Appliance Actions
**Version: 1.0**
🤔 Watts your appliance up to, you're always in the know from start to finish!🛎️🔌💸
<details>
<summary><b>The Automation Process:</b> - Click here to expand</summary>
- **Appliance Trigger:**
- Enter the power sensor entity that measures the live current draw of the appliance. Common devices with these sensors include smart plugs, energy meters, etc.
- The automation is triggered when the appliance's current draw exceeds a set wattage.
- The automation ends when the appliance's current draw falls below a set value.
- **Power Tracking:**
- Utilize power tracking for estimating total power consumption and cost.
⚠️ **Disclaimer** - These values are estimates and should only be used as a guide. Please avoid relying solely on these estimates for accuracy and use them at your own risk. We cannot be held responsible for any inaccuracies or resulting losses, damages, inconvenience, or anything else that may occur.
- **Custom Actions:**
- Tailor custom actions to suit your preferences and needs, enhancing the automation's functionality.
- Configure actions such as triggering announcements on platforms like The Voice (HA), Google, Alexa, etc., to keep you informed about appliance events.
- **Time-Based Automation:**
- Specify precise start and end times along with weekday selections to define when the automation can run.
- **Custom Conditions:**
- Enter any custom conditions to further customize the automation process.
</details>
Required = *
domain: automation
source_url: https://gist.github.com/chaptergy/3313000dbc3af114e53b184a09dac9e5
input:
power_sensor:
name: Power Sensor *
description: Please enter the power sensor entity that measures the live current draw of the appliance.
Common devices that have these sensors include smart plugs.
This sensor is essential for triggering the automation when the appliance starts and when it finishes.
selector:
entity:
domain: sensor
start_appliance_power:
name: Start - Appliance Power Setpoint
description: Specify the current threshold that the power must exceed to indicate the appliance has started.
default: 10
selector:
number:
min: 1
max: 30
step: 1
unit_of_measurement: watts
start_time_delay:
name: Start - Power Time Delay
description: Specify the duration for which the power must remain above the threshold to indicate the appliance has started.
This will prevent a false trigger.
default: 1
selector:
number:
min: 0.25
max: 5
step: 0.25
unit_of_measurement: minutes
running_dead_zone:
name: Running - Dead Zone
description: After the appliance starts, implementing a dead zone can prevent false end triggers,
especially if the power briefly dips below the appliance's end setpoint during the cycle after startup.
Setting the running dead zone beyond this point ensures a reliable conclusion by preventing a premature end trigger.
default: 0
selector:
number:
min: 0
max: 120
step: 1
unit_of_measurement: minutes
end_appliance_power:
name: End - Appliance Power Setpoint
description: Specify the current threshold that the power must stay below to indicate the appliance has finished.
It is recommended to set a lower value than the starting power setpoint.
default: 5
selector:
number:
min: 1
max: 30
step: 1
unit_of_measurement: watts
end_time_delay:
name: End - Power Time Delay
description: Specify the duration for which the power must remain below the threshold to indicate the appliance has finished.
default: 1
selector:
number:
min: 0.25
max: 5
step: 0.25
unit_of_measurement: minutes
include_power_tracking:
name: Use The Power Tracking Option (optional)
description: Choose whether to enable or disable power consumption tracking.
This feature can include power information in your end action, or you can choose to only update the start helper for use in your custom actions.
The options are to receive either the total kWh used in the cycle or the total kWh used along with an estimated cost for the cycle
⚠️ **Disclaimer** - These values are estimates and should only be used as a guide.
Please avoid relying solely on these estimates for accuracy and use them at your own risk.
We cannot be held responsible for any inaccuracies or resulting losses, damages, inconvenience, or anything else that may occur.
default: disable_power_tracking
selector:
select:
options:
- label: Enable - Power Consumption Tracking
value: enable_power_tracking
- label: Enable - Power Consumption Tracking + Total Cost
value: enable_power_tracking_and_cost
- label: Disable - Power Consumption Tracking
value: disable_power_tracking
power_consumption_sensor:
name: Power Tracking - Power Sensor
description: Select the sensor that provides a total measurement of power consumption in kWh.
This can either be a cumulative total or a daily total.
**Note** If you choose a daily total sensor that spans across two days, the information may not be accurate.
This is because the values should increase continuously from the start to the end of the cycle, without resetting back to 0.0 kWh the next day.
default: []
selector:
entity:
domain: sensor
cost_per_kwh:
name: Power Tracking - Cost per kWh
description: Please enter your number helper or a energy sensor to specify the electricity rate per kWh.
Keep in mind that the rate used is determined when the appliance ends and remains constant throughout the cycle, even if it varies based on the time of day.
default: []
selector:
entity:
domain:
- input_number
- sensor
include_actions:
name: Use The Action Options (Optional)
description: You can add any action you'd like to perform at the start and/or end, commonly used for notifications or playing announcements on The Voice (HA),
Google, Alexa, etc., when the appliance starts and/or finishes. Additionally, it can be utilized for other notification services or any action you would like to perform.
default: []
selector:
select:
options:
- label: Enable Start Actions
value: "enable_start_actions"
- label: Enable End Actions
value: "enable_end_actions"
multiple: true
start_actions:
name: Actions - Start
description: Enter the actions you would like to run at the start.
default:
- service: notify.notify
data:
message: The washing machine was just started.
title: Started Washing Machine
selector:
action:
end_actions:
name: Actions - End
description: Enter the actions you would like to run at the end.
You can use some variables in your actions.
"{{power_consumption_kwh}}" to get the kWh consumed during this cycle
"{{power_cost}}" to get the kWh consumed during this cycle
default:
- service: notify.notify
data:
message: >
The washing machine is finished. 🧺{{'\n'}}Consumption:
{{power_consumption_kwh}} kWh{{'\n'}}Approx. Cost: {{ power_cost }} €
title: Washing Machine Done
selector:
action:
include_time:
name: Use The Time Options (Optional)
description: This option restricts the automation to run only between the specified start and end times on selected weekdays.
This can be useful if you ever run an appliance at night when you are sleeping and don't want to be notified.
default: time_disabled
selector:
select:
options:
- label: Enable the time options
value: "time_enabled"
- label: Disable the time options
value: "time_disabled"
after_time:
name: Start Time
description: Set the start time.
default: 00:00:00
selector:
time:
before_time:
name: End Time
description: Set the end time.
default: 00:00:00
selector:
time:
weekday_options:
name: Weekdays
description: Select the days of the week you would like the automation to run. You must select "Enable the time options" above for the weekday selections to work.
default:
- mon
- tue
- wed
- thu
- fri
- sat
- sun
selector:
select:
multiple: true
mode: list
options:
- label: Monday
value: "mon"
- label: Tuesday
value: "tue"
- label: Wednesday
value: "wed"
- label: Thursday
value: "thu"
- label: Friday
value: "fri"
- label: Saturday
value: "sat"
- label: Sunday
value: "sun"
global_conditions:
name: Global Conditions
description: Enter any global conditions you would like to apply to the automation.
default: []
selector:
condition:
mode: single
max_exceeded: silent
variables:
# Variables for internal use
power_consumption_kwh: 0
power_cost: 0
start_power_consumption: 0
# Inputs as variable
cost_per_kwh: !input cost_per_kwh
include_actions: !input include_actions
include_power_tracking: !input include_power_tracking
include_time: !input include_time
power_consumption_sensor: !input power_consumption_sensor
trigger:
- platform: numeric_state
id: "t0"
entity_id: !input power_sensor
above: !input start_appliance_power
below: "24000"
for:
minutes: !input start_time_delay
# All Conditions
condition:
# Check The Time Options
- condition: or
conditions:
- "{{ include_time == 'time_disabled' }}"
- condition: and
conditions:
- condition: time
after: !input after_time
before: !input before_time
weekday: !input weekday_options
- "{{ include_time == 'time_enabled' }}"
# Global Conditions
- condition: and
conditions: !input global_conditions
action:
- choose:
- alias: "Check if power tracking is enabled"
conditions:
- "{{ (include_power_tracking == 'enable_power_tracking') or (include_power_tracking == 'enable_power_tracking_and_cost') }}"
sequence:
- alias: "Store power consumption at the start"
variables:
start_power_consumption: "{{ states(power_consumption_sensor) }}"
- choose:
- alias: "Perform the start actions"
conditions:
- condition: template
value_template: "{{ 'enable_start_actions' in include_actions }}"
sequence: !input start_actions
- alias: "Wait the number of minutes set in running dead zone"
delay:
minutes: !input running_dead_zone
- alias: "Wait until appliance has finished"
wait_for_trigger:
platform: numeric_state
entity_id: !input power_sensor
below: !input end_appliance_power
for:
minutes: !input end_time_delay
- choose:
- alias: "Check if power tracking is enabled"
conditions:
- "{{ include_power_tracking == 'enable_power_tracking' }}"
sequence:
- alias: "Set power consumption variable"
variables:
power_consumption_kwh: "{{ ((states(power_consumption_sensor) | float(default=0)) - (start_power_consumption | float(default=0))) | round(2) }}"
- alias: "Check if power and cost tracking is enabled"
conditions:
- "{{ (include_power_tracking == 'enable_power_tracking_and_cost') }}"
sequence:
- alias: "Set power consumption and cost variable"
variables:
power_consumption_kwh: "{{ ((states(power_consumption_sensor) | float(default=0)) - (start_power_consumption | float(default=0))) | round(2) }}"
power_cost: "{{ (power_consumption_kwh * (states(cost_per_kwh) | float(default=0))) | round(2) }}"
- choose:
- alias: "Perform the end actions"
conditions:
- condition: template
value_template: "{{ 'enable_end_actions' in include_actions }}"
sequence: !input end_actions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment