summaryrefslogtreecommitdiffstats
path: root/blueprints/automation/media/sven_scene_switch.yaml
blob: 8f54d8d6acd52abc6550bfedd97521a74774e3c8 (plain)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
blueprint:
  name: Sven Scene Switch
  description: Scene-switch (4-buttons) to control SmartPi media player
  domain: automation
  input:
    switch_action:
      name: switch_action
      description: Scene Switch Action
      selector:
        entity:
          domain: sensor
    media_player:
      name: Media Player
      description: "Media Player"
      selector:
        entity:
          domain: media_player
    playlist_control:
      name: Playlist Control
      description: "Playlist Control Variable (input_number.smartpi_playlist)"
      selector:
        entity:
           domain: input_number
    power_scene:
      name: Power Scene
      description: "Scene controlling Sven Power On/Off"
      selector:
        entity:
           domain: scene

trigger:
  - platform: state
    entity_id:
      - !input switch_action
    to: 1_single
    id: single1
  - platform: state
    entity_id:
      - !input switch_action
    to: 2_single
    id: single2
  - platform: state
    entity_id:
      - !input switch_action
    to: 3_single
    id: single3
  - platform: state
    entity_id:
      - !input switch_action
    to: 4_single
    id: single4
  - platform: state
    entity_id:
      - !input switch_action
    to: 1_double
    id: double1
  - platform: state
    entity_id:
      - !input switch_action
    to: 2_double
    id: double2
  - platform: state
    entity_id:
      - !input switch_action
    to: 3_double
    id: double3
  - platform: state
    entity_id:
      - !input switch_action
    to: 4_dobule
    id: double4

mode: restart

action:
  - choose:
      - conditions:
          - condition: trigger
            id: single1
        sequence:
          - service: media_player.media_play_pause
            target:
              entity_id: !input media_player
            data: {}
      - conditions:
          - condition: trigger
            id: double1
        sequence:
          - service: scene.turn_on
            target:
              entity_id: !input power_scene

      - conditions:
          - condition: trigger
            id: single2
        sequence:
          - service: media_player.media_next_track
            data: {}
            target:
              entity_id: !input media_player
      - conditions:
          - condition: trigger
            id: double2
        sequence:
          - service: media_player.media_previous_track
            data: {}
            target:
              entity_id: !input media_player

      - conditions:
          - condition: trigger
            id: single3
        sequence:
          - service: script.play_playlist
            data:
              media_player: !input media_player
              playlist: darksoft
      - conditions:
          - condition: trigger
            id: double3
        sequence:
          - service: input_number.set_value
            data:
              value: 0
            target:
              entity_id: !input playlist_control
          - service: script.play_playlist
            data:
              media_player: !input media_player
              playlist: darksoft

      - conditions:
          - condition: trigger
            id: single4
        sequence:
          - service: script.play_playlist
            data:
              media_player: !input media_player
              playlist: asgard
      - conditions:
          - condition: trigger
            id: double4
        sequence:
          - service: script.play_playlist
            data:
              media_player: !input media_player
              playlist: downloads

    default: []