Skip to content

Instantly share code, notes, and snippets.

@Blackshome
Last active December 19, 2024 18:37
Show Gist options
  • Save Blackshome/42586b567d243d432887cadf54e18906 to your computer and use it in GitHub Desktop.
Save Blackshome/42586b567d243d432887cadf54e18906 to your computer and use it in GitHub Desktop.
appliance-notifications.yaml
blueprint:
name: Appliance Notifications & Actions
description: >
# 📳 Appliance Notifications & Actions
**Version: 2.7**
🤔 Watts your appliance up to, you're always in the know from start to finish!🛎️🔌💸
**If you like my blueprints, and would like to show your support or just say thank you?** [Click Here](https://www.paypal.com/donate/?hosted_button_id=WAZS3QSDTPGA8) 🙂
<details>
<summary><b>The Automation Process:</b> 👈</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.
- **Notification Options:**
- Send notification messages to one or multiple devices when the appliance starts, finishes or the watchdog is triggered.
- Your end message can also include estimates of total power consumption and cost.
- Include duration tracking in your end message to track the appliance's operational time for the task or cycle.
- Opt to sends a repeated notifications to remind you when the appliance cycle is complete.
- Notifications are compatible with both Apple iOS and Android devices, ensuring universal accessibility.
- **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.
- **Duration Tracking:**
- You can include duration tracking in your end message to monitor the appliance's operational time for each task or cycle.
- **Watchdog:**
- The watchdog option monitors an appliance cycle completion.
- It sends a notification if a cycle completion fails within the specified time frame.
- **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>
Need help?
- FAQ: [Click Here](https://community.home-assistant.io/t/650166/2)
- Community Support Including Updates: [Click Here](https://community.home-assistant.io/t/650166)
Required = *
domain: automation
input:
appliance_power_settings:
name: "Power Settings *"
icon: mdi:current-ac
collapsed: true
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.
default: []
selector:
entity:
filter:
domain: sensor
start_appliance_power:
name: Start - Appliance Power Setpoint
description: >
Specify the threshold that the power must exceed to indicate the appliance has started its cycle.
The power must transition from below to above this setpoint.
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 its cycle.
The power must remain above its setpoint for the specified time delay.
If the power falls below the setpoint again within this time frame, it will not trigger.
This will help 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.
Additionally, the option to use 'End - Repeat Count' provides a similar functionality without being subjected to any specific time frame.
You can choose to use both the 'Running - Dead Zone' and 'End - Repeat Count,' with the 'End - Repeat Count' occurring after the 'Running - Dead Zone'.
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 threshold that the power must stay below to indicate the appliance has finished its cycle.
The power must transition from above to below this 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 its cycle.
The power must remain below its setpoint for the specified time delay.
If the power exceeds the setpoint again within this time frame, it will not trigger.
default: 1
selector:
number:
min: 0.25
max: 5
step: 0.25
unit_of_measurement: minutes
end_repeat_count:
name: End - Repeat Count
description: >
The number of times the 'End - Appliance Power Setpoint + End - Power Time Delay' condition should be met before triggering the end of the cycle.
default: 1
selector:
number:
min: 1
max: 10
mode: slider
start_notify_settings:
name: "Start Notify"
icon: mdi:bell-check-outline
collapsed: true
input:
include_start_notify:
name: Use The Start Notify Options (Optional)
description: >
Select 'Enable Start Notify Options' if you would like to receive a notification when the appliance starts.
default: disable_start_notify_options
selector:
select:
options:
- label: Enable Start Notify Options
value: "enable_start_notify_options"
- label: Disable Start Notify Options
value: "disable_start_notify_options"
start_notify_device:
name: Devices Notified
description: >
Select the devices to be notified when the appliance starts.
default: []
selector:
device:
filter:
- integration: mobile_app
multiple: true
start_title:
name: Title
description: >
Enter in the notification title that you would like to receive when the appliance starts.
default: Washing Machine
selector:
text:
start_message:
name: Message
description: >
Enter in the notification message that you would like to receive when the appliance starts.
default: YES! Another load is ON :)
selector:
text:
start_notify_interruption_level:
name: Interruption Level - iOS Only
description: >
On devices running iOS 15 and later, you can configure the interruption level for your notifications to ensure they are delivered according to your preferences.
Choose the desired interruption level from the dropdown list.
Critical and time-sensitive notifications must be turned ON within the Home Assistant App, and time-sensitive notifications must be allowed in your Focus settings.
For more information on interruption levels [Click Here](https://community.home-assistant.io/t/650166/278)
default: active
selector:
select:
mode: dropdown
options:
- label: Default
value: "active"
- label: Critical Notifications
value: "critical"
- label: Time Sensitive Notifications
value: "time-sensitive"
- label: Quiet Notifications Without Waking Screen
value: "passive"
start_notify_sound:
name: Notification Sound - iOS Only
description: >
The Home Assistant app for iOS includes built-in notification sounds, and you can import sounds from your iOS device into the app.
Custom sounds can also be added via iTunes or from your cloud storage.
When entering a sound, ensure you use the full filename, including the extension.
For more information on using sounds in the Home Assistant app, [Click Here](https://community.home-assistant.io/t/650166/278)
default: []
selector:
text:
start_notify_data:
name: Android Only Options (Optional)
description: >
**High Priority** notifications ensure that you receive important alerts immediately.
These notifications bypass normal delivery delays and are delivered instantly to your device.
**Sticky Notification** ensure that important alerts are not dismissed when selected. They remain on your notification screen until you actively clear or swipe them away, ensuring that critical information stays visible until addressed.
**Notification Channel** allow you to easily organize different notification settings,
including notification sounds, vibrations, and other device-specific features.
If you choose this option, please enter your desired channel name below.
For more information on notification options [Click Here](https://community.home-assistant.io/t/650166/278)
default: []
selector:
select:
multiple: true
options:
- label: High Priority
value: "high_priority"
- label: Sticky Notification
value: "sticky"
- label: Notification Channel
value: "channel"
start_notify_channel:
name: Notification Channel - Android Only
description: >
If you have chosen to use a notification channel, simply enter the name of an existing channel to apply its pre-configured settings.
If you don't have a channel yet, you can create a new one by entering a name here.
When your automation sends the first notification, it will create the channel on your device.
After the channel is created, you can customize its notification settings to your preference directly on your device.
default: []
selector:
text:
end_notify_settings:
name: "End Notify"
icon: mdi:bell-ring-outline
collapsed: true
input:
include_end_notify:
name: Use The End Notify Options (Optional)
description: >
Select 'Enable End Notify Options' if you would like to receive a notification when the appliance finishes.
default: disable_end_notify_options
selector:
select:
options:
- label: Enable End Notify Options
value: "enable_end_notify_options"
- label: Disable End Notify Options
value: "disable_end_notify_options"
end_notify_device:
name: Devices Notified
description: >
Select the devices to be notified when the appliance has finished.
default: []
selector:
device:
filter:
- integration: mobile_app
multiple: true
end_message_title:
name: Title
description: >
Enter in the notification title that you would like to receive when the appliance has finished.
default: Washing Machine
selector:
text:
end_message:
name: Message
description: >
Enter in the notification message that you would like to receive when the appliance has finished.
default: Yippee the washing machine is finished!
selector:
text:
end_notify_interruption_level:
name: Interruption Level - iOS Only
description: >
On devices running iOS 15 and later, you can configure the interruption level for your notifications to ensure they are delivered according to your preferences.
Choose the desired interruption level from the dropdown list.
Critical and time-sensitive notifications must be turned ON within the Home Assistant App, and time-sensitive notifications must be allowed in your Focus settings.
For more information on interruption levels [Click Here](https://community.home-assistant.io/t/650166/278)
default: active
selector:
select:
mode: dropdown
options:
- label: Default
value: "active"
- label: Critical Notifications
value: "critical"
- label: Time Sensitive Notifications
value: "time-sensitive"
- label: Quiet Notifications Without Waking Screen
value: "passive"
end_notify_sound:
name: Notification Sound - iOS Only
description: >
The Home Assistant app for iOS includes built-in notification sounds, and you can import sounds from your iOS device into the app.
Custom sounds can also be added via iTunes or from your cloud storage.
When entering a sound, ensure you use the full filename, including the extension.
For more information on using sounds in the Home Assistant app, [Click Here](https://community.home-assistant.io/t/650166/278)
default: []
selector:
text:
end_notify_data:
name: Android Only Options (Optional)
description: >
**High Priority** notifications ensure that you receive important alerts immediately.
These notifications bypass normal delivery delays and are delivered instantly to your device.
**Sticky Notification** ensure that important alerts are not dismissed when selected. They remain on your notification screen until you actively clear or swipe them away, ensuring that critical information stays visible until addressed.
**Notification Channel** allow you to easily organize different notification settings,
including notification sounds, vibrations, and other device-specific features.
If you choose this option, please enter your desired channel name below.
For more information on notification options [Click Here](https://community.home-assistant.io/t/650166/278)
default: []
selector:
select:
multiple: true
options:
- label: High Priority
value: "high_priority"
- label: Sticky Notification
value: "sticky"
- label: Notification Channel
value: "channel"
end_notify_channel:
name: Notification Channel - Android Only
description: >
If you have chosen to use a notification channel, simply enter the name of an existing channel to apply its pre-configured settings.
If you don't have a channel yet, you can create a new one by entering a name here.
When your automation sends the first notification, it will create the channel on your device.
After the channel is created, you can customize its notification settings to your preference directly on your device.
default: []
selector:
text:
end_reminder_notification:
name: Reminder Notification (Optional)
description: >
Set this option to receive repeated notifications reminding you that the appliance cycle is complete.
Notifications will continue until the specified **Reminder Notification Entity** is ON or the maximum notification count is reached, ensuring you don't miss the end of the cycle while preventing excessive reminders.
default: disable_reminder_notification
selector:
select:
options:
- label: Enable Reminder Notification
value: "enable_reminder_notification"
- label: Disable Reminder Notification
value: "disable_reminder_notification"
end_reminder_notification_entity:
name: Reminder Notification Entity
description: >
Select the entity that will stop the reminder notification.
This is typically a contact sensor placed on the door of your appliance (e.g., washing machine door sensor) that, when opened, will stop the reminder notifications.
default: []
selector:
entity:
filter:
domain: binary_sensor
end_reminder_notification_message:
name: Reminder Notification Message
description: >
Enter the message you would like to receive as a reminder that the appliance has finished its cycle.
This message will be sent repeatedly until the specified **Reminder Notification Entity** is ON or the maximum notification count is reached.
default: Hey! Your fresh laundry is ready, don't leave it hanging!
selector:
text:
end_reminder_notification_time_delay:
name: Reminder Notification Time Delay
description: >
Specify the duration to wait between reminder messages.
This sets the time interval at which the reminder will be sent repeatedly until the specified **Reminder Notification Entity** is ON or the maximum notification count is reached.
default: 10
selector:
number:
min: 1
max: 60
step: 1
unit_of_measurement: minutes
end_reminder_notification_max_count:
name: Reminder Notification Maximum Count
description: >
Specify the maximum number of times the reminder notification will be sent before stopping.
This ensures you won't receive excessive notifications.
default: 2
selector:
number:
min: 1
max: 10
step: 1
power_tracking_settings:
name: "Power Tracking"
icon: mdi:meter-electric-outline
collapsed: true
input:
include_power_tracking:
name: Use The Power Tracking Option (Optional)
description: >
You have the option to enable or disable the power consumption tracking.
This feature allows you to include power information in your end notification message.
Alternatively, you can opt to solely update the start and end helpers for use in your end custom action.
Additionally, you have the choice to receive either the total kWh used in the cycle or the total kWh used, accompanied by 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 - End Notify Power Consumption Tracking
value: enable_power_tracking
- label: Enable - End Notify Power Consumption Tracking + Total Cost
value: enable_power_tracking_and_cost
- label: Enable - Update of Start & End Helpers Only
value: enable_start_end_helpers
- 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:
filter:
domain: sensor
end_message_kwh:
name: Power Tracking - End Message - Power Consumption
description: >
Enter the notification message title for power consumption.
This is the description used in the end notification message, just before the kWh reading.
default: Consumption
selector:
text:
end_message_cost:
name: Power Tracking - End Message - Cost
description: >
Enter the notification message title for the cost estimate.
This is the description used in the end notification message, just before the cost reading.
default: Approx Cost $
selector:
text:
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:
filter:
domain:
- input_number
- sensor
start_power_consumption:
name: Power Tracking - Start Number Helper
description: >
Enter a number helper that will collect the kWh reading at the start of the cycle.
This must be a completely independent number helper and cannot be the same one used in the 'Power Tracking - End Number Helper' input below.
default: []
selector:
entity:
filter:
domain: input_number
end_power_consumption:
name: Power Tracking - End Number Helper
description: >
Enter a number helper that will collect the kWh reading at the end of the cycle.
This must be a completely independent number helper and cannot be the same one used in the 'Power Tracking - Start Number Helper' input above.
default: []
selector:
entity:
filter:
domain: input_number
duration_tracking_settings:
name: "Duration Tracking"
icon: mdi:timer-sand-complete
collapsed: true
input:
include_duration_tracking:
name: Use The Duration Tracking Option (Optional)
description: >
You can include duration tracking in your end notification message to monitor the appliance's operational time for each task or cycle.
default: disable_duration_tracking
selector:
select:
options:
- label: Enable - End Notify Duration Tracking
value: "enable_duration_tracking"
- label: Disable Duration Tracking
value: "disable_duration_tracking"
end_message_duration_tracking:
name: Duration Tracking - End Message - Duration
description: >
Enter the notification message title for the duration tracking.
This is the description used in the end notification message, just before the duration time.
default: Duration
selector:
text:
watchdog_settings:
name: "Watchdog"
icon: mdi:dog-side
collapsed: true
input:
include_watchdog:
name: Use The Watchdog Option (Optional)
description: >
This feature keeps an eye on your appliance to ensure it completes its task within the set time frame.
When enabled, if the appliance fails to complete its task, the automation will time out and send a notification to alert you of a potential issue.
This helps in promptly addressing any possible problems with the appliance.
**NOTE** - If the Watchdog is triggered, the automation will be cancelled.
default: disable_watchdog
selector:
select:
options:
- label: Enable Watchdog
value: "enable_watchdog"
- label: Disable Watchdog
value: "disable_watchdog"
watchdog_timeframe:
name: Time Frame
description: >
Specify the maximum duration for the 'Watchdog' to wait for the appliance to complete its task.
If the appliance exceeds this time frame, the 'Watchdog' will trigger and notify you, indicating a potential issue.
default: 00:00:00
selector:
duration:
watchdog_title:
name: Title
description: >
Enter the notification title for the Watchdog timeout.
default: ⚠️ Appliance Watchdog
selector:
text:
watchdog_message:
name: Message
description: >
Enter the notification message for the Watchdog timeout.
default: Uh-oh! Time to check the washing machine.
selector:
text:
watchdog_notify_interruption_level:
name: Interruption Level - iOS Only
description: >
On devices running iOS 15 and later, you can configure the interruption level for your notifications to ensure they are delivered according to your preferences.
Choose the desired interruption level from the dropdown list.
Critical and time-sensitive notifications must be turned ON within the Home Assistant App, and time-sensitive notifications must be allowed in your Focus settings.
For more information on interruption levels [Click Here](https://community.home-assistant.io/t/650166/278)
default: active
selector:
select:
mode: dropdown
options:
- label: Default
value: "active"
- label: Critical Notifications
value: "critical"
- label: Time Sensitive Notifications
value: "time-sensitive"
- label: Quiet Notifications Without Waking Screen
value: "passive"
watchdog_notify_sound:
name: Notification Sound - iOS Only
description: >
The Home Assistant app for iOS includes built-in notification sounds, and you can import sounds from your iOS device into the app.
Custom sounds can also be added via iTunes or from your cloud storage.
When entering a sound, ensure you use the full filename, including the extension.
For more information on using sounds in the Home Assistant app, [Click Here](https://community.home-assistant.io/t/650166/278)
default: []
selector:
text:
watchdog_notify_data:
name: Android Only Options (Optional)
description: >
**High Priority** notifications ensure that you receive important alerts immediately.
These notifications bypass normal delivery delays and are delivered instantly to your device.
**Sticky Notification** ensure that important alerts are not dismissed when selected. They remain on your notification screen until you actively clear or swipe them away, ensuring that critical information stays visible until addressed.
**Notification Channel** allow you to easily organize different notification settings,
including notification sounds, vibrations, and other device-specific features.
If you choose this option, please enter your desired channel name below.
For more information on notification options [Click Here](https://community.home-assistant.io/t/650166/278)
default: []
selector:
select:
multiple: true
options:
- label: High Priority
value: "high_priority"
- label: Sticky Notification
value: "sticky"
- label: Notification Channel
value: "channel"
watchdog_notify_channel:
name: Notification Channel - Android Only
description: >
If you have chosen to use a notification channel, simply enter the name of an existing channel to apply its pre-configured settings.
If you don't have a channel yet, you can create a new one by entering a name here.
When your automation sends the first notification, it will create the channel on your device.
After the channel is created, you can customize its notification settings to your preference directly on your device.
default: []
selector:
text:
custom_actions_settings:
name: "Custom Actions"
icon: mdi:code-tags
collapsed: true
input:
include_custom_actions:
name: Use The Custom Action Options (Optional)
description: >
Customize your automation with any action you desire, whether it's for the start, watchdog, or end of a cycle.
It is commonly used for playing announcements on The Voice (HA), Google, Alexa, etc.
Additionally, it can be utilized for other notification services or any other actions you would like to perform.
default: []
selector:
select:
options:
- label: Enable Custom Actions - Start
value: "enable_start_custom_actions"
- label: Enable Custom Actions - Watchdog
value: "enable_watchdog_custom_actions"
- label: Enable Custom Actions - End
value: "enable_end_custom_actions"
multiple: true
start_custom_actions:
name: Custom Actions - Start
description: >
Enter the actions you would like to run at the start.
default: []
selector:
action:
watchdog_custom_actions:
name: Custom Actions - Watchdog
description: >
Enter the actions you would like to run when the watchdog is triggered.
default: []
selector:
action:
end_custom_actions:
name: Custom Actions - End
description: >
Enter the actions you would like to run at the end.
default: []
selector:
action:
time_settings:
name: "Time"
icon: mdi:clock-outline
collapsed: true
input:
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_settings:
name: "Global Conditions"
icon: mdi:earth
collapsed: true
input:
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:
power_sensor: !input power_sensor
start_appliance_power: !input start_appliance_power
start_time_delay: !input start_time_delay
end_appliance_power: !input end_appliance_power
end_time_delay: !input end_time_delay
end_repeat_count: !input end_repeat_count
include_start_notify: !input include_start_notify
start_notify_device: !input start_notify_device
start_title: !input start_title
start_message: !input start_message
start_notify_interruption_level: !input start_notify_interruption_level
start_notify_sound: !input start_notify_sound
start_notify_data: !input start_notify_data
start_notify_channel: !input start_notify_channel
running_dead_zone: !input running_dead_zone
include_end_notify: !input include_end_notify
end_notify_device: !input end_notify_device
end_message_title: !input end_message_title
end_message: !input end_message
end_notify_interruption_level: !input end_notify_interruption_level
end_notify_sound: !input end_notify_sound
end_notify_data: !input end_notify_data
end_notify_channel: !input end_notify_channel
end_reminder_notification: !input end_reminder_notification
end_reminder_notification_entity: !input end_reminder_notification_entity
end_reminder_notification_message: !input end_reminder_notification_message
end_reminder_notification_time_delay: !input end_reminder_notification_time_delay
end_reminder_notification_max_count: !input end_reminder_notification_max_count
include_power_tracking: !input include_power_tracking
power_consumption_sensor: !input power_consumption_sensor
end_message_kwh: !input end_message_kwh
end_message_cost: !input end_message_cost
cost_per_kwh: !input cost_per_kwh
start_power_consumption: !input start_power_consumption
end_power_consumption: !input end_power_consumption
include_duration_tracking: !input include_duration_tracking
end_message_duration_tracking: !input end_message_duration_tracking
start_time: "{{ now().timestamp() }}"
include_watchdog: !input include_watchdog
watchdog_timeframe: !input watchdog_timeframe
watchdog_title: !input watchdog_title
watchdog_message: !input watchdog_message
watchdog_notify_interruption_level: !input watchdog_notify_interruption_level
watchdog_notify_sound: !input watchdog_notify_sound
watchdog_notify_data: !input watchdog_notify_data
watchdog_notify_channel: !input watchdog_notify_channel
include_custom_actions: !input include_custom_actions
start_custom_actions: !input start_custom_actions
watchdog_custom_actions: !input watchdog_custom_actions
end_custom_actions: !input end_custom_actions
include_time: !input include_time
after_time: !input after_time
before_time: !input before_time
weekday_options: !input weekday_options
global_conditions: !input global_conditions
# Start notify data
start_message_data: >-
{% set message = namespace(data={}) %}
{% set push = namespace(data={}) %}
{% if start_notify_interruption_level in ['active', 'critical', 'time-sensitive', 'passive'] %}
{% set push.data = dict(push.data, **{ 'interruption-level': start_notify_interruption_level }) %}
{% endif %}
{% if start_notify_sound != [] %}
{% set push.data = dict(push.data, **{ 'sound': start_notify_sound }) %}
{% endif %}
{% if push.data %}
{% set message.data = dict(message.data, **{ 'push': push.data }) %}
{% endif %}
{% if 'high_priority' in start_notify_data %}
{% set message.data = dict(message.data, **{ 'ttl': 0, 'priority': 'high' }) %}
{% endif %}
{% if 'channel' in start_notify_data %}
{% set message.data = dict(message.data, **{ 'channel': start_notify_channel }) %}
{% endif %}
{% if 'sticky' in start_notify_data %}
{% set message.data = dict(message.data, **{ 'sticky': "true" }) %}
{% endif %}
{{ message.data }}
# End notify data
end_message_data: >-
{% set message = namespace(data={}) %}
{% set push = namespace(data={}) %}
{% if end_notify_interruption_level in ['active', 'critical', 'time-sensitive', 'passive'] %}
{% set push.data = dict(push.data, **{ 'interruption-level': end_notify_interruption_level }) %}
{% endif %}
{% if end_notify_sound != [] %}
{% set push.data = dict(push.data, **{ 'sound': end_notify_sound }) %}
{% endif %}
{% if push.data %}
{% set message.data = dict(message.data, **{ 'push': push.data }) %}
{% endif %}
{% if 'high_priority' in end_notify_data %}
{% set message.data = dict(message.data, **{ 'ttl': 0, 'priority': 'high' }) %}
{% endif %}
{% if 'channel' in end_notify_data %}
{% set message.data = dict(message.data, **{ 'channel': end_notify_channel }) %}
{% endif %}
{% if 'sticky' in end_notify_data %}
{% set message.data = dict(message.data, **{ 'sticky': "true" }) %}
{% endif %}
{{ message.data }}
# Watchdog notify data
watchdog_message_data: >-
{% set message = namespace(data={}) %}
{% set push = namespace(data={}) %}
{% if watchdog_notify_interruption_level in ['active', 'critical', 'time-sensitive', 'passive'] %}
{% set push.data = dict(push.data, **{ 'interruption-level': watchdog_notify_interruption_level }) %}
{% endif %}
{% if watchdog_notify_sound != [] %}
{% set push.data = dict(push.data, **{ 'sound': watchdog_notify_sound }) %}
{% endif %}
{% if push.data %}
{% set message.data = dict(message.data, **{ 'push': push.data }) %}
{% endif %}
{% if 'high_priority' in watchdog_notify_data %}
{% set message.data = dict(message.data, **{ 'ttl': 0, 'priority': 'high' }) %}
{% endif %}
{% if 'channel' in watchdog_notify_data %}
{% set message.data = dict(message.data, **{ 'channel': watchdog_notify_channel }) %}
{% endif %}
{% if 'sticky' in watchdog_notify_data %}
{% set message.data = dict(message.data, **{ 'sticky': "true" }) %}
{% endif %}
{{ message.data }}
# Work out the actual watchdoog duration taking into account the running dead zone time
watchdog_duration: >-
{% set dead_zone_seconds = running_dead_zone * 60 %}
{% set hours = watchdog_timeframe.hours | default(0) %}
{% set minutes = watchdog_timeframe.minutes | default(0) %}
{% set seconds = watchdog_timeframe.seconds | default(0) %}
{% set watchdog_seconds = (hours * 3600) + (minutes * 60) + seconds %}
{% set duration_total_in_seconds = watchdog_seconds - dead_zone_seconds %}
{% set duration_hours = duration_total_in_seconds // 3600 %}
{% set duration_minutes = (duration_total_in_seconds % 3600) // 60 %}
{% set duration_seconds = duration_total_in_seconds % 60 %}
{{ '%02d:%02d:%02d' | format(duration_hours, duration_minutes, duration_seconds) }}
triggers:
- trigger: 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') or (include_power_tracking == 'enable_start_end_helpers') }}"
sequence:
- action: input_number.set_value
target:
entity_id: !input start_power_consumption
data_template:
value: "{{ states(power_consumption_sensor) | float }}"
- choose:
- alias: "Check if start of notification is enabled"
conditions:
- "{{ include_start_notify == 'enable_start_notify_options' }}"
sequence:
- alias: Send a notification to each device
repeat:
for_each: !input start_notify_device
sequence:
- action: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}"
data:
title: !input start_title
message: !input start_message
data: "{{ start_message_data }}"
- choose:
- alias: "Perform the custom start action"
conditions:
- condition: template
value_template: "{{ 'enable_start_custom_actions' in include_custom_actions }}"
sequence: !input start_custom_actions
- alias: "Wait the number of minutes set in running dead zone"
delay:
minutes: !input running_dead_zone
- choose:
- conditions: "{{ include_watchdog == 'enable_watchdog' }}"
sequence:
- alias: "Wait until appliance has finished"
repeat:
count: !input end_repeat_count
sequence:
- wait_for_trigger:
- trigger: numeric_state
entity_id: !input power_sensor
below: !input end_appliance_power
for:
minutes: !input end_time_delay
timeout: "{{ watchdog_duration }}"
- choose:
- conditions: "{{ wait.trigger is none }}"
sequence:
- choose:
- alias: "Check time condition"
conditions:
- "{{ include_time == 'time_enabled' }}"
- condition: time
after: !input before_time
before: !input after_time
weekday: !input weekday_options
sequence:
- stop: "Stop the automation"
- alias: Send a notification to each device
repeat:
for_each: !input end_notify_device
sequence:
- action: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}"
data:
title: !input watchdog_title
message: "{{watchdog_message}}"
data: "{{ watchdog_message_data }}"
- choose:
- alias: "Perform the custom watchdoog action"
conditions:
- condition: template
value_template: "{{ 'enable_watchdog_custom_actions' in include_custom_actions }}"
sequence: !input watchdog_custom_actions
- stop: "Stop the automation"
- conditions: "{{ include_watchdog == 'disable_watchdog' }}"
sequence:
- alias: "Wait until appliance has finished"
repeat:
count: !input end_repeat_count
sequence:
- wait_for_trigger:
- trigger: numeric_state
entity_id: !input power_sensor
below: !input end_appliance_power
for:
minutes: !input end_time_delay
- choose:
- alias: "Check time condition"
conditions:
- "{{ include_time == 'time_enabled' }}"
- condition: time
after: !input before_time
before: !input after_time
weekday: !input weekday_options
sequence:
- stop: "Stop the automation"
- choose:
- alias: "Check if power tracking is enabled"
conditions:
- "{{ (include_power_tracking == 'enable_power_tracking') or (include_power_tracking == 'enable_power_tracking_and_cost') or (include_power_tracking == 'enable_start_end_helpers') }}"
sequence:
- action: input_number.set_value
target:
entity_id: !input end_power_consumption
data_template:
value: "{{ states(power_consumption_sensor) | float }}"
- choose:
- alias: "Perform the custom end action"
conditions:
- condition: template
value_template: "{{ 'enable_end_custom_actions' in include_custom_actions }}"
sequence: !input end_custom_actions
- choose:
- alias: "Check if end of notification is enabled"
conditions:
- "{{ include_end_notify == 'enable_end_notify_options' }}"
sequence:
- alias: Send a notification to each device
repeat:
for_each: !input end_notify_device
sequence:
- choose:
- alias: "Check if end of notification is enabled and no power tracking"
conditions:
- "{{ (include_power_tracking == 'disable_power_tracking') or (include_power_tracking == 'enable_start_end_helpers') }}"
sequence:
- action: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}"
data:
title: !input end_message_title
message: >
{{end_message}}
{% if include_duration_tracking == "enable_duration_tracking" %}
{% set end_time = now().timestamp() %}
{% set duration = (end_time - start_time) | int %}
{% set hours = (duration // 3600) | int %}
{% set minutes = ((duration % 3600) // 60) | int %}
{% set seconds = (duration % 60) | int %}
{{'\n'}}{{ end_message_duration_tracking }} {{ '%02d' | format(hours) }}:{{ '%02d' | format(minutes) }}:{{ '%02d' | format(seconds) }}
{% endif %}
data: "{{ end_message_data }}"
- alias: "Check if end of notification is enabled and no power tracking is total power"
conditions:
- "{{ include_power_tracking == 'enable_power_tracking' }}"
sequence:
- action: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}"
data:
title: !input end_message_title
message: >
{{end_message}}
{% set kwh = states(end_power_consumption) | float - states(start_power_consumption) | float %}
{{'\n'}}{{end_message_kwh}} {{kwh | round(2) }} kWh
{% if include_duration_tracking == "enable_duration_tracking" %}
{% set end_time = now().timestamp() %}
{% set duration = (end_time - start_time) | int %}
{% set hours = (duration // 3600) | int %}
{% set minutes = ((duration % 3600) // 60) | int %}
{% set seconds = (duration % 60) | int %}
{{'\n'}}{{ end_message_duration_tracking }} {{ '%02d' | format(hours) }}:{{ '%02d' | format(minutes) }}:{{ '%02d' | format(seconds) }}
{% endif %}
data: "{{ end_message_data }}"
- alias: "Check if end of notification is enabled and no power tracking is total power and cost"
conditions:
- "{{ include_power_tracking == 'enable_power_tracking_and_cost' }}"
sequence:
- action: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}"
data:
title: !input end_message_title
message: >
{{end_message}}
{% set kwh = states(end_power_consumption) | float - states(start_power_consumption) | float %}
{{'\n'}}{{end_message_kwh}} {{kwh | round(2) }} kWh
{% set cost = (states(end_power_consumption) | float - states(start_power_consumption) | float) * (states(cost_per_kwh) | float) %}
{{'\n'}}{{end_message_cost}}{{cost | round(2) }}
{% if include_duration_tracking == "enable_duration_tracking" %}
{% set end_time = now().timestamp() %}
{% set duration = (end_time - start_time) | int %}
{% set hours = (duration // 3600) | int %}
{% set minutes = ((duration % 3600) // 60) | int %}
{% set seconds = (duration % 60) | int %}
{{'\n'}}{{ end_message_duration_tracking }} {{ '%02d' | format(hours) }}:{{ '%02d' | format(minutes) }}:{{ '%02d' | format(seconds) }}
{% endif %}
data: "{{ end_message_data }}"
- choose:
- alias: "Check if end reminder notification is enabled"
conditions:
- condition: template
value_template: "{{ end_reminder_notification == 'enable_reminder_notification' }}"
sequence:
- wait_for_trigger:
- trigger: state
entity_id: !input end_reminder_notification_entity
to: 'on'
timeout:
minutes: !input end_reminder_notification_time_delay
- repeat:
while:
- condition: template
value_template: "{{ (is_state(end_reminder_notification_entity, 'off')) and (repeat.index <= end_reminder_notification_max_count) }}"
sequence:
- repeat:
for_each: !input end_notify_device
sequence:
- action: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}"
data:
title: !input end_message_title
message: !input end_reminder_notification_message
data: "{{ end_message_data }}"
- wait_for_trigger:
- trigger: state
entity_id: !input end_reminder_notification_entity
to: 'on'
timeout:
minutes: !input end_reminder_notification_time_delay
@andrea-fantini
Copy link

andrea-fantini commented Oct 2, 2024

Great blueprint. I suggest changing 'current draw' to 'power consumption' on #L19, #L20, #L21, and #L72

@toml0006
Copy link

Great blueprint. I suggest changing 'current draw' to 'power consumption' on #L19, #L20, #L21, and #L72

Agreed, on both! “current” is typically associated with amperage, which many energy metering smart plugs will measure. I was initially confused by this upon my first setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment