Last active
September 4, 2020 08:59
-
-
Save Maczuga/73520b3e615a3cad437a9c42b61bf25f to your computer and use it in GitHub Desktop.
STYJ02YM EU - selective vacuuming
This file contains 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
input_boolean: | |
odkurz_salon: | |
odkurz_kuchnia: | |
odkurz_sypialnia: | |
odkurz_korytarz: | |
odkurz_pokoj_2: | |
odkurz_gabinet: | |
odkurz_lazienka: |
This file contains 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
# WARNING: This one uses custom:auto-entities | |
card: | |
show_header_toggle: false | |
title: Vacuum selected rooms | |
type: entities | |
filter: | |
include: | |
- entity_id: input_boolean.odkurz_* | |
- entity_id: script.vacuum_selective | |
type: 'custom:auto-entities' |
This file contains 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
vacuum_selective: | |
alias: Vacuum selected rooms | |
sequence: | |
- service: vacuum.stop | |
data: | |
entity_id: vacuum.styj02ym | |
- service: vacuum.send_command | |
data_template: | |
entity_id: vacuum.styj02ym | |
command: set_mode_withroom | |
params: > | |
{% set room_ids = ({ | |
"salon": 10, | |
"sypialnia": 11, | |
"pokoj_2": 12, | |
"gabinet": 13, | |
"korytarz": 14, | |
"kuchnia": 15, | |
"lazienka": 16, | |
}) %} | |
{% set ns = namespace(count = 0, room_ids = [], command = [0, 1]) %} | |
{% for state in states.input_boolean if 'input_boolean.odkurz_' in state.entity_id and state.state == 'on' %} | |
{% set room = state.entity_id|replace('input_boolean.odkurz_', '') %} | |
{% set ns.count = ns.count + 1 %} | |
{% set ns.room_ids = ns.room_ids + [room_ids[room]] %} | |
{% endfor %} | |
{% set ns.command = ns.command + [ns.count] %} | |
{% for room_id in ns.room_ids %} | |
{% set ns.command = ns.command + [room_id] %} | |
{% endfor %} | |
{{ ns.command }} | |
- service: input_boolean.turn_off | |
data_template: | |
entity_id: > | |
{% set ns = namespace(inputs = []) %} | |
{% for state in states.input_boolean if 'input_boolean.odkurz_' in state.entity_id %} | |
{% set ns.inputs = ns.inputs + [state.entity_id] %} | |
{% endfor %} | |
{{ ns.inputs|join(',') }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment