kevin 修订了这个 Gist . 转到此修订
1 file changed, 21 deletions
YAMA.yaml
| @@ -26,22 +26,6 @@ blueprint: | |||
| 26 | 26 | entity: | |
| 27 | 27 | - domain: | |
| 28 | 28 | - light | |
| 29 | - | luminance_sensor: | |
| 30 | - | name: Lux Sensor | |
| 31 | - | description: Lux Sensor | |
| 32 | - | selector: | |
| 33 | - | entity: | |
| 34 | - | luminance_required: | |
| 35 | - | name: Required Lux Level | |
| 36 | - | description: Lux level below which the automation will run. | |
| 37 | - | default: 100 | |
| 38 | - | selector: | |
| 39 | - | number: | |
| 40 | - | min: 0.0 | |
| 41 | - | max: 10000.0 | |
| 42 | - | unit_of_measurement: lx | |
| 43 | - | step: 1.0 | |
| 44 | - | mode: slider | |
| 45 | 29 | no_motion_wait: | |
| 46 | 30 | name: Wait time | |
| 47 | 31 | description: Time to leave the light on after last motion is detected. | |
| @@ -197,8 +181,6 @@ variables: | |||
| 197 | 181 | elevation_check: !input elevation_check | |
| 198 | 182 | scene_no_motion: !input scene_no_motion | |
| 199 | 183 | motion_entity: !input motion_entity | |
| 200 | - | luminance_sensor: !input luminance_sensor | |
| 201 | - | luminance_required: !input luminance_required | |
| 202 | 184 | trigger: | |
| 203 | 185 | - platform: state | |
| 204 | 186 | entity_id: !input motion_entity | |
| @@ -226,9 +208,6 @@ action: | |||
| 226 | 208 | - conditions: | |
| 227 | 209 | - condition: template | |
| 228 | 210 | value_template: '{{ trigger.to_state.state == ''on'' }}' | |
| 229 | - | - condition: numeric_state | |
| 230 | - | entity_id: !input luminance_sensor | |
| 231 | - | below: !input luminance_required | |
| 232 | 211 | sequence: | |
| 233 | 212 | - choose: | |
| 234 | 213 | - conditions: | |
kevin 修订了这个 Gist . 转到此修订
1 file changed, 2 insertions, 4 deletions
YAMA.yaml
| @@ -27,12 +27,10 @@ blueprint: | |||
| 27 | 27 | - domain: | |
| 28 | 28 | - light | |
| 29 | 29 | luminance_sensor: | |
| 30 | - | name: Illuminance sensor | |
| 31 | - | description: This sensor will be used to determine the illumination. | |
| 32 | - | default: | |
| 30 | + | name: Lux Sensor | |
| 31 | + | description: Lux Sensor | |
| 33 | 32 | selector: | |
| 34 | 33 | entity: | |
| 35 | - | multiple: true | |
| 36 | 34 | luminance_required: | |
| 37 | 35 | name: Required Lux Level | |
| 38 | 36 | description: Lux level below which the automation will run. | |
kevin 修订了这个 Gist . 转到此修订
1 file changed, 2 deletions
YAMA.yaml
| @@ -32,8 +32,6 @@ blueprint: | |||
| 32 | 32 | default: | |
| 33 | 33 | selector: | |
| 34 | 34 | entity: | |
| 35 | - | domain: | |
| 36 | - | - sensor | |
| 37 | 35 | multiple: true | |
| 38 | 36 | luminance_required: | |
| 39 | 37 | name: Required Lux Level | |
kevin 修订了这个 Gist . 转到此修订
1 file changed, 2 deletions
YAMA.yaml
| @@ -34,8 +34,6 @@ blueprint: | |||
| 34 | 34 | entity: | |
| 35 | 35 | domain: | |
| 36 | 36 | - sensor | |
| 37 | - | device_class: | |
| 38 | - | - illuminance | |
| 39 | 37 | multiple: true | |
| 40 | 38 | luminance_required: | |
| 41 | 39 | name: Required Lux Level | |
kevin 修订了这个 Gist . 转到此修订
1 file changed, 182 insertions, 171 deletions
YAMA.yaml
| @@ -1,171 +1,195 @@ | |||
| 1 | 1 | blueprint: | |
| 2 | - | name: Yet Another Motion Automation (V11) | |
| 3 | - | description: > | |
| 4 | - | # YAMA V11 | |
| 5 | - | Turn on lights or scenes when motion is detected. | |
| 6 | - | ||
| 7 | - | Four different scenes can be defined depending on time of day. | |
| 8 | - | ||
| 9 | - | You can now set an Lux Entity and a Threshold for triggering. | |
| 10 | - | ||
| 11 | - | Capabilitys: | |
| 12 | - | - Trigger on motion (in fact can be triggered by anything that switches between “on” and off") | |
| 13 | - | - Wait time for turning off | |
| 14 | - | - Only run if entity is in desired state (optional) | |
| 15 | - | - Sun elevation check (optional) | |
| 16 | - | - 4 Scenes for different times of day (optional) | |
| 17 | - | - Ambient support with time frame (optional) | |
| 18 | - | - Default scene when motion stops (optional) | |
| 19 | - | - “no motion blocker” with user choosable state (optional) | |
| 2 | + | name: Yet Another Motion Automation (Custom) | |
| 3 | + | description: "# YAMA V11\n\nTurn on lights or scenes when motion is detected optional with lumiance sensor. \nFour | |
| 4 | + | different scenes can be defined depending on time of day.\n\nFor Details see this | |
| 5 | + | 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 | |
| 6 | + | - Trigger on motion (in fact can be triggered by anything that switches between | |
| 7 | + | “on” and off\")\n - Wait time for turning off\n - Only run if entity is in desired | |
| 8 | + | state (optional)\n - Sun elevation check (optional)\n - 4 Scenes for different | |
| 9 | + | times of day (optional)\n - Ambient support with time frame (optional)\n - Default | |
| 10 | + | scene when motion stops (optional)\n - “no motion blocker” with user choosable | |
| 11 | + | state (optional)\n - As option one or more illumiance sensors can be used\n" | |
| 20 | 12 | domain: automation | |
| 21 | - | source_url: https://gist.github.com/DQKev/0979530e2996ced371a0f8db4432c178 | |
| 13 | + | source_url: https://gist.github.com/Stephan-4711/0bd3af042ac2ed2805403749b652dfe8 | |
| 22 | 14 | input: | |
| 23 | 15 | motion_entity: | |
| 24 | 16 | name: Motion Sensor | |
| 25 | - | description: Motion Sensor or a group with Motion Sensors (But can be anything switching between "on" and "off") | |
| 17 | + | description: Motion Sensor or a group with Motion Sensors (But can be anything | |
| 18 | + | switching between "on" and "off") | |
| 26 | 19 | selector: | |
| 27 | 20 | entity: | |
| 21 | + | multiple: true | |
| 28 | 22 | light_target: | |
| 29 | 23 | name: Light | |
| 30 | 24 | selector: | |
| 31 | 25 | target: | |
| 32 | 26 | entity: | |
| 33 | - | domain: light | |
| 27 | + | - domain: | |
| 28 | + | - light | |
| 29 | + | luminance_sensor: | |
| 30 | + | name: Illuminance sensor | |
| 31 | + | description: This sensor will be used to determine the illumination. | |
| 32 | + | default: | |
| 33 | + | selector: | |
| 34 | + | entity: | |
| 35 | + | domain: | |
| 36 | + | - sensor | |
| 37 | + | device_class: | |
| 38 | + | - illuminance | |
| 39 | + | multiple: true | |
| 40 | + | luminance_required: | |
| 41 | + | name: Required Lux Level | |
| 42 | + | description: Lux level below which the automation will run. | |
| 43 | + | default: 100 | |
| 44 | + | selector: | |
| 45 | + | number: | |
| 46 | + | min: 0.0 | |
| 47 | + | max: 10000.0 | |
| 48 | + | unit_of_measurement: lx | |
| 49 | + | step: 1.0 | |
| 50 | + | mode: slider | |
| 34 | 51 | no_motion_wait: | |
| 35 | 52 | name: Wait time | |
| 36 | 53 | description: Time to leave the light on after last motion is detected. | |
| 37 | 54 | default: 120 | |
| 38 | 55 | selector: | |
| 39 | 56 | number: | |
| 40 | - | min: 0 | |
| 41 | - | max: 3600 | |
| 57 | + | min: 0.0 | |
| 58 | + | max: 3600.0 | |
| 42 | 59 | unit_of_measurement: seconds | |
| 43 | - | lux_entity: | |
| 44 | - | name: Lux Sensor | |
| 45 | - | description: Lux Sensor | |
| 46 | - | selector: | |
| 47 | - | entity: | |
| 48 | - | lux_threshold: | |
| 49 | - | name: Lux Threshold | |
| 50 | - | description: If under this Lux Value the State will trigger. 0 = allways | |
| 51 | - | default: 0 | |
| 52 | - | selector: | |
| 53 | - | number: | |
| 54 | - | min: 0 | |
| 55 | - | max: 1500 | |
| 56 | - | unit_of_measurement: Lx | |
| 60 | + | step: 1.0 | |
| 61 | + | mode: slider | |
| 57 | 62 | automation_blocker: | |
| 58 | 63 | name: Automation Blocker (Optional) | |
| 59 | 64 | description: Only run if this boolean is in desired state (see next input) | |
| 60 | 65 | default: | |
| 61 | 66 | selector: | |
| 62 | - | entity: | |
| 67 | + | entity: {} | |
| 63 | 68 | automation_blocker_boolean: | |
| 64 | 69 | name: Automation Blocker Chooser (Optional) | |
| 65 | - | description: Desired state of automation blocker, choose on for on and off for off | |
| 70 | + | description: Desired state of automation blocker, choose on for on and off for | |
| 71 | + | off | |
| 66 | 72 | default: false | |
| 67 | 73 | selector: | |
| 68 | - | boolean: | |
| 74 | + | boolean: {} | |
| 69 | 75 | no_motion_blocker: | |
| 70 | 76 | name: No Motion Blocker (Optional) | |
| 71 | - | description: No motion sequence is not run if this boolean is in desired state (see next input) | |
| 77 | + | description: No motion sequence is not run if this boolean is in desired state | |
| 78 | + | (see next input) | |
| 72 | 79 | default: | |
| 73 | 80 | selector: | |
| 74 | - | entity: | |
| 81 | + | entity: {} | |
| 75 | 82 | no_motion_blocker_boolean: | |
| 76 | 83 | name: No Motion Chooser (Optional) | |
| 77 | - | description: Desired state of no motion blocker, choose on for on and off for off | |
| 84 | + | description: Desired state of no motion blocker, choose on for on and off for | |
| 85 | + | off | |
| 78 | 86 | default: false | |
| 79 | 87 | selector: | |
| 80 | - | boolean: | |
| 88 | + | boolean: {} | |
| 81 | 89 | elevation_check: | |
| 82 | 90 | name: Sun elevation check (Optional) | |
| 83 | - | description: This is the angle between the sun and the horizon. Negative values mean the sun is BELOW the horizon. | |
| 91 | + | description: This is the angle between the sun and the horizon. Negative values | |
| 92 | + | mean the sun is BELOW the horizon. | |
| 84 | 93 | default: none | |
| 85 | 94 | selector: | |
| 86 | 95 | number: | |
| 87 | - | min: -90 | |
| 88 | - | max: 90 | |
| 96 | + | min: -90.0 | |
| 97 | + | max: 90.0 | |
| 89 | 98 | unit_of_measurement: degrees | |
| 99 | + | step: 1.0 | |
| 100 | + | mode: slider | |
| 90 | 101 | scene_ambient: | |
| 91 | 102 | name: Ambient Scene (Optional) | |
| 92 | 103 | description: Scene for ambient state. Will be activated when no motion is detected. | |
| 93 | 104 | default: scene.none | |
| 94 | 105 | selector: | |
| 95 | 106 | entity: | |
| 96 | - | domain: scene | |
| 107 | + | domain: | |
| 108 | + | - scene | |
| 109 | + | multiple: false | |
| 97 | 110 | time_scene_ambient_start: | |
| 98 | 111 | name: Ambient time frame start (Optional) | |
| 99 | 112 | description: Time from which on ambient scene will be activated | |
| 100 | - | default: "00:00:00" | |
| 113 | + | default: 00:00:00 | |
| 101 | 114 | selector: | |
| 102 | - | time: | |
| 115 | + | time: {} | |
| 103 | 116 | time_scene_ambient_end: | |
| 104 | 117 | name: Ambient time frame end (Optional) | |
| 105 | 118 | description: Time from which on ambient scene will be not activated | |
| 106 | - | default: "00:00:00" | |
| 119 | + | default: 00:00:00 | |
| 107 | 120 | selector: | |
| 108 | - | time: | |
| 121 | + | time: {} | |
| 109 | 122 | scene_morning: | |
| 110 | 123 | name: Scene for the morning (Optional) | |
| 111 | 124 | default: scene.none | |
| 112 | 125 | selector: | |
| 113 | 126 | entity: | |
| 114 | - | domain: scene | |
| 127 | + | domain: | |
| 128 | + | - scene | |
| 129 | + | multiple: false | |
| 115 | 130 | time_scene_morning: | |
| 116 | 131 | name: Time for the morning scene (Optional) | |
| 117 | - | description: A time input which defines the time from which on the scene will be activated if motion is detected. | |
| 118 | - | default: "00:00:00" | |
| 132 | + | description: A time input which defines the time from which on the scene will | |
| 133 | + | be activated if motion is detected. | |
| 134 | + | default: 00:00:00 | |
| 119 | 135 | selector: | |
| 120 | - | time: | |
| 136 | + | time: {} | |
| 121 | 137 | scene_day: | |
| 122 | 138 | name: Scene for the bright day (Optional) | |
| 123 | 139 | default: scene.none | |
| 124 | 140 | selector: | |
| 125 | 141 | entity: | |
| 126 | - | domain: scene | |
| 142 | + | domain: | |
| 143 | + | - scene | |
| 144 | + | multiple: false | |
| 127 | 145 | time_scene_day: | |
| 128 | 146 | name: Time for the day scene (Optional) | |
| 129 | - | description: A time input which defines the time from which on the scene will be activated if motion is detected. | |
| 130 | - | default: "00:00:00" | |
| 147 | + | description: A time input which defines the time from which on the scene will | |
| 148 | + | be activated if motion is detected. | |
| 149 | + | default: 00:00:00 | |
| 131 | 150 | selector: | |
| 132 | - | time: | |
| 151 | + | time: {} | |
| 133 | 152 | scene_evening: | |
| 134 | 153 | name: Scene for the evening (Optional) | |
| 135 | 154 | default: scene.none | |
| 136 | 155 | selector: | |
| 137 | 156 | entity: | |
| 138 | - | domain: scene | |
| 157 | + | domain: | |
| 158 | + | - scene | |
| 159 | + | multiple: false | |
| 139 | 160 | time_scene_evening: | |
| 140 | 161 | name: Time for the evening scene (Optional) | |
| 141 | - | description: A time input which defines the time from which on the scene will be activated if motion is detected. | |
| 142 | - | default: "00:00:00" | |
| 162 | + | description: A time input which defines the time from which on the scene will | |
| 163 | + | be activated if motion is detected. | |
| 164 | + | default: 00:00:00 | |
| 143 | 165 | selector: | |
| 144 | - | time: | |
| 166 | + | time: {} | |
| 145 | 167 | scene_night: | |
| 146 | 168 | name: Scene for the dark night (Optional) | |
| 147 | 169 | default: scene.none | |
| 148 | 170 | selector: | |
| 149 | 171 | entity: | |
| 150 | - | domain: scene | |
| 172 | + | domain: | |
| 173 | + | - scene | |
| 174 | + | multiple: false | |
| 151 | 175 | time_scene_night: | |
| 152 | 176 | name: Time for the night scene (Optional) | |
| 153 | - | description: A time input which defines the time from which on the scene will be activated if motion is detectedd. | |
| 154 | - | default: "00:00:00" | |
| 177 | + | description: A time input which defines the time from which on the scene will | |
| 178 | + | be activated if motion is detectedd. | |
| 179 | + | default: 00:00:00 | |
| 155 | 180 | selector: | |
| 156 | - | time: | |
| 181 | + | time: {} | |
| 157 | 182 | scene_no_motion: | |
| 158 | 183 | name: Default scene for no motion (Optional) | |
| 159 | 184 | description: Set this Scene if you want to activate a scene if motion stops | |
| 160 | 185 | default: scene.none | |
| 161 | 186 | selector: | |
| 162 | 187 | entity: | |
| 163 | - | domain: scene | |
| 164 | - | ||
| 165 | - | ||
| 188 | + | domain: | |
| 189 | + | - scene | |
| 190 | + | multiple: false | |
| 166 | 191 | mode: restart | |
| 167 | 192 | max_exceeded: silent | |
| 168 | - | ||
| 169 | 193 | variables: | |
| 170 | 194 | scene_ambient: !input scene_ambient | |
| 171 | 195 | scene_morning: !input scene_morning | |
| @@ -173,113 +197,100 @@ variables: | |||
| 173 | 197 | scene_evening: !input scene_evening | |
| 174 | 198 | scene_night: !input scene_night | |
| 175 | 199 | automation_blocker: !input automation_blocker | |
| 176 | - | automation_blocker_boolean : !input automation_blocker_boolean | |
| 200 | + | automation_blocker_boolean: !input automation_blocker_boolean | |
| 177 | 201 | no_motion_blocker: !input no_motion_blocker | |
| 178 | 202 | no_motion_blocker_boolean: !input no_motion_blocker_boolean | |
| 179 | 203 | elevation_check: !input elevation_check | |
| 180 | 204 | scene_no_motion: !input scene_no_motion | |
| 181 | 205 | motion_entity: !input motion_entity | |
| 182 | - | lux_entity: !input lux_entity | |
| 183 | - | lux_threshold: !input lux_threshold | |
| 184 | - | ||
| 206 | + | luminance_sensor: !input luminance_sensor | |
| 207 | + | luminance_required: !input luminance_required | |
| 185 | 208 | trigger: | |
| 186 | - | - platform: state | |
| 187 | - | entity_id: !input motion_entity | |
| 188 | - | from: "off" | |
| 189 | - | to: "on" | |
| 190 | - | - platform: state | |
| 191 | - | entity_id: !input motion_entity | |
| 192 | - | from: "on" | |
| 193 | - | to: "off" | |
| 194 | - | for: !input no_motion_wait | |
| 195 | - | ||
| 196 | - | ||
| 197 | - | # All Conditions must be true | |
| 209 | + | - platform: state | |
| 210 | + | entity_id: !input motion_entity | |
| 211 | + | from: 'off' | |
| 212 | + | to: 'on' | |
| 213 | + | - platform: state | |
| 214 | + | entity_id: !input motion_entity | |
| 215 | + | from: 'on' | |
| 216 | + | to: 'off' | |
| 217 | + | for: !input no_motion_wait | |
| 198 | 218 | condition: | |
| 199 | - | # Check if automation blocker exist or is in desired state, otherwise do not run | |
| 200 | - | - condition: or | |
| 201 | - | conditions: | |
| 202 | - | - "{{ automation_blocker == none }}" | |
| 203 | - | - "{{ automation_blocker_boolean and states[automation_blocker].state == 'on' }}" | |
| 204 | - | - "{{ not automation_blocker_boolean and states[automation_blocker].state == 'off' }}" | |
| 205 | - | # Check if elevation input exist or is below desired value, otherwise do not run | |
| 206 | - | - condition: template | |
| 207 | - | value_template: "{{ (elevation_check == none) or (state_attr('sun.sun','elevation') <= elevation_check | float(90)) }}" | |
| 208 | - | ||
| 219 | + | - condition: or | |
| 220 | + | conditions: | |
| 221 | + | - '{{ automation_blocker == none }}' | |
| 222 | + | - '{{ automation_blocker_boolean and states[automation_blocker].state == ''off'' | |
| 223 | + | }}' | |
| 224 | + | - '{{ not automation_blocker_boolean and states[automation_blocker].state == ''on'' | |
| 225 | + | }}' | |
| 226 | + | - '{{ trigger.to_state.state == ''off'' }}' | |
| 227 | + | - condition: template | |
| 228 | + | value_template: '{{ (trigger.to_state.state == ''off'') or (elevation_check is none) | |
| 229 | + | or (state_attr(''sun.sun'', ''elevation'') <= elevation_check | float(90)) }}' | |
| 209 | 230 | action: | |
| 210 | - | - choose: | |
| 211 | - | # Trigger to state == "on" | |
| 231 | + | - choose: | |
| 232 | + | - conditions: | |
| 233 | + | - condition: template | |
| 234 | + | value_template: '{{ trigger.to_state.state == ''on'' }}' | |
| 235 | + | - condition: numeric_state | |
| 236 | + | entity_id: !input luminance_sensor | |
| 237 | + | below: !input luminance_required | |
| 238 | + | sequence: | |
| 239 | + | - choose: | |
| 212 | 240 | - conditions: | |
| 213 | - | - condition: template | |
| 214 | - | value_template: "{{ trigger.to_state.state == 'on' }}" | |
| 215 | - | - condition: template | |
| 216 | - | value_template: > | |
| 217 | - | {{ states(lux_entity) | float <= lux_threshold | float or states(lux_entity) | float == 0 }} | |
| 241 | + | - '{{ scene_morning != ''scene.none''}}' | |
| 242 | + | - condition: time | |
| 243 | + | after: !input time_scene_morning | |
| 244 | + | before: !input time_scene_day | |
| 218 | 245 | sequence: | |
| 219 | - | - choose: | |
| 220 | - | # Morning Scene | |
| 221 | - | - conditions: | |
| 222 | - | - "{{ scene_morning != 'scene.none'}}" | |
| 223 | - | - condition: time | |
| 224 | - | after: !input time_scene_morning | |
| 225 | - | before: !input time_scene_day | |
| 226 | - | sequence: | |
| 227 | - | - scene: !input scene_morning | |
| 228 | - | # Day Scene | |
| 229 | - | - conditions: | |
| 230 | - | - "{{ scene_day != 'scene.none'}}" | |
| 231 | - | - condition: time | |
| 232 | - | after: !input time_scene_day | |
| 233 | - | before: !input time_scene_evening | |
| 234 | - | sequence: | |
| 235 | - | - scene: !input scene_day | |
| 236 | - | # Evening Scene | |
| 237 | - | - conditions: | |
| 238 | - | - "{{ scene_evening != 'scene.none'}}" | |
| 239 | - | - condition: time | |
| 240 | - | after: !input time_scene_evening | |
| 241 | - | before: !input time_scene_night | |
| 242 | - | sequence: | |
| 243 | - | - scene: !input scene_evening | |
| 244 | - | # Night Scene | |
| 245 | - | - conditions: | |
| 246 | - | - "{{ scene_night != 'scene.none'}}" | |
| 247 | - | - condition: time | |
| 248 | - | after: !input time_scene_night | |
| 249 | - | before: !input time_scene_morning | |
| 250 | - | sequence: | |
| 251 | - | - scene: !input scene_night | |
| 252 | - | # If State -> "On" defaulting to turn light on | |
| 253 | - | default: | |
| 254 | - | - service: light.turn_on | |
| 255 | - | target: !input light_target | |
| 256 | - | ||
| 257 | - | # Trigger to state == "off" | |
| 246 | + | - scene: !input scene_morning | |
| 258 | 247 | - conditions: | |
| 259 | - | - condition: template | |
| 260 | - | value_template: "{{ trigger.to_state.state == 'off' }}" | |
| 261 | - | # Check if no motion blocker exist or in in desired state, otherwise do not run any no motion action | |
| 262 | - | - condition: or | |
| 263 | - | conditions: | |
| 264 | - | - "{{ no_motion_blocker == none }}" | |
| 265 | - | - "{{ no_motion_blocker_boolean and states[no_motion_blocker].state == 'on' }}" | |
| 266 | - | - "{{ not no_motion_blocker_boolean and states[no_motion_blocker].state == 'off' }}" | |
| 267 | - | sequence: | |
| 268 | - | - choose: | |
| 269 | - | # Used if ambient scene is true and in ambient scene time frame | |
| 270 | - | - conditions: | |
| 271 | - | - "{{ scene_ambient != 'scene.none' }}" | |
| 272 | - | - condition: time | |
| 273 | - | after: !input time_scene_ambient_start | |
| 274 | - | before: !input time_scene_ambient_end | |
| 275 | - | sequence: | |
| 276 | - | - scene: !input scene_ambient | |
| 277 | - | # Used if default no motion scene is set | |
| 278 | - | - conditions: | |
| 279 | - | - "{{ scene_no_motion != 'scene.none' }}" | |
| 280 | - | sequence: | |
| 281 | - | - scene: !input scene_no_motion | |
| 282 | - | # If State -> "off" default to turn lights off | |
| 283 | - | default: | |
| 284 | - | - service: light.turn_off | |
| 285 | - | target: !input light_target | |
| 248 | + | - '{{ scene_day != ''scene.none''}}' | |
| 249 | + | - condition: time | |
| 250 | + | after: !input time_scene_day | |
| 251 | + | before: !input time_scene_evening | |
| 252 | + | sequence: | |
| 253 | + | - scene: !input scene_day | |
| 254 | + | - conditions: | |
| 255 | + | - '{{ scene_evening != ''scene.none''}}' | |
| 256 | + | - condition: time | |
| 257 | + | after: !input time_scene_evening | |
| 258 | + | before: !input time_scene_night | |
| 259 | + | sequence: | |
| 260 | + | - scene: !input scene_evening | |
| 261 | + | - conditions: | |
| 262 | + | - '{{ scene_night != ''scene.none''}}' | |
| 263 | + | - condition: time | |
| 264 | + | after: !input time_scene_night | |
| 265 | + | before: !input time_scene_morning | |
| 266 | + | sequence: | |
| 267 | + | - scene: !input scene_night | |
| 268 | + | default: | |
| 269 | + | - service: light.turn_on | |
| 270 | + | target: !input light_target | |
| 271 | + | - conditions: | |
| 272 | + | - condition: template | |
| 273 | + | value_template: '{{ trigger.to_state.state == ''off'' }}' | |
| 274 | + | - condition: or | |
| 275 | + | conditions: | |
| 276 | + | - '{{ no_motion_blocker is none }}' | |
| 277 | + | - '{{ no_motion_blocker_boolean and states[no_motion_blocker].state == ''off'' | |
| 278 | + | }}' | |
| 279 | + | - '{{ not no_motion_blocker_boolean and states[no_motion_blocker].state == ''on'' | |
| 280 | + | }}' | |
| 281 | + | sequence: | |
| 282 | + | - choose: | |
| 283 | + | - conditions: | |
| 284 | + | - '{{ scene_ambient != ''scene.none'' }}' | |
| 285 | + | - condition: time | |
| 286 | + | after: !input time_scene_ambient_start | |
| 287 | + | before: !input time_scene_ambient_end | |
| 288 | + | sequence: | |
| 289 | + | - scene: !input scene_ambient | |
| 290 | + | - conditions: | |
| 291 | + | - '{{ scene_no_motion != ''scene.none'' }}' | |
| 292 | + | sequence: | |
| 293 | + | - scene: !input scene_no_motion | |
| 294 | + | default: | |
| 295 | + | - service: light.turn_off | |
| 296 | + | target: !input light_target | |
kevin 修订了这个 Gist . 转到此修订
1 file changed, 285 insertions
YAMA.yaml(文件已创建)
| @@ -0,0 +1,285 @@ | |||
| 1 | + | blueprint: | |
| 2 | + | name: Yet Another Motion Automation (V11) | |
| 3 | + | description: > | |
| 4 | + | # YAMA V11 | |
| 5 | + | Turn on lights or scenes when motion is detected. | |
| 6 | + | ||
| 7 | + | Four different scenes can be defined depending on time of day. | |
| 8 | + | ||
| 9 | + | You can now set an Lux Entity and a Threshold for triggering. | |
| 10 | + | ||
| 11 | + | Capabilitys: | |
| 12 | + | - Trigger on motion (in fact can be triggered by anything that switches between “on” and off") | |
| 13 | + | - Wait time for turning off | |
| 14 | + | - Only run if entity is in desired state (optional) | |
| 15 | + | - Sun elevation check (optional) | |
| 16 | + | - 4 Scenes for different times of day (optional) | |
| 17 | + | - Ambient support with time frame (optional) | |
| 18 | + | - Default scene when motion stops (optional) | |
| 19 | + | - “no motion blocker” with user choosable state (optional) | |
| 20 | + | domain: automation | |
| 21 | + | source_url: https://gist.github.com/DQKev/0979530e2996ced371a0f8db4432c178 | |
| 22 | + | input: | |
| 23 | + | motion_entity: | |
| 24 | + | name: Motion Sensor | |
| 25 | + | description: Motion Sensor or a group with Motion Sensors (But can be anything switching between "on" and "off") | |
| 26 | + | selector: | |
| 27 | + | entity: | |
| 28 | + | light_target: | |
| 29 | + | name: Light | |
| 30 | + | selector: | |
| 31 | + | target: | |
| 32 | + | entity: | |
| 33 | + | domain: light | |
| 34 | + | no_motion_wait: | |
| 35 | + | name: Wait time | |
| 36 | + | description: Time to leave the light on after last motion is detected. | |
| 37 | + | default: 120 | |
| 38 | + | selector: | |
| 39 | + | number: | |
| 40 | + | min: 0 | |
| 41 | + | max: 3600 | |
| 42 | + | unit_of_measurement: seconds | |
| 43 | + | lux_entity: | |
| 44 | + | name: Lux Sensor | |
| 45 | + | description: Lux Sensor | |
| 46 | + | selector: | |
| 47 | + | entity: | |
| 48 | + | lux_threshold: | |
| 49 | + | name: Lux Threshold | |
| 50 | + | description: If under this Lux Value the State will trigger. 0 = allways | |
| 51 | + | default: 0 | |
| 52 | + | selector: | |
| 53 | + | number: | |
| 54 | + | min: 0 | |
| 55 | + | max: 1500 | |
| 56 | + | unit_of_measurement: Lx | |
| 57 | + | automation_blocker: | |
| 58 | + | name: Automation Blocker (Optional) | |
| 59 | + | description: Only run if this boolean is in desired state (see next input) | |
| 60 | + | default: | |
| 61 | + | selector: | |
| 62 | + | entity: | |
| 63 | + | automation_blocker_boolean: | |
| 64 | + | name: Automation Blocker Chooser (Optional) | |
| 65 | + | description: Desired state of automation blocker, choose on for on and off for off | |
| 66 | + | default: false | |
| 67 | + | selector: | |
| 68 | + | boolean: | |
| 69 | + | no_motion_blocker: | |
| 70 | + | name: No Motion Blocker (Optional) | |
| 71 | + | description: No motion sequence is not run if this boolean is in desired state (see next input) | |
| 72 | + | default: | |
| 73 | + | selector: | |
| 74 | + | entity: | |
| 75 | + | no_motion_blocker_boolean: | |
| 76 | + | name: No Motion Chooser (Optional) | |
| 77 | + | description: Desired state of no motion blocker, choose on for on and off for off | |
| 78 | + | default: false | |
| 79 | + | selector: | |
| 80 | + | boolean: | |
| 81 | + | elevation_check: | |
| 82 | + | name: Sun elevation check (Optional) | |
| 83 | + | description: This is the angle between the sun and the horizon. Negative values mean the sun is BELOW the horizon. | |
| 84 | + | default: none | |
| 85 | + | selector: | |
| 86 | + | number: | |
| 87 | + | min: -90 | |
| 88 | + | max: 90 | |
| 89 | + | unit_of_measurement: degrees | |
| 90 | + | scene_ambient: | |
| 91 | + | name: Ambient Scene (Optional) | |
| 92 | + | description: Scene for ambient state. Will be activated when no motion is detected. | |
| 93 | + | default: scene.none | |
| 94 | + | selector: | |
| 95 | + | entity: | |
| 96 | + | domain: scene | |
| 97 | + | time_scene_ambient_start: | |
| 98 | + | name: Ambient time frame start (Optional) | |
| 99 | + | description: Time from which on ambient scene will be activated | |
| 100 | + | default: "00:00:00" | |
| 101 | + | selector: | |
| 102 | + | time: | |
| 103 | + | time_scene_ambient_end: | |
| 104 | + | name: Ambient time frame end (Optional) | |
| 105 | + | description: Time from which on ambient scene will be not activated | |
| 106 | + | default: "00:00:00" | |
| 107 | + | selector: | |
| 108 | + | time: | |
| 109 | + | scene_morning: | |
| 110 | + | name: Scene for the morning (Optional) | |
| 111 | + | default: scene.none | |
| 112 | + | selector: | |
| 113 | + | entity: | |
| 114 | + | domain: scene | |
| 115 | + | time_scene_morning: | |
| 116 | + | name: Time for the morning scene (Optional) | |
| 117 | + | description: A time input which defines the time from which on the scene will be activated if motion is detected. | |
| 118 | + | default: "00:00:00" | |
| 119 | + | selector: | |
| 120 | + | time: | |
| 121 | + | scene_day: | |
| 122 | + | name: Scene for the bright day (Optional) | |
| 123 | + | default: scene.none | |
| 124 | + | selector: | |
| 125 | + | entity: | |
| 126 | + | domain: scene | |
| 127 | + | time_scene_day: | |
| 128 | + | name: Time for the day scene (Optional) | |
| 129 | + | description: A time input which defines the time from which on the scene will be activated if motion is detected. | |
| 130 | + | default: "00:00:00" | |
| 131 | + | selector: | |
| 132 | + | time: | |
| 133 | + | scene_evening: | |
| 134 | + | name: Scene for the evening (Optional) | |
| 135 | + | default: scene.none | |
| 136 | + | selector: | |
| 137 | + | entity: | |
| 138 | + | domain: scene | |
| 139 | + | time_scene_evening: | |
| 140 | + | name: Time for the evening scene (Optional) | |
| 141 | + | description: A time input which defines the time from which on the scene will be activated if motion is detected. | |
| 142 | + | default: "00:00:00" | |
| 143 | + | selector: | |
| 144 | + | time: | |
| 145 | + | scene_night: | |
| 146 | + | name: Scene for the dark night (Optional) | |
| 147 | + | default: scene.none | |
| 148 | + | selector: | |
| 149 | + | entity: | |
| 150 | + | domain: scene | |
| 151 | + | time_scene_night: | |
| 152 | + | name: Time for the night scene (Optional) | |
| 153 | + | description: A time input which defines the time from which on the scene will be activated if motion is detectedd. | |
| 154 | + | default: "00:00:00" | |
| 155 | + | selector: | |
| 156 | + | time: | |
| 157 | + | scene_no_motion: | |
| 158 | + | name: Default scene for no motion (Optional) | |
| 159 | + | description: Set this Scene if you want to activate a scene if motion stops | |
| 160 | + | default: scene.none | |
| 161 | + | selector: | |
| 162 | + | entity: | |
| 163 | + | domain: scene | |
| 164 | + | ||
| 165 | + | ||
| 166 | + | mode: restart | |
| 167 | + | max_exceeded: silent | |
| 168 | + | ||
| 169 | + | variables: | |
| 170 | + | scene_ambient: !input scene_ambient | |
| 171 | + | scene_morning: !input scene_morning | |
| 172 | + | scene_day: !input scene_day | |
| 173 | + | scene_evening: !input scene_evening | |
| 174 | + | scene_night: !input scene_night | |
| 175 | + | automation_blocker: !input automation_blocker | |
| 176 | + | automation_blocker_boolean : !input automation_blocker_boolean | |
| 177 | + | no_motion_blocker: !input no_motion_blocker | |
| 178 | + | no_motion_blocker_boolean: !input no_motion_blocker_boolean | |
| 179 | + | elevation_check: !input elevation_check | |
| 180 | + | scene_no_motion: !input scene_no_motion | |
| 181 | + | motion_entity: !input motion_entity | |
| 182 | + | lux_entity: !input lux_entity | |
| 183 | + | lux_threshold: !input lux_threshold | |
| 184 | + | ||
| 185 | + | trigger: | |
| 186 | + | - platform: state | |
| 187 | + | entity_id: !input motion_entity | |
| 188 | + | from: "off" | |
| 189 | + | to: "on" | |
| 190 | + | - platform: state | |
| 191 | + | entity_id: !input motion_entity | |
| 192 | + | from: "on" | |
| 193 | + | to: "off" | |
| 194 | + | for: !input no_motion_wait | |
| 195 | + | ||
| 196 | + | ||
| 197 | + | # All Conditions must be true | |
| 198 | + | condition: | |
| 199 | + | # Check if automation blocker exist or is in desired state, otherwise do not run | |
| 200 | + | - condition: or | |
| 201 | + | conditions: | |
| 202 | + | - "{{ automation_blocker == none }}" | |
| 203 | + | - "{{ automation_blocker_boolean and states[automation_blocker].state == 'on' }}" | |
| 204 | + | - "{{ not automation_blocker_boolean and states[automation_blocker].state == 'off' }}" | |
| 205 | + | # Check if elevation input exist or is below desired value, otherwise do not run | |
| 206 | + | - condition: template | |
| 207 | + | value_template: "{{ (elevation_check == none) or (state_attr('sun.sun','elevation') <= elevation_check | float(90)) }}" | |
| 208 | + | ||
| 209 | + | action: | |
| 210 | + | - choose: | |
| 211 | + | # Trigger to state == "on" | |
| 212 | + | - conditions: | |
| 213 | + | - condition: template | |
| 214 | + | value_template: "{{ trigger.to_state.state == 'on' }}" | |
| 215 | + | - condition: template | |
| 216 | + | value_template: > | |
| 217 | + | {{ states(lux_entity) | float <= lux_threshold | float or states(lux_entity) | float == 0 }} | |
| 218 | + | sequence: | |
| 219 | + | - choose: | |
| 220 | + | # Morning Scene | |
| 221 | + | - conditions: | |
| 222 | + | - "{{ scene_morning != 'scene.none'}}" | |
| 223 | + | - condition: time | |
| 224 | + | after: !input time_scene_morning | |
| 225 | + | before: !input time_scene_day | |
| 226 | + | sequence: | |
| 227 | + | - scene: !input scene_morning | |
| 228 | + | # Day Scene | |
| 229 | + | - conditions: | |
| 230 | + | - "{{ scene_day != 'scene.none'}}" | |
| 231 | + | - condition: time | |
| 232 | + | after: !input time_scene_day | |
| 233 | + | before: !input time_scene_evening | |
| 234 | + | sequence: | |
| 235 | + | - scene: !input scene_day | |
| 236 | + | # Evening Scene | |
| 237 | + | - conditions: | |
| 238 | + | - "{{ scene_evening != 'scene.none'}}" | |
| 239 | + | - condition: time | |
| 240 | + | after: !input time_scene_evening | |
| 241 | + | before: !input time_scene_night | |
| 242 | + | sequence: | |
| 243 | + | - scene: !input scene_evening | |
| 244 | + | # Night Scene | |
| 245 | + | - conditions: | |
| 246 | + | - "{{ scene_night != 'scene.none'}}" | |
| 247 | + | - condition: time | |
| 248 | + | after: !input time_scene_night | |
| 249 | + | before: !input time_scene_morning | |
| 250 | + | sequence: | |
| 251 | + | - scene: !input scene_night | |
| 252 | + | # If State -> "On" defaulting to turn light on | |
| 253 | + | default: | |
| 254 | + | - service: light.turn_on | |
| 255 | + | target: !input light_target | |
| 256 | + | ||
| 257 | + | # Trigger to state == "off" | |
| 258 | + | - conditions: | |
| 259 | + | - condition: template | |
| 260 | + | value_template: "{{ trigger.to_state.state == 'off' }}" | |
| 261 | + | # Check if no motion blocker exist or in in desired state, otherwise do not run any no motion action | |
| 262 | + | - condition: or | |
| 263 | + | conditions: | |
| 264 | + | - "{{ no_motion_blocker == none }}" | |
| 265 | + | - "{{ no_motion_blocker_boolean and states[no_motion_blocker].state == 'on' }}" | |
| 266 | + | - "{{ not no_motion_blocker_boolean and states[no_motion_blocker].state == 'off' }}" | |
| 267 | + | sequence: | |
| 268 | + | - choose: | |
| 269 | + | # Used if ambient scene is true and in ambient scene time frame | |
| 270 | + | - conditions: | |
| 271 | + | - "{{ scene_ambient != 'scene.none' }}" | |
| 272 | + | - condition: time | |
| 273 | + | after: !input time_scene_ambient_start | |
| 274 | + | before: !input time_scene_ambient_end | |
| 275 | + | sequence: | |
| 276 | + | - scene: !input scene_ambient | |
| 277 | + | # Used if default no motion scene is set | |
| 278 | + | - conditions: | |
| 279 | + | - "{{ scene_no_motion != 'scene.none' }}" | |
| 280 | + | sequence: | |
| 281 | + | - scene: !input scene_no_motion | |
| 282 | + | # If State -> "off" default to turn lights off | |
| 283 | + | default: | |
| 284 | + | - service: light.turn_off | |
| 285 | + | target: !input light_target | |