Skip to content

Commit d6d0876

Browse files
authored
Convert Kodi turn_on_action / turn_off_action examples to automations (home-assistant#15324)
1 parent 584449e commit d6d0876

File tree

1 file changed

+89
-67
lines changed

1 file changed

+89
-67
lines changed

source/_integrations/kodi.markdown

Lines changed: 89 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,34 @@ If you do not remove it, your configuration will be imported with the following
3636

3737
### Turning On/Off
3838

39-
You can customize your turn on and off actions through automations. Simply use the relevant Kodi device triggers and your automation will be called to perform the `turn_on` or `turn_off` sequence.
39+
You can customize your turn on and off actions through automations. Simply use the relevant Kodi device triggers and your automation will be called to perform the `turn_on` or `turn_off` sequence; see the [Kodi turn on/off samples](#kodi-turn-onoff-samples) section for scripts that can be used.
40+
41+
These automations can be configured through the UI (see [Device Triggers](/automation/trigger/#device-triggers) for automations). If you prefer YAML, you'll need to get the device ID from the UI automation editor. Automations would be of the form:
42+
43+
```yaml
44+
automation:
45+
- id: kodi_turn_on
46+
alias: "Kodi: turn on"
47+
trigger:
48+
- platform: device
49+
device_id: !secret kodi_device_id
50+
domain: kodi
51+
entity_id: media_player.kodi
52+
type: turn_on
53+
action:
54+
- service: script.kodi_turn_on
55+
56+
- id: kodi_turn_off
57+
alias: "Kodi: turn off"
58+
trigger:
59+
- platform: device
60+
device_id: !secret kodi_device_id
61+
domain: kodi
62+
entity_id: media_player.kodi
63+
type: turn_off
64+
action:
65+
- service: script.kodi_turn_off
66+
```
4067
4168
### Services
4269
@@ -75,17 +102,16 @@ result: <data received from the Kodi API>
75102

76103
### Kodi turn on/off samples
77104

78-
With the `turn_on_action` and `turn_off_action` parameters you can run any combination of Home Assistant actions to turn on/off your Kodi instance. Here are a few examples of this usage, including the **migration instructions for the old `turn_off_action` list of options**.
105+
The following scripts can be used in automations for turning on/off your Kodi instance; see [Turning on/off](#turning-onoff). You could also simply use these sequences directly in the automations without creating scripts.
79106

80107
#### Turn on Kodi with Wake on LAN
81108

82109
With this configuration, when calling `media_player/turn_on` on the Kodi device, a _magic packet_ will be sent to the specified MAC address. To use this service, first you need to configuration the [`wake_on_lan`](/integrations/wake_on_lan) integration in Home Assistant, which is achieved simply by adding `wake_on_lan:` to your `configuration.yaml`.
83110

84111
```yaml
85-
media_player:
86-
- platform: kodi
87-
host: 192.168.0.123
88-
turn_on_action:
112+
script:
113+
turn_on_kodi_with_wol:
114+
sequence:
89115
- service: wake_on_lan.send_magic_packet
90116
data:
91117
mac: aa:bb:cc:dd:ee:ff
@@ -96,98 +122,94 @@ media_player:
96122

97123
Here are the equivalent ways to configure each of the old options to turn off Kodi (`quit`, `hibernate`, `suspend`, `reboot`, or `shutdown`):
98124

99-
- **Quit** method (before was `turn_off_action: quit`)
125+
- **Quit** method
100126

101127
```yaml
102-
media_player:
103-
- platform: kodi
104-
host: 192.168.0.123
105-
turn_off_action:
106-
service: kodi.call_method
107-
data:
108-
entity_id: media_player.kodi
109-
method: Application.Quit
128+
script:
129+
kodi_quit:
130+
sequence:
131+
- service: kodi.call_method
132+
data:
133+
entity_id: media_player.kodi
134+
method: Application.Quit
110135
```
111136

112-
- **Hibernate** method (before was `turn_off_action: hibernate`)
137+
- **Hibernate** method
113138

114139
```yaml
115-
media_player:
116-
- platform: kodi
117-
host: 192.168.0.123
118-
turn_off_action:
119-
service: kodi.call_method
120-
data:
121-
entity_id: media_player.kodi
122-
method: System.Hibernate
140+
script:
141+
kodi_hibernate:
142+
sequence:
143+
- service: kodi.call_method
144+
data:
145+
entity_id: media_player.kodi
146+
method: System.Hibernate
123147
```
124148

125-
- **Suspend** method (before was `turn_off_action: suspend`)
149+
- **Suspend** method
126150

127151
```yaml
128-
media_player:
129-
- platform: kodi
130-
host: 192.168.0.123
131-
turn_off_action:
132-
service: kodi.call_method
133-
data:
134-
entity_id: media_player.kodi
135-
method: System.Suspend
152+
script:
153+
kodi_suspend:
154+
sequence:
155+
- service: kodi.call_method
156+
data:
157+
entity_id: media_player.kodi
158+
method: System.Suspend
136159
```
137160

138-
- **Reboot** method (before was `turn_off_action: reboot`)
161+
- **Reboot** method
139162

140163
```yaml
141-
media_player:
142-
- platform: kodi
143-
host: 192.168.0.123
144-
turn_off_action:
145-
service: kodi.call_method
146-
data:
147-
entity_id: media_player.kodi
148-
method: System.Reboot
164+
script:
165+
kodi_reboot:
166+
sequence:
167+
- service: kodi.call_method
168+
data:
169+
entity_id: media_player.kodi
170+
method: System.Reboot
149171
```
150172

151-
- **Shutdown** method (before was `turn_off_action: shutdown`)
173+
- **Shutdown** method
152174

153175
```yaml
154-
media_player:
155-
- platform: kodi
156-
host: 192.168.0.123
157-
turn_off_action:
158-
service: kodi.call_method
159-
data:
160-
entity_id: media_player.kodi
161-
method: System.Shutdown
176+
script:
177+
kodi_shutdown:
178+
sequence:
179+
- service: kodi.call_method
180+
data:
181+
entity_id: media_player.kodi
182+
method: System.Shutdown
162183
```
163184

164185
#### Turn on and off the TV with the Kodi JSON-CEC Add-on
165186

166187
For Kodi devices running 24/7 attached to a CEC capable TV (OSMC / OpenElec and systems alike running in Rasperry Pi's, for example), this configuration enables the optimal way to turn on/off the attached TV from Home Assistant while Kodi is always active and ready:
167188

168189
```yaml
169-
media_player:
170-
- platform: kodi
171-
host: 192.168.0.123
172-
turn_on_action:
173-
service: kodi.call_method
174-
data:
175-
entity_id: media_player.kodi
176-
method: Addons.ExecuteAddon
177-
addonid: script.json-cec
178-
params:
179-
command: activate
180-
turn_off_action:
181-
- service: media_player.media_stop
182-
data:
183-
entity_id: media_player.kodi
190+
script:
191+
turn_on_kodi_with_cec:
192+
sequence:
184193
- service: kodi.call_method
185194
data:
186195
entity_id: media_player.kodi
187196
method: Addons.ExecuteAddon
188197
addonid: script.json-cec
189198
params:
190-
command: standby
199+
command: activate
200+
201+
turn_off_kodi_with_cec:
202+
sequence:
203+
- service: media_player.media_stop
204+
data:
205+
entity_id: media_player.kodi
206+
- service: kodi.call_method
207+
data:
208+
entity_id: media_player.kodi
209+
method: Addons.ExecuteAddon
210+
addonid: script.json-cec
211+
params:
212+
command: standby
191213
```
192214

193215
<div class='note'>

0 commit comments

Comments
 (0)