Last active
January 20, 2025 18:58
-
-
Save QNimbus/7db1fad83b34d2be52ceebcbb3ec74a5 to your computer and use it in GitHub Desktop.
Home Assistant #ha
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
alias: Test | |
description: Test | |
triggers: | |
- id: key_single_click | |
trigger: event | |
event_type: zwave_js_value_notification | |
event_data: | |
domain: zwave_js | |
node_id: 172 | |
command_class: 43 | |
command_class_name: Scene Activation | |
property: sceneId | |
value: 26 | |
enabled: true | |
- id: key_double_click | |
trigger: event | |
event_type: zwave_js_value_notification | |
event_data: | |
domain: zwave_js | |
node_id: 172 | |
command_class: 43 | |
command_class_name: Scene Activation | |
property: sceneId | |
value: 24 | |
enabled: true | |
- id: key_hold | |
trigger: event | |
event_type: zwave_js_value_notification | |
event_data: | |
domain: zwave_js | |
node_id: 172 | |
command_class: 43 | |
command_class_name: Scene Activation | |
property: sceneId | |
value: 22 | |
enabled: true | |
- id: key_release | |
trigger: event | |
event_type: zwave_js_value_notification | |
event_data: | |
domain: zwave_js | |
node_id: 172 | |
command_class: 43 | |
command_class_name: Scene Activation | |
property: sceneId | |
value: 23 | |
enabled: true | |
conditions: [] | |
actions: | |
- choose: | |
- conditions: | |
- condition: trigger | |
id: | |
- key_hold | |
sequence: | |
- action: input_boolean.toggle | |
metadata: {} | |
data: {} | |
target: | |
entity_id: input_boolean.brightness_toggle | |
- repeat: | |
sequence: | |
- action: light.turn_on | |
target: | |
entity_id: light.hue_kitchen_dimmer_rail_spotlights | |
data: | |
brightness: "{{ ([1, current_brightness + (repeat.index * dimming_step) | int, 255]|sort)[1] }}" | |
- delay: | |
milliseconds: 500 | |
until: | |
- condition: template | |
value_template: | | |
{{ repeat.index >= 10 }} | |
- conditions: | |
- condition: trigger | |
id: | |
- key_single_click | |
sequence: | |
- action: light.toggle | |
target: | |
entity_id: light.hue_kitchen_dimmer_rail_spotlights | |
data: {} | |
- if: | |
- condition: template | |
value_template: "{{ lights_are_off }}" | |
then: | |
- action: input_boolean.turn_off | |
metadata: {} | |
data: {} | |
target: | |
entity_id: input_boolean.brightness_toggle | |
else: | |
- action: input_boolean.turn_on | |
metadata: {} | |
data: {} | |
target: | |
entity_id: input_boolean.brightness_toggle | |
- conditions: | |
- condition: trigger | |
id: | |
- key_double_click | |
sequence: | |
- action: light.turn_on | |
target: | |
entity_id: light.hue_kitchen_dimmer_rail_spotlights | |
data: | |
brightness_pct: 100 | |
- action: input_boolean.turn_on | |
metadata: {} | |
data: {} | |
target: | |
entity_id: input_boolean.brightness_toggle | |
mode: restart | |
max_exceeded: silent | |
trace: | |
stored_traces: 50 | |
variables: | |
lights_are_off: "{{ is_state('light.hue_kitchen_dimmer_rail_spotlights', 'off') }}" | |
current_brightness: >- | |
{{ state_attr('light.hue_kitchen_dimmer_rail_spotlights', 'brightness') | | |
int(0) }} | |
dim_up: "{{ lights_are_off or not is_state('input_boolean.brightness_toggle', 'on') }}" | |
dimming_step: "{{ 25 if lights_are_off or dim_up else -25 }}" | |
max_dim_up: "{{ (255 - current_brightness) // (dimming_step | abs) }}" | |
max_dim_down: "{{ current_brightness // (dimming_step | abs) }}" | |
max_dim_steps: "{{ max_dim_up if dim_up else max_dim_down }}" |
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: "Battery Level Checker Script" | |
description: | | |
# 🪫 Battery Level Checker Script | |
**Version: 1.1** | |
Last updated: **2024-09-19** | |
This blueprint creates a script to check the battery levels of selected devices and notify users when the battery level falls below a specified threshold. | |
**Features:** | |
- **Customizable Battery Sensors**: Select multiple battery sensors to monitor. | |
- **Low Battery Threshold**: Specify the battery percentage considered 'low' (default is 20%). | |
- **Notifications**: Sends a notification to users when a device's battery level is below the threshold. | |
- **Automation Ready**: This script can be run manually or integrated into an automation to check battery levels at regular intervals. | |
**Usage:** | |
- **Selecting Devices**: Choose the battery sensors you want to monitor. These are typically sensors with a device class of 'battery'. | |
- **Setting Threshold**: Define the battery percentage that will trigger a low battery warning. | |
- **Automations**: Create an automation to run this script at regular intervals (e.g., daily at a specific time) to check battery levels automatically. | |
**Automation Example:** | |
```yaml | |
alias: Daily Battery Check | |
trigger: | |
- platform: time | |
at: '08:00:00' | |
action: | |
- service: script.battery_level_checker_script | |
``` | |
**For Users:** | |
This script helps you keep track of the battery levels of various devices in your smart home. It automatically checks the battery levels and notifies you when any device's battery is running low, so you can replace or recharge it in time. | |
**Changelog:** | |
## Version 1.1 (2024-09-19) | |
- Added elaborate description and usage instructions. | |
- Implemented `alias` keys for better readability. | |
- Improved notification messages to include device names. | |
- Improved handling of non-numeric battery levels. | |
## Version 1.0 | |
- Initial release. | |
domain: script | |
author: B. van Wetten | |
source_url: https://gist.githubusercontent.com/QNimbus/7db1fad83b34d2be52ceebcbb3ec74a5/raw/blueprints---battery_level_checker.yaml | |
input: | |
battery_sensors: | |
name: "Battery Sensors" | |
description: "Select the devices to monitor battery level." | |
selector: | |
entity: | |
multiple: true | |
domain: sensor | |
device_class: battery | |
low_battery_threshold: | |
name: "Low Battery Warning Threshold (%)" | |
description: "Specify the battery percentage considered 'low'." | |
default: 20 | |
selector: | |
number: | |
min: 1 | |
max: 50 | |
step: 1 | |
unit_of_measurement: "%" | |
variables: | |
battery_sensors: !input battery_sensors | |
low_battery_threshold: !input low_battery_threshold | |
sequence: | |
- alias: "Check Battery Levels" | |
repeat: | |
count: "{{ battery_sensors | length }}" | |
sequence: | |
- alias: "Set Current Battery Sensor" | |
variables: | |
current_battery_sensor: "{{ battery_sensors[repeat.index - 1] }}" | |
current_battery_level: "{{ states(current_battery_sensor) | float(default=None) }}" | |
- alias: "Check if Battery Level is Low" | |
choose: | |
- conditions: | |
- condition: template | |
value_template: > | |
{{ current_battery_level != None and current_battery_level < low_battery_threshold }} | |
sequence: | |
- alias: "Send Low Battery Persistent Notification" | |
service: notify.persistent_notification | |
data: | |
title: "Low Battery Alert" | |
message: > | |
The battery level for **{{ state_attr(current_battery_sensor, 'friendly_name') }}** is at **{{ current_battery_level }}%**, which is below the threshold of **{{ low_battery_threshold }}%**. | |
- alias: "Send Low Battery Notification to users" | |
service: notify.notify | |
data: | |
title: "Low Battery Alert" | |
message: > | |
The battery level for {{ state_attr(current_battery_sensor, 'friendly_name') }} is at {{ current_battery_level }}%, which is below the threshold of {{ low_battery_threshold }}%. |
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: Doorbell Quiet Hours Control | |
description: | | |
# 🔔 Doorbell Quiet Hours Control | |
**Version: 1.0.0** | |
Last updated: **2024-01-09** | |
This blueprint controls your doorbell chime based on specified quiet hours. It automatically disables the chime during nighttime hours and enables it during the day. The automation can also be manually triggered to toggle the chime state. | |
**Requirements:** | |
- A switch entity that controls your doorbell chime | |
- Set your preferred quiet hours start and end times | |
**GitHub:** [Click Here](https://gist.githubusercontent.com/QNimbus/7db1fad83b34d2be52ceebcbb3ec74a5/raw/blueprints---doorbell_quiet_hours.yaml) | |
<details> | |
<summary><b>[EN] For Users</b> - Click here to read</summary> | |
## Simple Explanation of the Doorbell Quiet Hours System | |
This system automatically controls your doorbell chime based on specific times. Here's how it works: | |
### Chime Disables at Night: | |
- The system automatically disables your doorbell chime at your specified quiet hours start time | |
- Perfect for ensuring undisturbed sleep | |
### Chime Enables in Morning: | |
- The doorbell chime automatically enables at your specified quiet hours end time | |
- Ensures you don't miss visitors during the day | |
### Handling Home Assistant Restarts: | |
- When Home Assistant restarts, the system checks the current time | |
- Sets the correct chime state based on whether it's currently quiet hours | |
### Manual Control: | |
- You can manually toggle the chime state by running the automation | |
- Gives you full control when needed | |
</details> | |
domain: automation | |
input: | |
doorbell_switch: | |
name: Doorbell Switch * | |
description: Select the switch that controls your doorbell chime. | |
selector: | |
entity: | |
domain: switch | |
quiet_start_time: | |
name: Quiet Hours Start Time * | |
description: Time when the doorbell chime should be disabled. | |
default: "22:00:00" | |
selector: | |
time: | |
quiet_end_time: | |
name: Quiet Hours End Time * | |
description: Time when the doorbell chime should be enabled again. | |
default: "07:00:00" | |
selector: | |
time: | |
trigger_variables: | |
doorbell_switch: !input doorbell_switch | |
quiet_start_time: !input quiet_start_time | |
quiet_end_time: !input quiet_end_time | |
trigger: | |
- platform: time | |
at: !input quiet_start_time | |
id: quiet_start | |
alias: "Quiet hours start time reached" | |
- platform: time | |
at: !input quiet_end_time | |
id: quiet_end | |
alias: "Quiet hours end time reached" | |
- platform: homeassistant | |
event: start | |
id: ha_start | |
alias: "Home Assistant start" | |
action: | |
- variables: | |
manually_triggered: "{{ 'idx' not in trigger }}" | |
is_quiet_hours: > | |
{% set current_time = now().strftime('%H:%M:%S') %} | |
{% set start = quiet_start_time %} | |
{% set end = quiet_end_time %} | |
{% if start < end %} | |
{{ current_time >= start and current_time < end }} | |
{% else %} | |
{{ current_time >= start or current_time < end }} | |
{% endif %} | |
- choose: | |
# Handle quiet hours start | |
- conditions: | |
- condition: trigger | |
id: quiet_start | |
sequence: | |
- service: switch.turn_off | |
target: | |
entity_id: !input doorbell_switch | |
alias: "Disable doorbell chime at quiet hours start" | |
# Handle quiet hours end | |
- conditions: | |
- condition: trigger | |
id: quiet_end | |
sequence: | |
- service: switch.turn_on | |
target: | |
entity_id: !input doorbell_switch | |
alias: "Enable doorbell chime at quiet hours end" | |
# Handle Home Assistant start | |
- conditions: | |
- condition: trigger | |
id: ha_start | |
sequence: | |
- choose: | |
- conditions: | |
- condition: template | |
value_template: "{{ is_quiet_hours }}" | |
sequence: | |
- service: switch.turn_off | |
target: | |
entity_id: !input doorbell_switch | |
alias: "Disable doorbell chime at HA start during quiet hours" | |
default: | |
- service: switch.turn_on | |
target: | |
entity_id: !input doorbell_switch | |
alias: "Enable doorbell chime at HA start during active hours" | |
# Handle manual trigger | |
- conditions: | |
- condition: template | |
value_template: "{{ manually_triggered }}" | |
sequence: | |
- service: > | |
{% if is_state(doorbell_switch, 'on') %} | |
switch.turn_off | |
{% else %} | |
switch.turn_on | |
{% endif %} | |
target: | |
entity_id: !input doorbell_switch | |
alias: "Toggle doorbell chime state" | |
mode: single | |
max_exceeded: silent |
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: Outdoor Lighting Control Based on Sun Elevation and Time | |
description: | | |
# 🌅 Outdoor Lighting Control Based on Sun Elevation and Time | |
**Version: 1.2.3** | |
Last updated: **2025-01-20** | |
This blueprint controls outdoor lighting based on the sun's elevation, time, and Home Assistant start events. It turns on the lights when the sun's elevation falls below a specified value at dusk. The lights are turned off at a specified time or using a required timer entity. It also handles Home Assistant start events to ensure the lights are in the correct state based on the sun's elevation at startup. Additionally, the automation can be manually run to toggle the lights on or off. | |
**Requirements:** | |
- Light(s) to control the outdoor lighting. | |
- Provide a timer entity, which is required to control when the lights should turn off. | |
**GitHub:** [Click Here](https://gist.githubusercontent.com/QNimbus/7db1fad83b34d2be52ceebcbb3ec74a5/raw/blueprints---evening_light.yaml) | |
<details> | |
<summary><b>[EN] For Users</b> - Click here to read</summary> | |
## Simple Explanation of the Automatic Outdoor Lighting System | |
This system automatically controls your outdoor lighting based on the position of the sun, specific times, and when Home Assistant restarts. Here's how it works: | |
### Lights Turn On at Dusk: | |
- The system monitors the angle of the sun relative to the horizon. | |
- When the sun drops below a certain height in the sky (you can set this value), the lighting turns on. | |
### Lights Turn On at a Specific Time: | |
- When the sun has not yet descended below the preset angle, the lights will still turn on. | |
### Lights Turn Off at Night: | |
- The lights turn off automatically at a time you specify. | |
- You can also specify a timer that determines when the lights should turn off. | |
### Handling Home Assistant Restarts: | |
- When Home Assistant restarts (e.g., after an update or reboot), the system checks the position of the sun. | |
- When the sun is below the preset height, the lights turn on. | |
- When the sun is above the preset height, the lights turn off. | |
### Manual Control: | |
- Manually running the automation turns the lights on or off. | |
### In Summary: | |
- The system ensures that your outdoor lighting turns on when it gets dark and turns off at a time you specify. | |
- It keeps your outdoor lighting consistent, even if Home Assistant restarts. | |
- You retain full control to turn the lights on or off whenever you want. | |
</details> | |
<br/> | |
<details> | |
<summary><b>[NL] Voor gebruikers</b> - Klik hier om te lezen</summary> | |
## Eenvoudige uitleg van het automatische buitenverlichtingssysteem | |
Dit systeem bedient automatisch uw buitenverlichting op basis van de stand van de zon, specifieke tijden en wanneer Home Assistant opnieuw opstart. Zo werkt het: | |
### Lichten gaan aan bij schemering: | |
- Het systeem houdt de hoek van de zon ten opzichte van de horizon in de gaten. | |
- Wanneer de zon onder een bepaalde hoogte aan de hemel komt (deze waarde kunt u instellen), gaat de verlichting aan. | |
### Lichten gaan aan op een specifieke tijd: | |
- Wanneer de zon nog niet onder de voorafingestelde hoek is gezakt, gaan de lichten toch aan. | |
### Lichten gaan 's nachts uit: | |
- De lichten gaan automatisch uit op een door u ingestelde tijd. | |
- U kunt ook een timer opgeven die bepaalt wanneer de lichten uit moeten gaan. | |
### Handelen bij herstart van Home Assistant: | |
- Als Home Assistant opnieuw opstart (bijvoorbeeld na een update of herstart), controleert het systeem de positie van de zon. | |
- Wanneer de zon onder de voorafingestelde hoogte staat, gaan de lichten aan. | |
- Wanneer de zon boven de voorafingestelde hoogte staat, gaan de lichten uit. | |
### Handmatige bediening: | |
- Het handmatig uitvoeren van de automatisering schakelt de lichten aan of uit. | |
### Samengevat: | |
- Het systeem zorgt ervoor dat uw buitenverlichting aangaat wanneer het donker wordt en uitgaat op een door u gespecificeerde tijd. | |
- Het houdt uw buitenverlichting consistent, zelfs als Home Assistant opnieuw opstart. | |
- U behoudt de volledige controle om de lichten in of uit te schakelen wanneer u maar wilt. | |
</details> | |
<br/> | |
<details> | |
<summary><b>The Automation Process in detail</b> - Click here to expand</summary> | |
## The Automation Process: | |
This blueprint is designed to control outdoor lighting based on sun elevation, time, and Home Assistant start events. The lights are managed to turn on at dusk when the sun's elevation falls below a specified value, and to turn off at a specified time or when the timer entity finishes, whichever occurs first. Additionally, the automation handles Home Assistant start events to ensure the lights are in the correct state based on the sun's elevation at startup. The automation can also be manually triggered to toggle the lights on or off. | |
### Triggers: | |
1. **Sun Elevation:** The automation is triggered when the sun's elevation falls below the specified value. | |
2. **On Time:** The automation is triggered at a specified time to turn on the lights if the sun elevation trigger has not already occurred. | |
3. **Home Assistant Start:** The automation is triggered when Home Assistant starts, ensuring the lights are in the correct state based on the sun's elevation at startup. | |
4. **Off Time:** The automation is triggered at a specified time to turn off the lights. | |
5. **Timer Entity:** The automation is triggered when the specified timer entity goes from active to idle. | |
### Conditions: | |
There are no additional conditions specified for this automation. | |
### Actions: | |
The automation uses a series of "choose" actions to handle different scenarios based on the trigger: | |
1. **Sun Elevation Below Specified Value:** | |
- If the sun's elevation is below the specified value and all selected lights are off, the lights are turned on. | |
2. **On Time Reached:** | |
- If the specified time to turn on the lights is reached and all selected lights are off, the lights are turned on. | |
3. **Off Time Reached:** | |
- If the specified time to turn off the lights is reached and all selected lights are on, the lights are turned off. | |
4. **Home Assistant Start with Sun Below Specified Elevation:** | |
- If Home Assistant starts and the sun's elevation is below the specified value (and it is not rising), and all selected lights are off, the lights are turned on. | |
5. **Home Assistant Start with Sun Above Specified Elevation:** | |
- If Home Assistant starts and the sun's elevation is above the specified value (and it is rising), and all selected lights are on, the lights are turned off. | |
6. **Timer Entity Finished:** | |
- If the specified timer entity goes from active to idle, the lights are turned off. | |
7. **Manual Trigger:** | |
- If the automation is manually triggered, the lights are toggled (turned on if off, and turned off if on). | |
### Detailed Description: | |
- **Inputs:** | |
- **Light(s):** Select the light(s) to control. These lights will be turned on or off based on the sun's elevation, time, or timer entity. | |
- **Dusk Elevation:** Set the sun elevation value below which the lights should turn on at dusk. | |
- **Lights On Time:** Set the time at which the lights should turn on if the sun elevation trigger has not already occurred. | |
- **Lights Off Time:** Set the time at which the lights should turn off. | |
- **Timer Entity:** A required timer entity to control when the lights should turn off. | |
- **Variables:** | |
- **lights:** The selected lights. | |
- **sun_elevation_on:** The specified sun elevation value for turning on the lights at dusk. | |
- **on_time:** The specified time to turn on the lights. | |
- **off_time:** The specified time to turn off the lights. | |
- **timer_entity:** The required timer entity to manage the off time of the lights. | |
- **Triggers:** | |
- Sun elevation falling below the specified value. | |
- Reaching the specified time to turn on the lights. | |
- Home Assistant starting. | |
- Reaching the specified time to turn off the lights. | |
- The specified timer entity going from active to idle. | |
- **Actions:** | |
- Turn on the lights if the sun's elevation is below the specified value and the lights are off. | |
- Turn on the lights at the specified time if the lights are off. | |
- Turn off the lights at the specified time if the lights are on. | |
- Turn on the lights if Home Assistant starts and the sun's elevation is below the specified value (and it is not rising) and the lights are off. | |
- Turn off the lights if Home Assistant starts and the sun's elevation is above the specified value (and it is rising) and the lights are on. | |
- Turn off the lights if the specified timer entity goes from active to idle. | |
- Toggle the lights if the automation is manually triggered. | |
This blueprint ensures that the outdoor lights are controlled based on environmental conditions, specific times, Home Assistant start events, and by a required timer entity, providing flexibility and ensuring lights are on or off as needed. | |
</details> | |
<br/> | |
<details> | |
<summary><b>Changelog</b> - Click here to expand</summary> | |
## Version 1.2.3 (2025-01-20) | |
- Changed 'eq' Jinja filter to 'ne' for checking if any lights are off. | |
## Version 1.2.2 (2024-12-27) | |
- Made timer entity optional - lights will now use only the on/off times if no timer is provided | |
## Version 1.2.1 (2024-10-26) | |
- Moved some variables from 'variables' to 'trigger_variables' since they need to be evaluated at the automation level and not when the trigger fires | |
## Version 1.1 (2024-09-18) | |
- Initial version. | |
- Added detailed explanations in English and Dutch. | |
- Added Changelog section. | |
</details> | |
domain: automation | |
source_url: https://gist.githubusercontent.com/QNimbus/7db1fad83b34d2be52ceebcbb3ec74a5/raw/blueprints---evening_light.yaml | |
input: | |
lights: | |
name: Light(s) * | |
description: Select the light(s) to control. These lights will be turned on or off based on the sun's elevation, local time.or on duration trigger. | |
default: [] | |
selector: | |
entity: | |
multiple: true | |
filter: | |
- domain: light | |
sun_elevation_on: | |
name: Dusk Elevation * | |
description: Set the sun elevation value below which the lights should turn on at dusk. For example, a value of 6 means the lights will turn on when the sun is at 6 degrees above the horizon. | |
default: 6 | |
selector: | |
number: | |
min: -6.0 | |
max: 30 | |
step: 0.25 | |
unit_of_measurement: "°" | |
on_time: | |
name: Lights on time * | |
description: Set the time at which the lights should turn on if the sun elevation trigger has not already occurred. | |
default: "20:30:00" | |
selector: | |
time: | |
off_time: | |
name: Lights off time * | |
description: Set the time at which the lights should turn off. When the timer entity is still running at the off time, this will turn off the lights. | |
default: "02:00:00" | |
selector: | |
time: | |
timer_entity: | |
name: Timer Entity | |
description: Optional timer entity to control when the lights should turn off. If not provided, the lights will turn off at the specified off time. | |
default: null | |
selector: | |
entity: | |
domain: timer | |
trigger_variables: | |
lights: !input lights | |
sun_elevation_on: !input sun_elevation_on | |
on_time: !input on_time | |
off_time: !input off_time | |
timer_entity: !input timer_entity | |
trigger: | |
- platform: numeric_state | |
entity_id: sun.sun | |
attribute: elevation | |
below: !input sun_elevation_on | |
id: sun_elevation_on | |
alias: "Sun elevation below specified value" | |
- platform: time | |
at: !input on_time | |
id: on_time | |
alias: "Specified lights on time reached" | |
- platform: homeassistant | |
event: start | |
id: ha_start | |
alias: "Home Assistant start" | |
- platform: time | |
at: !input off_time | |
id: off_time | |
alias: "Specified lights off time reached" | |
- platform: state | |
entity_id: !input timer_entity | |
from: "active" | |
to: "idle" | |
id: timer_finished | |
alias: "Timer finished" | |
enabled: "{{ timer_entity != null }}" | |
condition: [] | |
action: | |
- variables: | |
manually_triggered: "{{ 'idx' not in trigger }}" | |
light_states: >- | |
{% set entities = expand(lights) %} | |
{{ entities | map(attribute='state') | list }} | |
any_light_on: "{{ light_states | select('eq', 'on') | list | length > 0 }}" | |
any_light_off: "{{ light_states | select('ne', 'on') | list | length > 0 }}" | |
all_lights_on: "{{ light_states | select('eq', 'on') | list | length == light_states | length }}" | |
all_lights_off: "{{ light_states | select('ne', 'on') | list | length == light_states | length }}" | |
has_timer: "{{ timer_entity != null }}" | |
- choose: | |
- conditions: | |
- condition: trigger | |
id: sun_elevation_on | |
alias: "Triggered by sun elevation below specified value" | |
- condition: template | |
value_template: "{{ any_light_off }}" | |
alias: "Some selected lights are off" | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: !input lights | |
- if: | |
condition: template | |
value_template: "{{ has_timer }}" | |
then: | |
- service: timer.start | |
alias: "Start timer" | |
target: | |
entity_id: !input timer_entity | |
- conditions: | |
- condition: trigger | |
id: on_time | |
alias: "Triggered by specified lights on time" | |
- condition: template | |
value_template: "{{ any_light_off }}" | |
alias: "Some selected lights are off" | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: !input lights | |
- if: | |
condition: template | |
value_template: "{{ has_timer }}" | |
then: | |
- service: timer.start | |
alias: "Start timer" | |
target: | |
entity_id: !input timer_entity | |
- conditions: | |
- condition: trigger | |
id: off_time | |
alias: "Triggered by specified lights off time" | |
- condition: template | |
value_template: "{{ any_lights_on }}" | |
alias: "Some selected lights are on" | |
sequence: | |
- service: light.turn_off | |
target: | |
entity_id: !input lights | |
- if: | |
condition: template | |
value_template: "{{ has_timer }}" | |
then: | |
- service: timer.cancel | |
alias: "Cancel timer" | |
target: | |
entity_id: !input timer_entity | |
- conditions: | |
- condition: and | |
conditions: | |
- condition: trigger | |
id: ha_start | |
alias: "Triggered by Home Assistant start" | |
- condition: numeric_state | |
entity_id: sun.sun | |
attribute: elevation | |
below: !input sun_elevation_on | |
alias: "Sun elevation below specified value" | |
- condition: template | |
alias: "Sun is not rising" | |
value_template: "{{ state_attr('sun.sun', 'rising') == false }}" | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: !input lights | |
alias: "Turn on lights at HA start when sun is below specified elevation" | |
- if: | |
condition: template | |
value_template: "{{ has_timer }}" | |
then: | |
- service: timer.start | |
alias: "Start timer" | |
target: | |
entity_id: !input timer_entity | |
- conditions: | |
- condition: and | |
conditions: | |
- condition: trigger | |
id: ha_start | |
alias: "Triggered by Home Assistant start" | |
- condition: numeric_state | |
entity_id: sun.sun | |
attribute: elevation | |
above: !input sun_elevation_on | |
alias: "Sun elevation above specified value" | |
- condition: template | |
alias: "Sun is rising" | |
value_template: "{{ state_attr('sun.sun', 'rising') == true }}" | |
sequence: | |
- service: light.turn_off | |
target: | |
entity_id: !input lights | |
alias: "Turn off lights at HA start when sun is above specified elevation" | |
- if: | |
condition: template | |
value_template: "{{ has_timer }}" | |
then: | |
- service: timer.cancel | |
alias: "Cancel timer" | |
target: | |
entity_id: !input timer_entity | |
- conditions: | |
- condition: trigger | |
id: timer_finished | |
alias: "Triggered by timer finishing" | |
- condition: template | |
value_template: "{{ has_timer }}" | |
sequence: | |
- service: light.turn_off | |
target: | |
entity_id: !input lights | |
alias: "Turn off lights when timer finishes" | |
- conditions: | |
- condition: template | |
value_template: "{{ manually_triggered }}" | |
alias: "Automation manually triggered" | |
sequence: | |
- choose: | |
- conditions: | |
- condition: template | |
value_template: "{{ any_light_on }}" | |
alias: "Some lights are on" | |
sequence: | |
- service: light.turn_off | |
alias: "Turn off all lights" | |
target: | |
entity_id: !input lights | |
default: | |
sequence: | |
- service: light.turn_on | |
alias: "Turn on all lights" | |
target: | |
entity_id: !input lights | |
mode: single | |
max_exceeded: silent |
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 metadata | |
blueprint: | |
name: Disable Fibaro lights during daylight | |
description: | | |
# 🪄 Disable Fibaro lights during daylight | |
**Version: 0.4** | |
This blueprint can disable the manual operation of one or more Fibaro dimmers during a certain period (i.e. daytime, between sunrise and sunset). | |
The use case for this blueprint is the fact that my children occasionally refuse to open their bedroom curtains and switch on their room lights during the day which is wasteful and not required when the sun is up. | |
Using this blueprint/automation the manual operation of these lights is inhibited during daytime. | |
<details> | |
<summary><b>The Automation Process:</b> - Click here to expand</summary> | |
</details> | |
Required = * | |
GitHub: [Click Here](https://gist.githubusercontent.com/QNimbus/7db1fad83b34d2be52ceebcbb3ec74a5/raw/blueprints---fibaro_daylight_disable.yaml) | |
domain: automation | |
source_url: https://gist.githubusercontent.com/QNimbus/7db1fad83b34d2be52ceebcbb3ec74a5/raw/blueprints---fibaro_daylight_disable.yaml | |
input: | |
switch_off_lights: | |
name: " Switch off lights?" | |
description: >- | |
Also turn off the light(s) if they were on. | |
default: true | |
selector: | |
boolean: | |
fibaro_devices: | |
name: " Fibaro dimmer(s)" | |
description: >- | |
Which Fibaro dimmer(s) do you want to control? | |
<details> | |
<summary><code><strong>[ More info ]</strong></code></summary> | |
Select one or more Fibaro dimmers that you want to disable manual/local control for during the daylight period. | |
</details> | |
selector: | |
device: | |
multiple: true | |
filter: | |
- integration: zwave_js | |
manufacturer: Fibargroup | |
model: FGD212 | |
sun_elevation: | |
name: "Sun Elevation" | |
description: "Set the sun elevation value above which local operation should be disabled." | |
default: 6.0 | |
selector: | |
number: | |
min: -10 | |
max: 20 | |
step: 0.1 | |
unit_of_measurement: "°" | |
manual_control: | |
name: "Re-enable manual control on manual trigger of automation" | |
description: "Re-enable manual control when the automation is manually triggered regardless of sun elevation." | |
default: false | |
selector: | |
boolean: | |
mode: single | |
max_exceeded: silent | |
variables: | |
switch_off_lights: !input switch_off_lights | |
fibaro_devices: !input fibaro_devices | |
sun_elevation: !input sun_elevation | |
manual_control: !input manual_control | |
# Extract local operation entities | |
fibaro_entities_local_operation: >- | |
{%- set ns = namespace(fibaro_entities_local_operation=[]) -%} | |
{%- for device in fibaro_devices -%} | |
{%- for entity in device_entities(device) -%} | |
{%- if entity | regex_search("^select\\..*local.*$") -%} | |
{%- set ns.fibaro_entities_local_operation = ns.fibaro_entities_local_operation + [entity] -%} | |
{%- endif -%} | |
{%- endfor -%} | |
{%- endfor -%} | |
{{ ns.fibaro_entities_local_operation }} | |
# Extract light entities | |
fibaro_entities_light: >- | |
{%- set ns = namespace(fibaro_entities_light=[]) -%} | |
{%- for device in fibaro_devices -%} | |
{%- for entity in device_entities(device) -%} | |
{%- if entity | regex_search("^light\\..*$") -%} | |
{%- set ns.fibaro_entities_light = ns.fibaro_entities_light + [entity] -%} | |
{%- endif -%} | |
{%- endfor -%} | |
{%- endfor -%} | |
{{ ns.fibaro_entities_light }} | |
trigger: | |
- platform: numeric_state | |
entity_id: sun.sun | |
attribute: elevation | |
above: !input sun_elevation | |
id: "t1_start" | |
- platform: numeric_state | |
entity_id: sun.sun | |
attribute: elevation | |
below: !input sun_elevation | |
id: "t1_end" | |
- platform: homeassistant | |
id: "homeassistant_start" | |
event: start | |
# All Conditions | |
condition: [] | |
# Actions | |
action: | |
- alias: "Determine if manually triggered" | |
choose: | |
- conditions: | |
- condition: template | |
value_template: "{{ trigger.platform != 'numeric_state' and trigger.platform != 'homeassistant' }}" | |
sequence: | |
- alias: "Toggle manual control" | |
choose: | |
- conditions: | |
- condition: template | |
value_template: > | |
{{ states(fibaro_entities_local_operation[0]) == 'Unprotected' }} | |
sequence: | |
- service: select.select_option | |
data: | |
option: NoOperationPossible | |
target: | |
entity_id: "{{ fibaro_entities_local_operation }}" | |
- service: light.turn_off | |
target: | |
entity_id: "{{ fibaro_entities_light }}" | |
- conditions: | |
- condition: template | |
value_template: > | |
{{ states(fibaro_entities_local_operation[0]) == 'NoOperationPossible' }} | |
sequence: | |
- service: select.select_option | |
data: | |
option: Unprotected | |
target: | |
entity_id: "{{ fibaro_entities_local_operation }}" | |
- conditions: | |
- condition: numeric_state | |
entity_id: sun.sun | |
attribute: elevation | |
above: !input sun_elevation | |
sequence: | |
- alias: "Disable local operation after sunrise" | |
service: select.select_option | |
data: | |
option: NoOperationPossible | |
target: | |
entity_id: "{{ fibaro_entities_local_operation }}" | |
- choose: | |
- conditions: | |
- condition: template | |
value_template: "{{ switch_off_lights }}" | |
sequence: | |
- service: light.turn_off | |
target: | |
entity_id: "{{ fibaro_entities_light }}" | |
- conditions: | |
- condition: numeric_state | |
entity_id: sun.sun | |
attribute: elevation | |
below: !input sun_elevation | |
sequence: | |
- alias: "Enable local operation before sunrise" | |
service: select.select_option | |
data: | |
option: Unprotected | |
target: | |
entity_id: "{{ fibaro_entities_local_operation }}" |
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: Smart Garden Irrigation Control with Auto Shutdown | |
description: | | |
# 💧 Smart Garden Irrigation Control with Auto Shutdown | |
**Version: 1.3** | |
This blueprint controls Woox Smart Garden Irrigation valves. When manually triggered, it will open the selected valves and automatically close them after 60 minutes or the specified duration. Additionally, if configured, the automation will only run if a specified Fibargroup power plug (controlling a water pump) is turned on. | |
**Requirements:** | |
- Woox Smart Garden Irrigation Control (R7060) water valves. | |
- Timer helper to manage the irrigation duration. | |
- (Optional) Fibargroup power plug to control a water pump. | |
**Automation Process:** | |
- **Triggers:** | |
1. Manual trigger. | |
2. Valves have been open for the specified duration (managed by the timer). | |
- **Actions:** | |
- Open the valves when manually triggered. | |
- Close the valves when the timer finishes. | |
domain: automation | |
source_url: https://gist.githubusercontent.com/QNimbus/7db1fad83b34d2be52ceebcbb3ec74a5/raw/blueprints---garden_irrigation.yaml | |
input: | |
irrigation_valves: | |
name: Irrigation Valve(s) * | |
description: Select the water valves to control. | |
selector: | |
device: | |
multiple: true | |
filter: | |
- manufacturer: Woox | |
timer_entity: | |
name: Timer Helper * | |
description: Select the timer helper entity that will manage the irrigation duration. | |
selector: | |
entity: | |
domain: timer | |
duration: | |
name: Irrigation Duration | |
description: Set the duration (in minutes) for how long the valves should remain open. | |
default: 60 | |
selector: | |
number: | |
min: 1 | |
max: 180 | |
step: 1 | |
unit_of_measurement: "min" | |
power_plug: | |
name: Power Plug (Optional) | |
description: Select the Fibargroup power plug that controls the water pump. The automation will only run if this plug is turned on. | |
default: [] | |
selector: | |
device: | |
multiple: false | |
filter: | |
- manufacturer: Fibargroup | |
model: FGWP102 | |
variables: | |
irrigation_valves: !input irrigation_valves | |
duration: !input duration | |
timer_entity: !input timer_entity | |
power_plug: !input power_plug | |
woox_switches: >- | |
{%- set ns = namespace(woox_switches=[]) -%} | |
{%- for device in irrigation_valves -%} | |
{%- for entity in device_entities(device) -%} | |
{%- if entity | regex_search("^switch\\..*$") -%} | |
{%- set ns.woox_switches = ns.woox_switches + [entity] -%} | |
{%- endif -%} | |
{%- endfor -%} | |
{%- endfor -%} | |
{{ ns.woox_switches }} | |
pump_switch: >- | |
{%- if power_plug == [] -%} | |
None | |
{%- else -%} | |
{%- set ns = namespace(pump_switch=None) -%} | |
{%- for entity in device_entities(power_plug) -%} | |
{%- if entity | regex_search("^switch\\..*$") -%} | |
{%- set ns.pump_switch = entity -%} | |
{%- endif -%} | |
{%- endfor -%} | |
{{ ns.pump_switch }} | |
{%- endif -%} | |
trigger: | |
- platform: state | |
entity_id: !input timer_entity | |
from: "active" | |
to: "idle" | |
id: "timer_finished" | |
action: | |
- choose: | |
- conditions: | |
- "{{ 'idx' not in trigger }}" | |
- "{{ pump_switch is none or is_state(pump_switch, 'on') }}" | |
alias: Test if manually run (no trigger) and pump is on | |
sequence: | |
- service: switch.toggle | |
target: | |
entity_id: "{{ woox_switches }}" | |
- service: timer.start | |
target: | |
entity_id: !input timer_entity | |
data: | |
duration: "{{ duration | multiply(60) }}" # Convert minutes to seconds | |
- conditions: | |
- condition: trigger | |
id: "timer_finished" | |
sequence: | |
- service: switch.turn_off | |
target: | |
entity_id: "{{ woox_switches }}" | |
mode: restart |
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 metadata | |
blueprint: | |
name: Friends of Hue switch | |
description: > | |
HA version 2023.08 or newer | |
When using the Friends of Hue switch using the zigbee2mqtt integration, the switch is not recognized as a button. This blueprint allows you to use the Friends of Hue switch as a button. The blueprint supports short press, long press, double press, and press and hold actions. | |
Requirements: | |
- Friends of Hue switch | |
- zigbee2mqtt integration | |
- HA version 2023.08 or newer | |
- binary_sensor entities for each button on the Friends of Hue switch | |
e.g. for a Friends of Hue switch with 4 buttons, you need 4 binary_sensor entities. | |
```yaml | |
mqtt: | |
binary_sensor: | |
- name: "Friends of Hue Smart Switch 01 - Button A0" | |
unique_id: 76258bd9-61be-4069-83ee-45c2747ea960 | |
icon: mdi:grid-large | |
state_topic: "zigbee2mqtt/FriendsOfHueSmartSwitch01/action" | |
payload_on: "press_1" | |
payload_off: "release_1" | |
``` | |
GitHub: [Click Here](https://gist.githubusercontent.com/QNimbus/7db1fad83b34d2be52ceebcbb3ec74a5/raw/blueprints---hue_switch.yaml) | |
domain: automation | |
source_url: https://gist.githubusercontent.com/QNimbus/7db1fad83b34d2be52ceebcbb3ec74a5/raw/blueprints---hue_switch.yaml | |
input: | |
hue-double-press-time: | |
name: "Double press time span" | |
description: "Maximal time between two button presses to count as double press" | |
selector: | |
number: | |
min: 100 | |
max: 1000 | |
step: 100 | |
unit_of_measurement: "ms" | |
mode: slider | |
hue-switch-button1: | |
name: "Button 1 (A0)" | |
description: "Upper left" | |
selector: | |
entity: | |
filter: | |
domain: binary_sensor | |
integration: mqtt | |
hue-switch-button2: | |
name: "Button 2 (A1)" | |
description: "Lower left" | |
selector: | |
entity: | |
filter: | |
domain: binary_sensor | |
integration: mqtt | |
hue-switch-button3: | |
name: "Button 3 (B0)" | |
description: "Upper right" | |
selector: | |
entity: | |
filter: | |
domain: binary_sensor | |
integration: mqtt | |
hue-switch-button4: | |
name: "Button 4 (B1)" | |
description: "Lower right" | |
selector: | |
entity: | |
filter: | |
domain: binary_sensor | |
integration: mqtt | |
# button_1_short_release: | |
# name: Short Release 1 | |
# description: Action to run on button upper-left short release | |
# default: [] | |
# selector: | |
# action: {} | |
# button_2_short_release: | |
# name: Short Release 2 | |
# description: Action to run on button lower-left short release | |
# default: [] | |
# selector: | |
# action: {} | |
# button_3_short_release: | |
# name: Short Release 3 | |
# description: Action to run on button upper-right short release | |
# default: [] | |
# selector: | |
# action: {} | |
# button_4_short_release: | |
# name: Short Release 4 | |
# description: Action to run on button lower-right short release | |
# default: [] | |
# selector: | |
# action: {} | |
# button_1_long_release: | |
# name: Long Release 1 | |
# description: Action to run on button upper-left long release | |
# default: [] | |
# selector: | |
# action: {} | |
# button_2_long_release: | |
# name: Long Release 2 | |
# description: Action to run on button lower-left long release | |
# default: [] | |
# selector: | |
# action: {} | |
# button_3_long_release: | |
# name: Long Release 3 | |
# description: Action to run on button upper-right long release | |
# default: [] | |
# selector: | |
# action: {} | |
# button_4_long_release: | |
# name: Long Release 4 | |
# description: Action to run on button lower-right long release | |
# default: [] | |
# selector: | |
# action: {} | |
button_1_press: | |
name: Press 1 | |
description: Action to run on button upper-left initial press | |
default: [] | |
selector: | |
action: {} | |
button_2_press: | |
name: Press 2 | |
description: Action to run on button lower-left initial press | |
default: [] | |
selector: | |
action: {} | |
button_3_press: | |
name: Press 3 | |
description: Action to run on button upper-right initial press | |
default: [] | |
selector: | |
action: {} | |
button_4_press: | |
name: Press 4 | |
description: Action to run on button lower-right initial press | |
default: [] | |
selector: | |
action: {} | |
button_1_double_press: | |
name: Double Press 1 | |
description: Action to run on button upper-left initial double press | |
default: [] | |
selector: | |
action: {} | |
button_2_double_press: | |
name: Double Press 2 | |
description: Action to run on button lower-left initial double press | |
default: [] | |
selector: | |
action: {} | |
button_3_double_press: | |
name: Double Press 3 | |
description: Action to run on button upper-right initial double press | |
default: [] | |
selector: | |
action: {} | |
button_4_double_press: | |
name: Double Press 4 | |
description: Action to run on button lower-right initial double press | |
default: [] | |
selector: | |
action: {} | |
button_1_repeat: | |
name: Repeat 1 | |
description: Action to run on button upper-left repeat | |
default: [] | |
selector: | |
action: {} | |
button_2_repeat: | |
name: Repeat 2 | |
description: Action to run on button lower-left repeat | |
default: [] | |
selector: | |
action: {} | |
button_3_repeat: | |
name: Repeat 3 | |
description: Action to run on button upper-right repeat | |
default: [] | |
selector: | |
action: {} | |
button_4_repeat: | |
name: Repeat 4 | |
description: Action to run on button lower-right repeat | |
default: [] | |
selector: | |
action: {} | |
# Automation schema | |
mode: single | |
max_exceeded: silent | |
trigger: | |
- platform: state | |
id: A0 | |
entity_id: !input "hue-switch-button1" | |
- platform: state | |
id: A1 | |
entity_id: !input "hue-switch-button2" | |
- platform: state | |
id: B0 | |
entity_id: !input "hue-switch-button3" | |
- platform: state | |
id: B1 | |
entity_id: !input "hue-switch-button4" | |
action: | |
- variables: | |
switch_id: "{{ trigger.id }}" | |
switch_to_state: "{{ trigger.to_state.state }}" | |
switch_from_state: "{{ trigger.from_state.state }}" | |
hue_double_press_seconds: !input "hue-double-press-time" | |
- choose: | |
- conditions: "{{ switch_to_state == 'on' }}" | |
sequence: | |
- choose: | |
- conditions: "{{ switch_id == 'A0' }}" | |
sequence: | |
- if: { condition: template, value_template: "{{ true }}" } | |
then: !input "button_1_press" | |
- conditions: "{{ switch_id == 'A1' }}" | |
sequence: | |
- if: { condition: template, value_template: "{{ true }}" } | |
then: !input "button_2_press" | |
- conditions: "{{ switch_id == 'B0' }}" | |
sequence: | |
- if: { condition: template, value_template: "{{ true }}" } | |
then: !input "button_3_press" | |
- conditions: "{{ switch_id == 'B1' }}" | |
sequence: | |
- if: { condition: template, value_template: "{{ true }}" } | |
then: !input "button_4_press" | |
# - conditions: "{{ switch_to_state == 'repeat' }}" | |
# sequence: | |
# - choose: | |
# - conditions: "{{ switch_id == 'B1' }}" | |
# sequence: !input "button_1_repeat" | |
# - conditions: "{{ switch_id == 'B2' }}" | |
# sequence: !input "button_2_repeat" | |
# - conditions: "{{ switch_id == 'B3' }}" | |
# sequence: !input "button_3_repeat" | |
# - conditions: "{{ switch_id == 'B4' }}" | |
# sequence: !input "button_4_repeat" | |
# - conditions: "{{ switch_to_state == 'long_release' }}" | |
# sequence: | |
# - choose: | |
# - conditions: "{{ switch_id == 'B1' }}" | |
# sequence: !input "button_1_long_release" | |
# - conditions: "{{ switch_id == 'B2' }}" | |
# sequence: !input "button_2_long_release" | |
# - conditions: "{{ switch_id == 'B3' }}" | |
# sequence: !input "button_3_long_release" | |
# - conditions: "{{ switch_id == 'B4' }}" | |
# sequence: !input "button_4_long_release" | |
# - conditions: "{{ switch_to_state == 'short_release' }}" | |
# sequence: | |
# - choose: | |
# - conditions: "{{ switch_from_state == 'initial_press' }}" | |
# sequence: | |
# - choose: | |
# - conditions: "{{ switch_id == 'B1' }}" | |
# sequence: !input "button_1_short_release" | |
# - conditions: "{{ switch_id == 'B2' }}" | |
# sequence: !input "button_2_short_release" | |
# - conditions: "{{ switch_id == 'B3' }}" | |
# sequence: !input "button_3_short_release" | |
# - conditions: "{{ switch_id == 'B4' }}" | |
# sequence: !input "button_4_short_release" |
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: Bathroom Mirror Heating Control | |
description: | | |
# 🛁 Bathroom Mirror Heating Control | |
**Version: 1.5** | |
This blueprint automates the control of your bathroom mirror heating based on water flow and light conditions. When the water flow exceeds a defined threshold for a specified duration and the bathroom lights are on, the mirror heater will be activated. If the water flow drops below the threshold for more than 1 minute, the mirror heater will turn off—but only after it has been on for at least 5 minutes. | |
**Requirements:** | |
- A switch entity to control the mirror heating. | |
- A sensor entity for water flow measurement (e.g., `sensor.watermeter_water_usage`). | |
- A light entity for the bathroom lights. | |
**Automation Process:** | |
- **Triggers:** | |
- Water flow above the threshold for the specified duration. | |
- Water flow below the threshold for more than 1 minute. | |
- **Conditions:** | |
- For turning on: Water flow is above the threshold for the specified duration, and the bathroom lights are on. | |
- For turning off: Water flow is below the threshold, and the mirror heater is on. | |
- **Actions:** | |
- Turn on the bathroom mirror heating when both conditions are met. | |
- Wait until the heating has been on for at least 5 minutes before turning it off when water flow is below the threshold. | |
domain: automation | |
source_url: https://gist.githubusercontent.com/QNimbus/7db1fad83b34d2be52ceebcbb3ec74a5/raw/blueprints---mirror_heater_control.yaml | |
input: | |
mirror_heating_switch: | |
name: Mirror Heating Switch * | |
description: Select the switch entity that controls the bathroom mirror heating. | |
selector: | |
entity: | |
domain: switch | |
water_flow_sensor: | |
name: Water Flow Sensor * | |
description: Select the sensor entity that measures the water flow. | |
selector: | |
entity: | |
domain: sensor | |
bathroom_lights: | |
name: Bathroom Light * | |
description: Select the light entity for the bathroom lights. | |
selector: | |
entity: | |
multiple: false | |
filter: | |
- domain: light | |
water_flow_threshold: | |
name: Water Flow Threshold (lpm) * | |
description: Set the threshold for the water flow in liters per minute (lpm). The default is 5 lpm. | |
default: 5 | |
selector: | |
number: | |
min: 1 | |
max: 40 | |
step: 0.5 | |
unit_of_measurement: "lpm" | |
water_flow_duration: | |
name: Water Flow Duration (seconds) * | |
description: Set the duration for which the water flow must exceed the threshold to trigger the automation. | |
default: 30 | |
selector: | |
number: | |
min: 5 | |
max: 300 | |
step: 1 | |
unit_of_measurement: "s" | |
variables: | |
mirror_heating_switch: !input mirror_heating_switch | |
water_flow_sensor: !input water_flow_sensor | |
bathroom_lights: !input bathroom_lights | |
water_flow_threshold: !input water_flow_threshold | |
water_flow_duration: !input water_flow_duration | |
heating_min_duration: 300 # Minimum time (in seconds) the heating should be on before it can be turned off | |
trigger: | |
- platform: numeric_state | |
entity_id: !input water_flow_sensor | |
above: !input water_flow_threshold | |
for: | |
seconds: !input water_flow_duration | |
id: "water_flow_high" | |
- platform: numeric_state | |
entity_id: !input water_flow_sensor | |
below: !input water_flow_threshold | |
for: | |
seconds: 60 | |
id: "water_flow_low" | |
condition: | |
- condition: or | |
conditions: | |
- condition: template | |
value_template: "{{ 'idx' not in trigger }}" # Check if manually triggered | |
- condition: and | |
conditions: | |
- condition: template | |
value_template: "{{ trigger.id == 'water_flow_high' }}" # Check if triggered by water flow high | |
- condition: state | |
entity_id: !input bathroom_lights | |
state: "on" # Ensure bathroom lights are on | |
- condition: and | |
conditions: | |
- condition: template | |
value_template: "{{ trigger.id == 'water_flow_low' }}" # Check if triggered by water flow low | |
- condition: state | |
entity_id: !input mirror_heating_switch | |
state: "on" # Ensure the heating is on | |
action: | |
- choose: | |
- conditions: "{{ 'idx' not in trigger }}" | |
sequence: | |
- service: switch.toggle | |
target: | |
entity_id: !input mirror_heating_switch | |
- conditions: "{{ trigger.id == 'water_flow_high' }}" | |
sequence: | |
- service: switch.turn_on | |
target: | |
entity_id: !input mirror_heating_switch | |
- conditions: "{{ trigger.id == 'water_flow_low' }}" | |
sequence: | |
- wait_template: "{{ (as_timestamp(now()) - as_timestamp(states[mirror_heating_switch].last_changed)) > heating_min_duration }}" | |
timeout: "00:05:00" # Timeout after 5 minutes (as a safeguard) | |
continue_on_timeout: true # Continue even if the timeout is reached | |
- service: switch.turn_off | |
target: | |
entity_id: !input mirror_heating_switch | |
mode: single | |
max_exceeded: silent |
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: Motion Activated Lights with Timer, Sun Elevation, and Cooldown | |
description: | | |
# 🌞 Motion Activated Lights with Timer, Sun Elevation, and Cooldown | |
**Version: 2.0.2** | |
Last updated: **2024-10-26** | |
This blueprint automates lights based on motion detection, sun elevation, and a timer. It includes features like a cooldown period, manual override handling, optional disabling of local operation on Fibaro devices, and adjustable brightness for motion-activated lighting. | |
**Automation Logic:** | |
1. Motion Detection: Turns on lights when motion is detected if the sun is below the specified elevation or if "Always Trigger" is enabled. | |
2. Timer Management: Starts or restarts a timer when motion is detected or lights are turned on. | |
3. Light Control: Turns off lights when the timer finishes and no motion is detected. | |
4. Cooldown Period: Implements a cooldown delay after lights are manually turned off to prevent immediate re-triggering. | |
5. Manual Override: Allows for manual control of lights, adjusting the timer accordingly. | |
6. Partial State Handling: Properly manages scenarios where only some lights in a group are on or off. | |
7. **Disable Local Operation:** Optionally disables local control of Fibaro devices while the lights are on due to motion detection. | |
8. **Motion-activated Brightness:** Sets a specific brightness level when lights are turned on by motion detection. | |
**Requirements:** | |
- Motion sensor(s) for detecting movement. | |
- Fibaro device(s) (e.g., dimmers) whose associated lights will be controlled. | |
- Timer helper to manage the light duration. | |
**GitHub:** [Click Here](https://gist.githubusercontent.com/QNimbus/7db1fad83b34d2be52ceebcbb3ec74a5/raw/blueprints---motion_light.yaml) | |
<details> | |
<summary><b>[EN] For Users</b> - Click here to read</summary> | |
## Simple Explanation of the Automatic Lighting System | |
This system in your home automatically controls the lights based on movement and whether it is light or dark outside. Here's how it works: | |
## Motion Sensors: | |
In certain rooms, there are sensors that detect when someone enters or moves. | |
When movement is detected, the system receives a signal. | |
## Lights Turn On When It's Dark: | |
The system knows if it's dark outside by looking at the position of the sun. | |
If it's dark and there is movement, the lights automatically turn on. | |
There is also an option to always turn on the lights when there is movement, regardless of whether it's light or dark outside. | |
## Timer for the Lights: | |
As soon as the lights turn on, a timer starts. | |
If there is no movement after a certain time, the lights automatically turn off. | |
If you keep moving, the timer keeps restarting, so the lights stay on. | |
## Manual Control: | |
You can also turn the lights on or off manually, for example with a switch. | |
If you turn off the lights manually while the timer is still running, the system will not turn them back on immediately. There is a short pause before the automatic system starts working again. | |
## Temporarily Disabling Local Control | |
When the system turns on the lights due to movement, it can choose to temporarily disable the light switches. This way, you cannot operate them while the automatic system has turned on the lights. | |
Once the lights go off again, the switches become manually operable again. | |
## In Summary: | |
The system ensures that the lights turn on when you enter a room and it's dark. They automatically turn off when you leave or when there is no more movement. This makes your home more comfortable and saves energy. You still have the control to operate the lights manually whenever you want. | |
</details> | |
<br/> | |
<details> | |
<summary><b>[NL] Voor gebruikers</b> - Klik hier om te lezen</summary> | |
## Eenvoudige uitleg van het automatische lichtsysteem | |
Dit systeem in je huis regelt automatisch de lichten op basis van beweging en of het buiten licht of donker is. Zo werkt het: | |
## Bewegingssensoren: | |
In bepaalde kamers zijn sensoren die merken wanneer iemand binnenkomt of beweegt. | |
Als er beweging wordt gedetecteerd, krijgt het systeem een seintje. | |
## Lichten gaan aan als het donker is: | |
Het systeem weet of het buiten donker is door naar de stand van de zon te kijken. | |
Als het donker is en er beweging is, gaan de lichten automatisch aan. | |
Er is ook een optie om de lichten altijd aan te laten gaan bij beweging, ongeacht of het licht of donker is buiten. | |
## Timer voor de lichten: | |
Zodra de lichten aangaan, start er een timer. | |
Als er na een bepaalde tijd geen beweging meer is, gaan de lichten vanzelf uit. | |
Als je blijft bewegen, blijft de timer opnieuw starten, zodat de lichten aan blijven. | |
## Handmatige bediening: | |
Je kunt de lichten ook met de hand aan- of uitzetten, bijvoorbeeld met een schakelaar. | |
Als je de lichten met de hand uitzet terwijl de timer nog loopt, zal het systeem ze niet meteen weer aanzetten. Er is dan een korte pauze voordat het automatische systeem weer werkt. | |
## Tijdelijk uitschakelen van lokale bediening | |
Als het systeem de lichten aanzet vanwege beweging, kan het ervoor kiezen om de licht schakelaars tijdelijk uit te schakelen. Zo kun je ze niet bedienen terwijl het automatische systeem de lampen heeft ingeschakeld. | |
Zodra de lichten weer uitgaan, worden de schakelaars weer met de hand bedienbaar. | |
## Kort samengevat: | |
Het systeem zorgt ervoor dat de lichten aangaan als je een kamer binnenkomt en het donker is. Ze gaan automatisch uit als je weggaat of als er geen beweging meer is. Dit maakt je huis comfortabeler en bespaart energie. Je hebt nog steeds de controle om de lichten met de hand te bedienen wanneer je dat wilt. | |
</details> | |
<br/> | |
<details> | |
<summary><b>The Automation Process in detail</b> - Click here to expand</summary> | |
## The Automation Process: | |
This automation blueprint controls lights based on motion detection, sun elevation, and a timer. It includes features like a cooldown period, manual override handling, and optional disabling of local operation on Fibaro devices. | |
### Triggers: | |
1. **Motion Detection:** Triggered when any selected motion sensor detects motion. | |
2. **Timer Finished:** Triggered when the specified timer transitions from "active" to "idle". | |
3. **Light Turned Off:** Triggered when any of the lights associated with the selected Fibaro devices transitions from "on" to "off". | |
### Conditions: | |
1. **Sun Condition Met:** Checks if lights should be turned on based on: | |
- The "Always Trigger" option being enabled, or | |
- The sun's elevation being below the specified threshold. | |
2. **Cooldown Condition:** Applies when lights are turned off while the timer is active. | |
### Actions: | |
The automation uses a series of "choose" actions to handle different scenarios: | |
1. **Manual Trigger:** Toggles lights and manages the timer accordingly. | |
2. **Motion Detected and All Lights Off:** Turns on all lights, disables local operation (if enabled), and starts the timer. | |
3. **Motion Detected with Timer Active:** Restarts the timer. | |
4. **Timer Finished:** | |
- If no motion is detected or sun is above threshold: Turns off lights, re-enables local operation (if previously disabled). | |
- If motion is detected and any light is on: Restarts timer. | |
5. **Light Manually Turned Off During Timer:** Applies a cooldown delay. | |
This automation ensures lights are controlled based on motion, sun elevation, and manual interventions, with features to prevent rapid re-triggering, handle partial light states, and optionally disable local operation on Fibaro devices during motion-activated lighting. | |
</details> | |
<br/> | |
<details> | |
<summary><b>Changelog</b> - Click here to expand</summary> | |
## Version 2.0.2 (2024-10-26) | |
- Moved some variables from 'variables' to 'trigger_variables' since they need to be evaluated at the automation level and not when the trigger fires | |
## Version 2.0.1 (2024-10-08) | |
- Modified timer finished condition to check for motion state before turning off lights. | |
- If motion is still detected when timer finishes, the timer is restarted. | |
- If no motion is detected when timer finishes, lights are turned off. | |
## Version 2.0 (2024-10-08) | |
- Users can now set a specific brightness level for when lights are turned on by motion detection. | |
## Version 1.9 (2024-10-07) | |
- Modified timer finished condition to always turn off lights when timer ends, regardless of motion or sun condition. | |
- Removed redundant conditions for turning off lights when timer finishes. | |
- Changed automation mode from 'single' to 'queued' with a max of 10. | |
## Version 1.8 (2024-09-18) | |
- Refactored the automation logic to remove redundant variable declarations and streamline the manual trigger sequence. | |
- Moved the `manually_triggered`, `light_states`, `any_light_on`, and `any_light_off` variables to the action scope. | |
- Replaced the `light.toggle` service with conditional logic to ensure lights are turned on or off explicitly, preventing unknown states. | |
- Improved the manual trigger sequence to check the current state of lights and perform the appropriate action (turn on or off). | |
- Removed starting/stopping the timer when manually triggered. | |
## Version 1.7 (2024-09-18) | |
- Added a usage section for the user in Dutch and English. | |
## Version 1.6 (2024-09-17) | |
- Changed to select Fibaro devices instead of light entities. | |
- Added option to disable local operation on Fibaro devices while lights are on due to motion detection. | |
## Version 1.5 (2024-09-12) | |
- Introducing changelog. | |
</details> | |
domain: automation | |
source_url: https://gist.githubusercontent.com/QNimbus/7db1fad83b34d2be52ceebcbb3ec74a5/raw/blueprints---motion_light.yaml | |
input: | |
motion_sensors: | |
name: Motion Sensor(s) * | |
description: Select one or more motion sensors that will trigger the lights when motion is detected. | |
selector: | |
entity: | |
multiple: true | |
filter: | |
- domain: binary_sensor | |
device_class: motion | |
fibaro_devices: | |
name: Fibaro Device(s) * | |
description: | | |
Select one or more Fibaro devices to control. The lights associated with these devices will be turned on when motion is detected. | |
selector: | |
device: | |
multiple: true | |
filter: | |
- integration: zwave_js | |
manufacturer: Fibargroup | |
timer_entity: | |
name: Timer Helper * | |
description: Select the timer helper entity that will manage the duration for which the lights remain on. | |
selector: | |
entity: | |
domain: timer | |
sun_elevation: | |
name: Sun Elevation Offset * | |
description: Set the sun elevation offset value (between -10 and +10 degrees) at which the lights should turn on. For example, a value of 0 means the lights will turn on when the sun is below the horizon. | |
default: 0 | |
selector: | |
number: | |
min: -10.0 | |
max: 10.0 | |
step: 0.1 | |
unit_of_measurement: "°" | |
always_trigger: | |
name: Always Trigger | |
description: When enabled, the lights will turn on regardless of the sun's elevation when motion is detected. | |
default: false | |
selector: | |
boolean: | |
cooldown_delay: | |
name: Cooldown Period | |
description: Time in seconds to wait before re-triggering the lights after they have been manually turned off while the timer is still active. | |
default: 60 | |
selector: | |
number: | |
min: 30 | |
max: 3600 | |
step: 1 | |
unit_of_measurement: "sec" | |
disable_local_operation: | |
name: Disable Local Operation | |
description: > | |
When enabled, the automation will disable local control of the Fibaro devices while the lights are on due to motion detection. | |
default: false | |
selector: | |
boolean: | |
motion_brightness: | |
name: Motion-activated Brightness | |
description: Set the brightness level for lights when activated by motion (0-100%). | |
default: 20 | |
selector: | |
number: | |
min: 0 | |
max: 100 | |
step: 1 | |
unit_of_measurement: "%" | |
trigger_variables: | |
motion_sensors: !input motion_sensors | |
fibaro_devices: !input fibaro_devices | |
timer_entity: !input timer_entity | |
sun_elevation: !input sun_elevation | |
always_trigger: !input always_trigger | |
cooldown_delay: !input cooldown_delay | |
disable_local_operation: !input disable_local_operation | |
motion_brightness: !input motion_brightness | |
# Extract light entities from selected Fibaro devices | |
lights: >- | |
{%- set ns = namespace(lights=[]) -%} | |
{%- for device in fibaro_devices -%} | |
{%- for entity in device_entities(device) -%} | |
{%- if entity.startswith('light.') -%} | |
{%- set ns.lights = ns.lights + [entity] -%} | |
{%- endif -%} | |
{%- endfor -%} | |
{%- endfor -%} | |
{{ ns.lights }} | |
# Extract local operation entities | |
fibaro_entities_local_operation: >- | |
{%- set ns = namespace(fibaro_entities_local_operation=[]) -%} | |
{%- for device in fibaro_devices -%} | |
{%- for entity in device_entities(device) -%} | |
{%- if entity | regex_search("^select\\..*local.*$") -%} | |
{%- set ns.fibaro_entities_local_operation = ns.fibaro_entities_local_operation + [entity] -%} | |
{%- endif -%} | |
{%- endfor -%} | |
{%- endfor -%} | |
{{ ns.fibaro_entities_local_operation }} | |
variables: | |
sun_condition_met: "{{ always_trigger or (state_attr('sun.sun', 'elevation') | float < sun_elevation | float) }}" | |
timer_active: "{{ is_state(timer_entity, 'active') }}" | |
trigger: | |
- platform: state | |
entity_id: !input motion_sensors | |
to: "on" | |
id: "motion" | |
- platform: state | |
entity_id: !input timer_entity | |
from: "active" | |
to: "idle" | |
id: "timer_finished" | |
- platform: event | |
event_type: state_changed | |
id: "lights_off" | |
event_data: | |
entity_id: "{{ lights }}" | |
condition: | |
- condition: or | |
conditions: | |
- condition: template | |
value_template: "{{ sun_condition_met }}" | |
alias: "Sun below elevation or always trigger enabled" | |
- condition: trigger | |
id: "timer_finished" | |
alias: "Timer finished" | |
- condition: template | |
value_template: "{{ trigger.id == 'lights_off' and timer_active }}" | |
alias: "Lights turned off while timer active" | |
action: | |
- variables: | |
manually_triggered: "{{ 'idx' not in trigger }}" | |
light_states: "{% set entities = expand(lights) %}{{ entities | map(attribute='state') | list }}" | |
any_light_on: "{{ light_states | select('eq', 'on') | list | length > 0 }}" | |
any_light_off: "{{ light_states | select('eq', 'off') | list | length > 0 }}" | |
brightness: "{{ (motion_brightness | int if motion_brightness is not none else 100) / 100 * 255 | round | int }}" | |
- choose: | |
- conditions: | |
- condition: trigger | |
id: "motion" | |
- condition: template | |
value_template: "{{ any_light_off and not timer_active }}" | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: "{{ lights }}" | |
data: | |
brightness: "{{ brightness }}" | |
alias: "Turn on lights (motion detected) with set brightness" | |
- choose: | |
- conditions: "{{ disable_local_operation }}" | |
sequence: | |
- service: select.select_option | |
target: | |
entity_id: "{{ fibaro_entities_local_operation }}" | |
data: | |
option: "NoOperationPossible" | |
alias: "Disable local operation" | |
- service: timer.start | |
target: | |
entity_id: !input timer_entity | |
alias: "Start timer (motion detected)" | |
- conditions: | |
- condition: trigger | |
id: "motion" | |
- condition: template | |
value_template: "{{ timer_active }}" | |
sequence: | |
- service: timer.start | |
target: | |
entity_id: !input timer_entity | |
alias: "Restart timer (continued motion)" | |
- conditions: | |
- condition: trigger | |
id: timer_finished | |
sequence: | |
- choose: | |
- conditions: | |
- condition: state | |
entity_id: !input motion_sensors | |
state: "on" | |
match: any | |
sequence: | |
- service: timer.start | |
target: | |
entity_id: !input timer_entity | |
alias: "Restart timer (motion still detected)" | |
- conditions: | |
- condition: state | |
entity_id: !input motion_sensors | |
state: "off" | |
sequence: | |
- service: light.turn_off | |
target: | |
entity_id: "{{ lights }}" | |
alias: "Turn off lights (timer finished, no motion)" | |
- choose: | |
- conditions: "{{ disable_local_operation }}" | |
sequence: | |
- service: select.select_option | |
target: | |
entity_id: "{{ fibaro_entities_local_operation }}" | |
data: | |
option: "Unprotected" | |
alias: "Enable local operation" | |
- conditions: | |
- condition: trigger | |
id: "lights_off" | |
- condition: template | |
value_template: > | |
{{ | |
trigger.from_state.state == 'on' and | |
trigger.to_state.state == 'off' and | |
not any_light_on and | |
timer_active | |
}} | |
sequence: | |
- service: timer.cancel | |
target: | |
entity_id: !input timer_entity | |
alias: "Cancel timer when lights turned off manually" | |
- delay: "{{ cooldown_delay }}" | |
alias: "Cooldown delay after lights turned off" | |
- conditions: | |
- condition: template | |
value_template: "{{ manually_triggered }}" | |
alias: "Automation manually triggered" | |
sequence: | |
- service: light.toggle | |
target: | |
entity_id: "{{ lights }}" | |
alias: "Toggle lights (manual trigger)" | |
- choose: | |
- conditions: "{{ not any_light_on }}" | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: "{{ lights }}" | |
alias: "Turn on all lights" | |
- service: timer.start | |
target: | |
entity_id: !input timer_entity | |
alias: "Start timer" | |
- conditions: "{{ any_light_on }}" | |
sequence: | |
- service: light.turn_off | |
target: | |
entity_id: "{{ lights }}" | |
alias: "Turn off all lights" | |
- service: timer.cancel | |
target: | |
entity_id: !input timer_entity | |
alias: "Cancel timer" | |
mode: queued | |
max: 10 |
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: Philips Hue Control with Fibaro Dimmer | |
description: | | |
# Philips Hue Control with Fibaro Dimmer | |
**Version: 1.0.0** | |
Last updated: **2025-01-20** | |
This blueprint allows you to control Philips Hue lights using a Fibaro dimmer. It supports single click, double click, hold, and release actions to toggle lights, adjust brightness, and more. | |
**Requirements:** | |
- A Fibaro dimmer device | |
- Philips Hue lights | |
**Triggers:** | |
- Single click | |
- Double click | |
- Hold | |
- Release | |
domain: automation | |
input: | |
fibaro_dimmer_node_id: | |
name: Fibaro Dimmer Node ID | |
description: Enter the node ID of the Fibaro dimmer device. | |
selector: | |
number: | |
min: 1 | |
max: 255 | |
mode: box | |
hue_lights: | |
name: Philips Hue Lights | |
description: Select the Philips Hue lights to control. | |
selector: | |
entity: | |
domain: light | |
multiple: true | |
trigger: | |
- platform: event | |
event_type: zwave_js_value_notification | |
event_data: | |
domain: zwave_js | |
node_id: !input fibaro_dimmer_node_id | |
command_class: 43 | |
command_class_name: Scene Activation | |
property: sceneId | |
value: 26 | |
id: key_single_click | |
alias: "Single click on Fibaro dimmer" | |
- platform: event | |
event_type: zwave_js_value_notification | |
event_data: | |
domain: zwave_js | |
node_id: !input fibaro_dimmer_node_id | |
command_class: 43 | |
command_class_name: Scene Activation | |
property: sceneId | |
value: 24 | |
id: key_double_click | |
alias: "Double click on Fibaro dimmer" | |
- platform: event | |
event_type: zwave_js_value_notification | |
event_data: | |
domain: zwave_js | |
node_id: !input fibaro_dimmer_node_id | |
command_class: 43 | |
command_class_name: Scene Activation | |
property: sceneId | |
value: 22 | |
id: key_hold | |
alias: "Hold on Fibaro dimmer" | |
- platform: event | |
event_type: zwave_js_value_notification | |
event_data: | |
domain: zwave_js | |
node_id: !input fibaro_dimmer_node_id | |
command_class: 43 | |
command_class_name: Scene Activation | |
property: sceneId | |
value: 23 | |
id: key_release | |
alias: "Release on Fibaro dimmer" | |
action: | |
- choose: | |
- conditions: | |
- condition: trigger | |
id: key_single_click | |
sequence: | |
- service: light.toggle | |
target: | |
entity_id: !input hue_lights | |
alias: "Toggle Hue lights on single click" | |
- conditions: | |
- condition: trigger | |
id: key_double_click | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: !input hue_lights | |
data: | |
brightness_pct: 100 | |
alias: "Turn on Hue lights to full brightness on double click" | |
- conditions: | |
- condition: trigger | |
id: key_hold | |
sequence: | |
- repeat: | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: !input hue_lights | |
data: | |
brightness: > | |
{{ ([1, state_attr(trigger.entity_id, 'brightness') + 25, 255] | sort)[1] }} | |
- delay: | |
milliseconds: 500 | |
until: | |
- condition: template | |
value_template: "{{ repeat.index >= 10 }}" | |
alias: "Increase brightness on hold" | |
- conditions: | |
- condition: trigger | |
id: key_release | |
sequence: | |
- service: light.turn_off | |
target: | |
entity_id: !input hue_lights | |
alias: "Turn off Hue lights on release" | |
mode: restart | |
max_exceeded: silent |
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: NFC Tag Media Playback | |
description: | | |
# 🎶 NFC Tag Media Playback | |
Creates an automation that plays media content when a specific NFC tag is scanned. Currently supports playing | |
Spotify albums, but can be extended for other media types. | |
**Features:** | |
- Play Spotify albums on a selected media player when an NFC tag is scanned | |
- Configurable media player target | |
- Support for multiple NFC tags | |
**GitHub:** [Click Here](https://gist.githubusercontent.com/QNimbus/7db1fad83b34d2be52ceebcbb3ec74a5/raw/blueprints---tag_media_playback.yaml) | |
<details> | |
<summary><b>Changelog</b>- Click here to expand</summary> | |
## Version 1.0 (2024-12-15) | |
- Initial version. | |
- Added Changelog section. | |
</details> | |
domain: automation | |
source_url: https://gist.githubusercontent.com/QNimbus/7db1fad83b34d2be52ceebcbb3ec74a5/raw/804661230e8347942087007583598f8c44e23429/blueprints---tag_media_playback.yaml | |
input: | |
tag_id: | |
name: NFC Tag | |
description: Select the NFC tag that will trigger playback | |
selector: | |
device: | |
integration: tag | |
multiple: false | |
media_player: | |
name: Media Player | |
description: The media player that will play the content | |
selector: | |
entity: | |
domain: | |
- media_player | |
multiple: false | |
spotify_content_url: | |
name: Spotify Content URL | |
description: Paste a Spotify URL for an album, playlist, or artist (e.g., https://open.spotify.com/playlist/0TkCx0CUwRwYdnYhnQOADB?si=Awv6U5lpQ5KtCMiLv5fFZg) | |
selector: | |
text: {} | |
mode: single | |
trigger: | |
- platform: tag | |
tag_id: '{{ device_attr(tag_id, ''tag_id'') }}' | |
variables: | |
url_parts: "{% set url = spotify_content_url | regex_replace('\\\\?.*$', '') %} | |
{% if 'spotify.com/' in url %}\n {% set parts = url.split('/') %}\n {% set type | |
= parts[-2] %}\n {% set id = parts[-1] %}\n { \"type\": type, \"id\": id }\n{% | |
else %}\n { \"type\": \"unknown\", \"id\": \"\" }\n{% endif %}" | |
media_type: "{% set type_map = {\n 'album': 'album',\n 'playlist': 'playlist',\n | |
\ 'artist': 'artist'\n} %} {{ type_map[url_parts.type] | default('album') }}" | |
action: | |
- service: media_player.play_media | |
target: | |
entity_id: !input media_player | |
data: | |
media_content_id: spotify:{{ url_parts.type }}:{{ url_parts.id }} | |
media_content_type: '{{ media_type }}' |
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
# ------------------------------------------------------------- | |
# Home Assistant Automation Template for Room/Floor Light Count | |
# ------------------------------------------------------------- | |
# | |
# Purpose: | |
# This template dynamically generates a Home Assistant YAML sensor configuration that: | |
# - Counts how many light entities are currently "on" in a specific room or floor. | |
# - Excludes "Helper"-labeled or hidden entities, unless customization is needed. | |
# - Provides both a manually adjustable name for the sensor (via `entity_name`) | |
# and an auto-generated unique ID (if `entity_name` is not set). | |
# | |
# Usage: | |
# 1. Open Home Assistant Developer Tools > Template Editor to test this template. | |
# 2. Set `room_name` or `floor_name` to define the area to scan for light entities. | |
# - `room_name` filters for a specific room. | |
# - `floor_name` filters for all entities across multiple areas on that floor. | |
# 3. Customize `entity_name` (e.g., 'kitchen', 'living_room') if you want a specific | |
# sensor name; otherwise, the sensor name defaults to the `room_name` or `floor_name`. | |
# 4. Use the generated YAML in `configuration.yaml` or another automation file. | |
# | |
# Key Variables and Functions: | |
# - `room_name` / `floor_name`: Define the area or floor to scan. | |
# - `entity_name`: Optional. Custom name for the sensor; defaults to the room or floor name. | |
# - `all_light_entities`: List of all "light" entities in the system. | |
# - `filtered_light_entities`: Final list of "light" entities in the specified room or floor, | |
# excluding hidden entities and "Helper"-labeled entities. | |
# - `random_guid()`: Generates a unique identifier for the sensor using a pseudo-random | |
# GUID format. | |
# | |
# When to Use: | |
# - When you want a sensor that dynamically counts lights "on" in a room or floor. | |
# - To avoid manually updating entity lists in automations every time a light is added or removed. | |
# - To simplify and maintain light-counting logic in one reusable template. | |
# | |
# ------------------------------------------------------------- | |
# -------- THE TEMPLATE CODE ---------------------------------- | |
# | |
# {% set entity_name = 'Kitchen' %} | |
# {% set room_name = 'Keuken' %} | |
# {% set floor_name = 'Begane grond' if not room_name else None %} | |
# {% set all_light_entities = states.light | map(attribute='entity_id') | list %} | |
# {% set helper_entities = label_entities('Helper') | default([]) %} | |
# {# Macro to generate a random string #} | |
# {% macro random_string(len) -%}{% for i in range(0,len) -%}{{ [0,1,2,3,4,5,6,7,8,9,"a","b","c","d","e","f"]|random }}{% endfor %}{%- endmacro -%} | |
# {# Macro to generate a random GUID #} | |
# {% macro random_guid() -%} {{ random_string(8) + "-" + random_string(4) + "-" + random_string(4) + "-" + random_string(4) + "-" + random_string(12) }}{%- endmacro -%} | |
# {% set poormansguid = random_guid() %} | |
# {# Set entity_name to room_name or floor_name if it's empty #} | |
# {% set entity_name = entity_name if entity_name else (room_name if room_name else floor_name) | lower | slugify %} | |
# {# Get entities based on whether room_name or floor_name is defined #} | |
# {% if room_name %} | |
# {# Get entities for the specific room #} | |
# {% set room_entities = area_entities(room_name) | list %} | |
# {% set target_entities = room_entities %} | |
# {% elif floor_name %} | |
# {# Get entities for all areas on the specified floor #} | |
# {% set floor_areas_list = floor_areas(floor_name) | default([]) %} | |
# {% set floor_entities = floor_areas_list | map('area_entities') | map('default', []) | sum(start=[]) | list %} | |
# {% set target_entities = floor_entities %} | |
# {% else %} | |
# {% set target_entities = [] %} | |
# {% endif %} | |
# {# Filter target entities for lights only, excluding helpers and hidden entities, and sort #} | |
# {% set filtered_light_entities = target_entities | |
# | select('in', all_light_entities) | |
# | reject('in', helper_entities) | |
# | reject('is_hidden_entity') | |
# | list | sort %} | |
# Entities in {{ room_name if room_name else floor_name }} (Total: {{ filtered_light_entities | length }}): | |
# {# Intentionally leave a blank line above #} | |
# {%- for entity in filtered_light_entities %} | |
# - {{ entity }} | |
# {%- endfor %} | |
# Generated YAML Sensor Configuration: | |
# - trigger: | |
# - platform: state | |
# entity_id: | |
# {%- for entity in filtered_light_entities %} | |
# - {{ entity }} | |
# {%- endfor %} | |
# sensor: | |
# - name: "{{ entity_name }}_lights_on_count" | |
# unique_id: {{ poormansguid }} | |
# icon: mdi:lightbulb-multiple-outline | |
# state: > | |
# {% raw %}{% set lights = [{% endraw %} | |
# '{{ filtered_light_entities | map('string') | join("',\n '") }}' | |
# {% raw %}] %}{% endraw %} | |
# {% raw %}{{ lights | select('in', states.light | selectattr('state', 'eq', 'on') | map(attribute='entity_id') | list) | list | length }}{% endraw %} | |
# availability: > | |
# {% raw %}{% set lights = [{% endraw %} | |
# '{{ filtered_light_entities | map('string') | join("',\n '") }}' | |
# {% raw %}] %}{% endraw %} | |
# {% raw %}{{ lights | select('in', states.light | map(attribute='entity_id') | list) | list | length >= 0 }}{% endraw %} | |
# | |
# -------- END OF THE TEMPLATE CODE --------------------------- | |
- trigger: | |
- platform: state | |
entity_id: | |
- light.kitchen_dimmer_areaspotlights | |
- light.kitchen_dimmer_diningtable | |
- light.kitchen_dimmer_rail_hanglamps | |
- light.kitchen_dimmer_rail_spotlights | |
- light.kitchen_dimmer_sinkcounter_spotlights_high | |
- light.kitchen_dimmer_sinkcounter_spotlights_low | |
- light.kitchen_dimmer_walllamps | |
sensor: | |
- name: "kitchen_lights_on_count" | |
unique_id: 56f60699-116a-d7f2-bf76-285438ce6e46 | |
icon: mdi:lightbulb-multiple-outline | |
state: > | |
{% set lights = [ | |
'light.kitchen_dimmer_areaspotlights', | |
'light.kitchen_dimmer_diningtable', | |
'light.kitchen_dimmer_rail_hanglamps', | |
'light.kitchen_dimmer_rail_spotlights', | |
'light.kitchen_dimmer_sinkcounter_spotlights_high', | |
'light.kitchen_dimmer_sinkcounter_spotlights_low', | |
'light.kitchen_dimmer_walllamps' | |
] %} | |
{{ lights | select('in', states.light | selectattr('state', 'eq', 'on') | map(attribute='entity_id') | list) | list | length }} | |
availability: > | |
{% set lights = [ | |
'light.kitchen_dimmer_areaspotlights', | |
'light.kitchen_dimmer_diningtable', | |
'light.kitchen_dimmer_rail_hanglamps', | |
'light.kitchen_dimmer_rail_spotlights', | |
'light.kitchen_dimmer_sinkcounter_spotlights_high', | |
'light.kitchen_dimmer_sinkcounter_spotlights_low', | |
'light.kitchen_dimmer_walllamps' | |
] %} | |
{{ lights | select('in', states.light | selectattr('state', 'eq', 'on') | map(attribute='entity_id') | list) | list | length >= 0 }} |
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
# ------------------------------------------------------------- | |
# Home Assistant Automation Template for Room/Floor Shutter Count | |
# ------------------------------------------------------------- | |
# | |
# Purpose: | |
# This template dynamically generates a Home Assistant YAML sensor configuration that: | |
# - Counts how many roller shutters (`cover.*`) in a specified room or floor are *not fully open* | |
# (i.e., `current_position` attribute is less than 100). | |
# - Excludes "Helper"-labeled or hidden entities from the count, unless customization is needed. | |
# - Provides an option to set a specific sensor name with the `entity_name` variable; if left | |
# empty, the name defaults to the `room_name` or `floor_name` provided. | |
# | |
# Usage: | |
# 1. Open Home Assistant Developer Tools > Template Editor to test this template. | |
# 2. Set `room_name` or `floor_name` to specify the area for counting shutter entities. | |
# - `room_name`: Counts shutters in a specific room. | |
# - `floor_name`: Counts shutters across multiple rooms on a specific floor. | |
# 3. Customize `entity_name` (e.g., 'living', 'bedroom') if you want a specific name for the sensor. | |
# - If `entity_name` is not set or is left empty, the sensor name defaults to the room or floor name. | |
# 4. Copy the generated YAML into `configuration.yaml` or another automation file for Home Assistant. | |
# | |
# Key Variables and Functions: | |
# - `room_name` / `floor_name`: Define the area or floor to scan for shutters. | |
# - `entity_name`: Optional. Custom name for the sensor; defaults to the room or floor name. | |
# - `all_cover_entities`: List of all "cover" entities in the system. | |
# - `filtered_cover_entities`: Final list of cover entities in the specified room or floor, | |
# excluding hidden entities and "Helper"-labeled entities. | |
# - `random_guid()`: Generates a unique identifier for the sensor using a pseudo-random | |
# GUID format. | |
# | |
# When to Use: | |
# - Use this template when you need a sensor to dynamically count shutters that are not fully open | |
# in a room or floor. | |
# - Helps simplify automations, especially if the number of shutters changes over time or if they | |
# are managed as part of broader automations in Home Assistant. | |
# | |
# -------- THE TEMPLATE CODE ---------------------------------- | |
# | |
# {% set entity_name = 'living' %} | |
# {% set room_name = 'Woonkamer' %} | |
# {% set floor_name = 'Begane grond' if not room_name else None %} | |
# {% set all_cover_entities = states.cover | map(attribute='entity_id') | list %} | |
# {% set helper_entities = label_entities('Helper') | default([]) %} | |
# {# Macro to generate a random string #} | |
# {% macro random_string(len) -%}{% for i in range(0,len) -%}{{ [0,1,2,3,4,5,6,7,8,9,"a","b","c","d","e","f"]|random }}{% endfor %}{%- endmacro -%} | |
# {# Macro to generate a random GUID #} | |
# {% macro random_guid() -%} {{ random_string(8) + "-" + random_string(4) + "-" + random_string(4) + "-" + random_string(4) + "-" + random_string(12) }}{%- endmacro -%} | |
# {% set poormansguid = random_guid() %} | |
# {# Set entity_name to room_name or floor_name if it's empty #} | |
# {% set entity_name = entity_name if entity_name else (room_name if room_name else floor_name) | lower | slugify %} | |
# {# Get entities based on whether room_name or floor_name is defined #} | |
# {% if room_name %} | |
# {# Get entities for the specific room #} | |
# {% set room_entities = area_entities(room_name) | list %} | |
# {% set target_entities = room_entities %} | |
# {% elif floor_name %} | |
# {# Get entities for all areas on the specified floor #} | |
# {% set floor_areas_list = floor_areas(floor_name) | default([]) %} | |
# {% set floor_entities = floor_areas_list | map('area_entities') | map('default', []) | sum(start=[]) | list %} | |
# {% set target_entities = floor_entities %} | |
# {% else %} | |
# {% set target_entities = [] %} | |
# {% endif %} | |
# {# Filter target entities for covers only, excluding helpers and hidden entities, and sort #} | |
# {% set filtered_cover_entities = target_entities | |
# | select('in', all_cover_entities) | |
# | reject('in', helper_entities) | |
# | reject('is_hidden_entity') | |
# | list | sort %} | |
# Entities in {{ room_name if room_name else floor_name }} (Total: {{ filtered_cover_entities | length }}): | |
# {# Intentionally leave a blank line above #} | |
# {%- for entity in filtered_cover_entities %} | |
# - {{ entity }} | |
# {%- endfor %} | |
# Generated YAML Sensor Configuration: | |
# - trigger: | |
# - platform: state | |
# entity_id: | |
# {%- for entity in filtered_cover_entities %} | |
# - {{ entity }} | |
# {%- endfor %} | |
# sensor: | |
# - name: "{{ entity_name }}_shutters_not_open_count" | |
# unique_id: {{ poormansguid }} | |
# icon: mdi:window-shutter | |
# state: > | |
# {% raw %}{% set shutters = [{% endraw %} | |
# '{{ filtered_cover_entities | map('string') | join("',\n '") }}' | |
# {% raw %}] %}{% endraw %} | |
# {% raw %}{{ shutters | select('in', states.cover | selectattr('attributes.current_position', 'lt', 100) | map(attribute='entity_id') | list) | list | length }}{% endraw %} | |
# availability: > | |
# {% raw %}{% set shutters = [{% endraw %} | |
# '{{ filtered_cover_entities | map('string') | join("',\n '") }}' | |
# {% raw %}] %}{% endraw %} | |
# {% raw %}{{ shutters | select('in', states.cover | map(attribute='entity_id') | list) | list | length >= 0 }}{% endraw %} | |
# | |
# -------- END OF THE TEMPLATE CODE --------------------------- | |
- trigger: | |
- platform: state | |
entity_id: | |
- cover.homekit_living_cover_center | |
- cover.homekit_living_cover_left | |
- cover.homekit_living_cover_right | |
sensor: | |
- name: "living_shutters_not_open_count" | |
unique_id: 0ae36ecd-ce07-5f90-b6ba-06f6b97093d3 | |
icon: mdi:window-shutter | |
state: > | |
{% set shutters = [ | |
'cover.homekit_living_cover_center', | |
'cover.homekit_living_cover_left', | |
'cover.homekit_living_cover_right' | |
] %} | |
{{ shutters | select('in', states.cover | selectattr('attributes.current_position', 'lt', 100) | map(attribute='entity_id') | list) | list | length }} | |
availability: > | |
{% set shutters = [ | |
'cover.homekit_living_cover_center', | |
'cover.homekit_living_cover_left', | |
'cover.homekit_living_cover_right' | |
] %} | |
{{ shutters | select('in', states.cover | map(attribute='entity_id') | list) | list | length >= 0 }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment