-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathoffice_dial_rotate.yaml
More file actions
61 lines (61 loc) · 2.1 KB
/
office_dial_rotate.yaml
File metadata and controls
61 lines (61 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
id: 'office_dial_rotate'
initial_state: 'on'
alias: 'Office dial rotate'
triggers:
- trigger: state
entity_id: event.office_dial_moes_action
to: ~
conditions:
- condition: template
value_template: >-
{{ trigger.to_state.attributes.event_type in ['brightness_step','brightness_step','color_temperature_step_up','color_temperature_step_down'] }}
variables:
action: >-
{% if trigger.to_state.attributes.event_type == 'brightness_step' and trigger.to_state.attributes.direction|is_defined %}
volume_{{trigger.to_state.attributes.direction}}
{% elif trigger.to_state.attributes.event_type == 'color_temperature_step_up' %}
next_track
{% else %}
prev_track
{% endif %}
current_vol: "{{ state_attr('media_player.office','volume_level')|float(0) }}"
vol_step: "0.01"
new_vol: >-
{{ (min(1,(current_vol|float(0)+vol_step|float(0))))|round(2) if (action == 'volume_up') else (max(0,(current_vol|float(0)-vol_step|float(0))))|round(2) }}
action:
- choose:
- conditions:
- condition: template
value_template: "{{ action == 'volume_up' or action == 'volume_down'}}"
sequence:
- service: media_player.volume_set
data:
entity_id: media_player.office
volume_level: "{{ new_vol }}"
- conditions:
- condition: template
value_template: "{{ action == 'next_track' }}"
sequence:
- service: media_player.media_play
data:
entity_id: media_player.office
- service: media_player.media_next_track
data:
entity_id: media_player.office
- conditions:
- condition: template
value_template: "{{ action == 'prev_track' }}"
sequence:
- service: media_player.media_play
data:
entity_id: media_player.office
- service: media_player.media_previous_track
data:
entity_id: media_player.office
default:
- service: notify.send_message
target:
entity_id: notify.debug_log
data:
message: >-
Action is {{ action }} with {{ new_vol }}