initial commit

This commit is contained in:
2022-12-20 21:26:47 +01:00
commit 2962a6db69
722 changed files with 63886 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
blueprint:
name: Lights On At Sunset
description: Turn on the following lights at sunset
domain: automation
input:
target_light:
name: Lights
description: This is the light (or lights) that will be activated at sunset
selector:
target:
entity:
domain: light
target_brightness:
name: Brightness
description: Brightness of the light(s) when they're activated
default: 50
selector:
number:
min: 5.0
max: 100.0
mode: slider
step: 5.0
unit_of_measurement: '%'
elevation_shift:
name: Elevation Shift
description: Using an elevation offset (height of sun relative to the horizon)
to shift the sunset trigger, either earlier or later. Positive values bring
the automation start time forward, whilst negative values delay the start
time. To approximate Golden Hour - set the Elevation Offset to 1.
default: 0.0
selector:
number:
min: -3.0
max: 3.0
mode: slider
step: 1.0
source_url: https://gist.github.com/CyanAutomation/1b8bafd033f73e3c24e42e8f381ff906
mode: single
variables:
target_brightness: !input target_brightness
target_light: !input target_light
trigger:
platform: numeric_state
entity_id: sun.sun
attribute: elevation
below: !input elevation_shift
condition:
condition: sun
after: sunrise
after_offset: 01:00:00
action:
- service: light.turn_on
target: !input target_light
data_template:
brightness_pct: '{{ target_brightness | int }}'

View File

@@ -0,0 +1,183 @@
blueprint:
name: Turn on light, switch, scene, script or group based on motion and illuminance.
description: "Turn on a light, switch, scene, script or group based on motion detection,\
\ and low light level.\nThis blueprint uses helper entities you have to create\
\ yourself for some input values, to be able to dynamically set limits. For instructions\
\ on creating the helper entities take a look in the Home Assistant Community\
\ forum topic: https://community.home-assistant.io/t/turn-on-light-switch-scene-or-script-based-on-motion-and-illuminance-more-conditions/257085\n\
\nRequired entities:\n - Motion sensor (single sensor or group)\n - Target entity\
\ (light, switch, scene or script)\n\n\nOptional features:\n- You can set a cutoff\
\ entity of which the value determines whether the illuminance level is low and\
\ the automation needs to trigger.\n- You can define a blocking entity, which\
\ blocks the automation from running when this entity's state is on.\n- You van\
\ define a turn-off blocking entity, which blocks the entity from turning off\
\ after the set delay.\n- Time limits can also be defined to limit the time before\
\ and after the automation should trigger.\n- If you want the entity to turn off\
\ after a certain amount of minutes, you can use the Wait Time input.\n- If you\
\ want another entity than the target_entity to turn off after the delay, you\
\ can define a separate Turn-off entity.\n- If you do not enable the optional\
\ entities the automation will skip these conditions.\n\n\nOptional entities:\n\
- Illuminance sensor (sensor in illuminance class)\n- Illuminance cutoff value\
\ (input_number)\n- Blocking entity (any entity with state on/off)\n- Time limit\
\ before (input_datetime)\n- Time limit after (input_datetime)\n- Turn off wait\
\ time (input_number defining amount in minutes)\n- Turn off entity (any entity_id\
\ that needs to be turned off after wait)\n"
domain: automation
input:
motion_sensor:
name: Motion Sensor
description: This sensor will trigger the turning on of the target entity.
selector:
entity: {}
target_entity:
name: Target entity.
description: The light, switch, scene to turn on (or script to run) when the
automation is triggered.
selector:
entity: {}
illuminance_sensor:
name: (OPTIONAL) Illuminance sensor
description: This sensor will be used to determine the illumination.
default:
selector:
entity:
domain: sensor
device_class: illuminance
multiple: false
illuminance_cutoff:
name: (OPTIONAL) Illuminance cutoff value
description: This input_number will be used to compare to the current illumination
to determine if it is low.
default:
selector:
entity:
domain: input_number
multiple: false
blocker_entity:
name: (OPTIONAL) Blocking entity
description: If this entity's state is on, it will prevent the automation from
running. E.g. sleepmode or away mode.
default:
selector:
entity: {}
time_limit_after:
name: (OPTIONAL) Only run after time.
description: Automation will only run when time is later than this input_datetime
value.
default:
selector:
entity:
domain: input_datetime
multiple: false
time_limit_before:
name: (OPTIONAL) Only run before time.
description: Automation will only run when time is earlier than this input_datetime
value.
default:
selector:
entity:
domain: input_datetime
multiple: false
no_motion_wait:
name: (OPTIONAL) Turn off wait time (minutes)
description: Time in minutes to leave the target entity on after last motion
is detected. If not used entity will not auto turn off.
default:
selector:
entity:
domain: input_number
multiple: false
turn_off_blocker_entity:
name: (OPTIONAL) Turn-off Blocking entity
description: If this entity's state is on, it will prevent the target entity
from turning off after the set delay.
default:
selector:
entity: {}
target_off_entity:
name: (OPTIONAL) Turn-off entity
description: If defined, this entity will be turned off instead of the default
target entity. This can be helpful when using target entities of type scene
or script.
default:
selector:
entity: {}
source_url: https://gist.github.com/freakshock88/2311759ba64f929f6affad4c0a67110b
mode: restart
max_exceeded: silent
variables:
target_entity: !input 'target_entity'
illuminance_currently: !input 'illuminance_sensor'
illuminance_cutoff: !input 'illuminance_cutoff'
blocker_entity: !input 'blocker_entity'
time_limit_before: !input 'time_limit_before'
time_limit_after: !input 'time_limit_after'
no_motion_wait: !input 'no_motion_wait'
entity_domain: '{{ states[target_entity].domain }}'
turn_off_blocker_entity: !input 'turn_off_blocker_entity'
target_off_entity: !input 'target_off_entity'
trigger:
platform: state
entity_id: !input 'motion_sensor'
to: 'on'
condition:
- condition: template
value_template: '{% set illuminance_defined = illuminance_currently != none and
illuminance_cutoff != none %} {% set illuminance_defined_and_low = (illuminance_defined
and (states(illuminance_currently) | int(0) < states(illuminance_cutoff) | int(0))) %}
{% set target_entity_domain_supports_on_state_check = entity_domain != ''scene''
and entity_domain != ''script'' %} {{ ( target_entity_domain_supports_on_state_check
and states(target_entity) == ''on'') or ( target_entity_domain_supports_on_state_check
and states(target_entity) == ''off'' and not illuminance_defined) or ( target_entity_domain_supports_on_state_check
and states(target_entity) == ''off'' and illuminance_defined_and_low) or ( not
target_entity_domain_supports_on_state_check and illuminance_defined_and_low)
or ( not target_entity_domain_supports_on_state_check and not illuminance_defined)
}}
'
- condition: template
value_template: '{{ (blocker_entity == none) or (states(blocker_entity) == ''off'')
}}'
- condition: template
value_template: "{% set current_time = now().strftime(\"%H:%M\") %}\n{% if time_limit_before\
\ == none and time_limit_after == none %} true {% endif %}\n{% if time_limit_before\
\ != none and time_limit_after == none %} {% set current_time_is_before_limit\
\ = current_time < states(time_limit_before) %} {{ current_time_is_before_limit\
\ }} {% elif time_limit_before == none and time_limit_after != none %} {% set\
\ current_time_is_after_limit = current_time > states(time_limit_after) %} {{\
\ current_time_is_after_limit }} {% endif %}\n{% if time_limit_before != none\
\ and time_limit_after != none %} {% set before_limit_is_tomorrow = states(time_limit_before)\
\ < states(time_limit_after) %} {% set current_time_is_before_limit = current_time\
\ < states(time_limit_before) %} {% set current_time_is_after_limit = current_time\
\ > states(time_limit_after) %} {% set time_window_spans_midnight = states(time_limit_after)\
\ > states(time_limit_before) %}\n {% if time_window_spans_midnight != none\
\ and time_window_spans_midnight and before_limit_is_tomorrow %}\n {{ current_time_is_after_limit\
\ or current_time_is_before_limit }}\n {% elif time_window_spans_midnight !=\
\ none and not time_window_spans_midnight %}\n {{ current_time_is_before_limit\
\ and current_time_is_after_limit }}\n {% endif %}\n{% endif %}\n"
action:
- service: homeassistant.turn_on
entity_id: !input 'target_entity'
- condition: template
value_template: '{{ no_motion_wait != none }}'
- wait_for_trigger:
platform: state
entity_id: !input 'motion_sensor'
from: 'on'
to: 'off'
- delay:
minutes: '{{ states(no_motion_wait) | int(0) }}'
- condition: template
value_template: '{{ (turn_off_blocker_entity == none) or (states(turn_off_blocker_entity)
== ''off'') }}'
- choose:
- conditions:
- condition: template
value_template: '{{ (target_off_entity != none) }}'
sequence:
- service: homeassistant.turn_off
entity_id: !input 'target_off_entity'
default:
- service: homeassistant.turn_off
entity_id: !input 'target_entity'

View File

@@ -0,0 +1,54 @@
blueprint:
name: Motion-activated Light
description: Turn on a light when motion is detected.
domain: automation
source_url: https://github.com/home-assistant/core/blob/dev/homeassistant/components/automation/blueprints/motion_light.yaml
input:
motion_entity:
name: Motion Sensor
selector:
entity:
domain: binary_sensor
device_class: motion
light_target:
name: Light
selector:
target:
entity:
domain: light
no_motion_wait:
name: Wait time
description: Time to leave the light on after last motion is detected.
default: 120
selector:
number:
min: 0
max: 3600
unit_of_measurement: seconds
# If motion is detected within the delay,
# we restart the script.
mode: restart
max_exceeded: silent
trigger:
platform: state
entity_id: !input motion_entity
from: "off"
to: "on"
action:
- alias: "Turn on the light"
service: light.turn_on
target: !input light_target
- alias: "Wait until there is no motion from device"
wait_for_trigger:
platform: state
entity_id: !input motion_entity
from: "on"
to: "off"
- alias: "Wait the number of seconds that has been set"
delay: !input no_motion_wait
- alias: "Turn off the light"
service: light.turn_off
target: !input light_target

View File

@@ -0,0 +1,46 @@
blueprint:
name: Zone Notification
description: Send a notification to a device when a person leaves a specific zone.
domain: automation
source_url: https://github.com/home-assistant/core/blob/dev/homeassistant/components/automation/blueprints/notify_leaving_zone.yaml
input:
person_entity:
name: Person
selector:
entity:
domain: person
zone_entity:
name: Zone
selector:
entity:
domain: zone
notify_device:
name: Device to notify
description: Device needs to run the official Home Assistant app to receive notifications.
selector:
device:
integration: mobile_app
trigger:
platform: state
entity_id: !input person_entity
variables:
zone_entity: !input zone_entity
# This is the state of the person when it's in this zone.
zone_state: "{{ states[zone_entity].name }}"
person_entity: !input person_entity
person_name: "{{ states[person_entity].name }}"
condition:
condition: template
# The first case handles leaving the Home zone which has a special state when zoning called 'home'.
# The second case handles leaving all other zones.
value_template: "{{ zone_entity == 'zone.home' and trigger.from_state.state == 'home' and trigger.to_state.state != 'home' or trigger.from_state.state == zone_state and trigger.to_state.state != zone_state }}"
action:
- alias: "Notify that a person has left the zone"
domain: mobile_app
type: notify
device_id: !input notify_device
message: "{{ person_name }} has left {{ zone_state }}"

View File

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

View File

@@ -0,0 +1,260 @@
blueprint:
name: Yet Another Motion Automation
description: "# YAMA V10\n\nTurn on lights or scenes when motion is detected. \n\
Four different scenes can be defined depending on time of day.\n\nFor Details\
\ see this forum post:\nhttps://community.home-assistant.io/t/yama-yet-another-motion-automation-scenes-ambient-light-and-some-conditions/257062?u=networkingcat\n\
\nCapabilitys:\n\n - Trigger on motion (in fact can be triggered by anything that\
\ switches between “on” and off\")\n - Wait time for turning off\n - Only run\
\ if entity is in desired state (optional)\n - Sun elevation check (optional)\n\
\ - 4 Scenes for different times of day (optional)\n - Ambient support with time\
\ frame (optional)\n - Default scene when motion stops (optional)\n - “no motion\
\ blocker” with user choosable state (optional)\n"
domain: automation
source_url: https://gist.github.com/networkingcat/a1876d7e706e07c8bdcf974113940fb8
input:
motion_entity:
name: Motion Sensor
description: Motion Sensor or a group with Motion Sensors (But can be anything
switching between "on" and "off")
selector:
entity: {}
light_target:
name: Light
selector:
target:
entity:
domain: light
no_motion_wait:
name: Wait time
description: Time to leave the light on after last motion is detected.
default: 120
selector:
number:
min: 0.0
max: 3600.0
unit_of_measurement: seconds
mode: slider
step: 1.0
automation_blocker:
name: Automation Blocker (Optional)
description: Only run if this boolean is in desired state (see next input)
default:
selector:
entity: {}
automation_blocker_boolean:
name: Automation Blocker Chooser (Optional)
description: Desired state of automation blocker, choose on for on and off for
off
default: false
selector:
boolean: {}
no_motion_blocker:
name: No Motion Blocker (Optional)
description: No motion sequence is not run if this boolean is in desired state
(see next input)
default:
selector:
entity: {}
no_motion_blocker_boolean:
name: No Motion Chooser (Optional)
description: Desired state of no motion blocker, choose on for on and off for
off
default: false
selector:
boolean: {}
elevation_check:
name: Sun elevation check (Optional)
description: This is the angle between the sun and the horizon. Negative values
mean the sun is BELOW the horizon.
default: none
selector:
number:
min: -90.0
max: 90.0
unit_of_measurement: degrees
mode: slider
step: 1.0
scene_ambient:
name: Ambient Scene (Optional)
description: Scene for ambient state. Will be activated when no motion is detected.
default: scene.none
selector:
entity:
domain: scene
multiple: false
time_scene_ambient_start:
name: Ambient time frame start (Optional)
description: Time from which on ambient scene will be activated
default: 00:00:00
selector:
time: {}
time_scene_ambient_end:
name: Ambient time frame end (Optional)
description: Time from which on ambient scene will be not activated
default: 00:00:00
selector:
time: {}
scene_morning:
name: Scene for the morning (Optional)
default: scene.none
selector:
entity:
domain: scene
multiple: false
time_scene_morning:
name: Time for the morning scene (Optional)
description: A time input which defines the time from which on the scene will
be activated if motion is detected.
default: 00:00:00
selector:
time: {}
scene_day:
name: Scene for the bright day (Optional)
default: scene.none
selector:
entity:
domain: scene
multiple: false
time_scene_day:
name: Time for the day scene (Optional)
description: A time input which defines the time from which on the scene will
be activated if motion is detected.
default: 00:00:00
selector:
time: {}
scene_evening:
name: Scene for the evening (Optional)
default: scene.none
selector:
entity:
domain: scene
multiple: false
time_scene_evening:
name: Time for the evening scene (Optional)
description: A time input which defines the time from which on the scene will
be activated if motion is detected.
default: 00:00:00
selector:
time: {}
scene_night:
name: Scene for the dark night (Optional)
default: scene.none
selector:
entity:
domain: scene
multiple: false
time_scene_night:
name: Time for the night scene (Optional)
description: A time input which defines the time from which on the scene will
be activated if motion is detectedd.
default: 00:00:00
selector:
time: {}
scene_no_motion:
name: Default scene for no motion (Optional)
description: Set this Scene if you want to activate a scene if motion stops
default: scene.none
selector:
entity:
domain: scene
multiple: false
mode: restart
max_exceeded: silent
variables:
scene_ambient: !input 'scene_ambient'
scene_morning: !input 'scene_morning'
scene_day: !input 'scene_day'
scene_evening: !input 'scene_evening'
scene_night: !input 'scene_night'
automation_blocker: !input 'automation_blocker'
automation_blocker_boolean: !input 'automation_blocker_boolean'
no_motion_blocker: !input 'no_motion_blocker'
no_motion_blocker_boolean: !input 'no_motion_blocker_boolean'
elevation_check: !input 'elevation_check'
scene_no_motion: !input 'scene_no_motion'
motion_entity: !input 'motion_entity'
trigger:
- platform: state
entity_id: !input 'motion_entity'
from: 'off'
to: 'on'
- platform: state
entity_id: !input 'motion_entity'
from: 'on'
to: 'off'
for: !input 'no_motion_wait'
condition:
- condition: or
conditions:
- '{{ automation_blocker == none }}'
- '{{ automation_blocker_boolean and states[automation_blocker].state == ''on''
}}'
- '{{ not automation_blocker_boolean and states[automation_blocker].state == ''off''
}}'
- condition: template
value_template: '{{ (elevation_check == none) or (state_attr(''sun.sun'',''elevation'')
<= elevation_check | float(90)) }}'
action:
- choose:
- conditions:
- condition: template
value_template: '{{ trigger.to_state.state == ''on'' }}'
sequence:
- choose:
- conditions:
- '{{ scene_morning != ''scene.none''}}'
- condition: time
after: !input 'time_scene_morning'
before: !input 'time_scene_day'
sequence:
- scene: !input 'scene_morning'
- conditions:
- '{{ scene_day != ''scene.none''}}'
- condition: time
after: !input 'time_scene_day'
before: !input 'time_scene_evening'
sequence:
- scene: !input 'scene_day'
- conditions:
- '{{ scene_evening != ''scene.none''}}'
- condition: time
after: !input 'time_scene_evening'
before: !input 'time_scene_night'
sequence:
- scene: !input 'scene_evening'
- conditions:
- '{{ scene_night != ''scene.none''}}'
- condition: time
after: !input 'time_scene_night'
before: !input 'time_scene_morning'
sequence:
- scene: !input 'scene_night'
default:
- service: light.turn_on
target: !input 'light_target'
- conditions:
- condition: template
value_template: '{{ trigger.to_state.state == ''off'' }}'
- condition: or
conditions:
- '{{ no_motion_blocker == none }}'
- '{{ no_motion_blocker_boolean and states[no_motion_blocker].state == ''on''
}}'
- '{{ not no_motion_blocker_boolean and states[no_motion_blocker].state == ''off''
}}'
sequence:
- choose:
- conditions:
- '{{ scene_ambient != ''scene.none'' }}'
- condition: time
after: !input 'time_scene_ambient_start'
before: !input 'time_scene_ambient_end'
sequence:
- scene: !input 'scene_ambient'
- conditions:
- '{{ scene_no_motion != ''scene.none'' }}'
sequence:
- scene: !input 'scene_no_motion'
default:
- service: light.turn_off
target: !input 'light_target'

View File

@@ -0,0 +1,20 @@
blueprint:
name: Restore Samba Backup sensor on startup
description: Restore Samba Backup sensor on startup
domain: automation
input:
addon:
name: Samba Backup Addon
description: Select samba backup addon.
selector:
addon: {}
source_url: https://github.com/thomasmauerer/hassio-addons/blob/master/samba-backup/blueprints/restore_samba_backup_sensor.yaml
mode: single
trigger:
- event: start
platform: homeassistant
action:
- service: hassio.addon_stdin
data:
addon: !input addon
input: restore-sensor