Convert Kodi turn_on_action / turn_off_action examples to automations (#15324)

This commit is contained in:
Jeff Irion 2020-10-20 04:32:22 -07:00 committed by GitHub
parent 584449eb77
commit d6d0876fff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -36,7 +36,34 @@ If you do not remove it, your configuration will be imported with the following
### Turning On/Off
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.
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.
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:
```yaml
automation:
- id: kodi_turn_on
alias: "Kodi: turn on"
trigger:
- platform: device
device_id: !secret kodi_device_id
domain: kodi
entity_id: media_player.kodi
type: turn_on
action:
- service: script.kodi_turn_on
- id: kodi_turn_off
alias: "Kodi: turn off"
trigger:
- platform: device
device_id: !secret kodi_device_id
domain: kodi
entity_id: media_player.kodi
type: turn_off
action:
- service: script.kodi_turn_off
```
### Services
@ -75,17 +102,16 @@ result: <data received from the Kodi API>
### Kodi turn on/off samples
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**.
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.
#### Turn on Kodi with Wake on LAN
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`.
```yaml
media_player:
- platform: kodi
host: 192.168.0.123
turn_on_action:
script:
turn_on_kodi_with_wol:
sequence:
- service: wake_on_lan.send_magic_packet
data:
mac: aa:bb:cc:dd:ee:ff
@ -96,66 +122,61 @@ media_player:
Here are the equivalent ways to configure each of the old options to turn off Kodi (`quit`, `hibernate`, `suspend`, `reboot`, or `shutdown`):
- **Quit** method (before was `turn_off_action: quit`)
- **Quit** method
```yaml
media_player:
- platform: kodi
host: 192.168.0.123
turn_off_action:
service: kodi.call_method
script:
kodi_quit:
sequence:
- service: kodi.call_method
data:
entity_id: media_player.kodi
method: Application.Quit
```
- **Hibernate** method (before was `turn_off_action: hibernate`)
- **Hibernate** method
```yaml
media_player:
- platform: kodi
host: 192.168.0.123
turn_off_action:
service: kodi.call_method
script:
kodi_hibernate:
sequence:
- service: kodi.call_method
data:
entity_id: media_player.kodi
method: System.Hibernate
```
- **Suspend** method (before was `turn_off_action: suspend`)
- **Suspend** method
```yaml
media_player:
- platform: kodi
host: 192.168.0.123
turn_off_action:
service: kodi.call_method
script:
kodi_suspend:
sequence:
- service: kodi.call_method
data:
entity_id: media_player.kodi
method: System.Suspend
```
- **Reboot** method (before was `turn_off_action: reboot`)
- **Reboot** method
```yaml
media_player:
- platform: kodi
host: 192.168.0.123
turn_off_action:
service: kodi.call_method
script:
kodi_reboot:
sequence:
- service: kodi.call_method
data:
entity_id: media_player.kodi
method: System.Reboot
```
- **Shutdown** method (before was `turn_off_action: shutdown`)
- **Shutdown** method
```yaml
media_player:
- platform: kodi
host: 192.168.0.123
turn_off_action:
service: kodi.call_method
script:
kodi_shutdown:
sequence:
- service: kodi.call_method
data:
entity_id: media_player.kodi
method: System.Shutdown
@ -166,18 +187,19 @@ media_player:
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:
```yaml
media_player:
- platform: kodi
host: 192.168.0.123
turn_on_action:
service: kodi.call_method
script:
turn_on_kodi_with_cec:
sequence:
- service: kodi.call_method
data:
entity_id: media_player.kodi
method: Addons.ExecuteAddon
addonid: script.json-cec
params:
command: activate
turn_off_action:
turn_off_kodi_with_cec:
sequence:
- service: media_player.media_stop
data:
entity_id: media_player.kodi