mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-19 15:26:59 +00:00
Convert Kodi turn_on_action
/ turn_off_action
examples to automations (#15324)
This commit is contained in:
parent
584449eb77
commit
d6d0876fff
@ -36,7 +36,34 @@ If you do not remove it, your configuration will be imported with the following
|
|||||||
|
|
||||||
### Turning On/Off
|
### 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
|
### Services
|
||||||
|
|
||||||
@ -75,17 +102,16 @@ result: <data received from the Kodi API>
|
|||||||
|
|
||||||
### Kodi turn on/off samples
|
### 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
|
#### 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`.
|
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
|
```yaml
|
||||||
media_player:
|
script:
|
||||||
- platform: kodi
|
turn_on_kodi_with_wol:
|
||||||
host: 192.168.0.123
|
sequence:
|
||||||
turn_on_action:
|
|
||||||
- service: wake_on_lan.send_magic_packet
|
- service: wake_on_lan.send_magic_packet
|
||||||
data:
|
data:
|
||||||
mac: aa:bb:cc:dd:ee:ff
|
mac: aa:bb:cc:dd:ee:ff
|
||||||
@ -96,69 +122,64 @@ media_player:
|
|||||||
|
|
||||||
Here are the equivalent ways to configure each of the old options to turn off Kodi (`quit`, `hibernate`, `suspend`, `reboot`, or `shutdown`):
|
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
|
```yaml
|
||||||
media_player:
|
script:
|
||||||
- platform: kodi
|
kodi_quit:
|
||||||
host: 192.168.0.123
|
sequence:
|
||||||
turn_off_action:
|
- service: kodi.call_method
|
||||||
service: kodi.call_method
|
data:
|
||||||
data:
|
entity_id: media_player.kodi
|
||||||
entity_id: media_player.kodi
|
method: Application.Quit
|
||||||
method: Application.Quit
|
|
||||||
```
|
```
|
||||||
|
|
||||||
- **Hibernate** method (before was `turn_off_action: hibernate`)
|
- **Hibernate** method
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
media_player:
|
script:
|
||||||
- platform: kodi
|
kodi_hibernate:
|
||||||
host: 192.168.0.123
|
sequence:
|
||||||
turn_off_action:
|
- service: kodi.call_method
|
||||||
service: kodi.call_method
|
data:
|
||||||
data:
|
entity_id: media_player.kodi
|
||||||
entity_id: media_player.kodi
|
method: System.Hibernate
|
||||||
method: System.Hibernate
|
|
||||||
```
|
```
|
||||||
|
|
||||||
- **Suspend** method (before was `turn_off_action: suspend`)
|
- **Suspend** method
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
media_player:
|
script:
|
||||||
- platform: kodi
|
kodi_suspend:
|
||||||
host: 192.168.0.123
|
sequence:
|
||||||
turn_off_action:
|
- service: kodi.call_method
|
||||||
service: kodi.call_method
|
data:
|
||||||
data:
|
entity_id: media_player.kodi
|
||||||
entity_id: media_player.kodi
|
method: System.Suspend
|
||||||
method: System.Suspend
|
|
||||||
```
|
```
|
||||||
|
|
||||||
- **Reboot** method (before was `turn_off_action: reboot`)
|
- **Reboot** method
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
media_player:
|
script:
|
||||||
- platform: kodi
|
kodi_reboot:
|
||||||
host: 192.168.0.123
|
sequence:
|
||||||
turn_off_action:
|
- service: kodi.call_method
|
||||||
service: kodi.call_method
|
data:
|
||||||
data:
|
entity_id: media_player.kodi
|
||||||
entity_id: media_player.kodi
|
method: System.Reboot
|
||||||
method: System.Reboot
|
|
||||||
```
|
```
|
||||||
|
|
||||||
- **Shutdown** method (before was `turn_off_action: shutdown`)
|
- **Shutdown** method
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
media_player:
|
script:
|
||||||
- platform: kodi
|
kodi_shutdown:
|
||||||
host: 192.168.0.123
|
sequence:
|
||||||
turn_off_action:
|
- service: kodi.call_method
|
||||||
service: kodi.call_method
|
data:
|
||||||
data:
|
entity_id: media_player.kodi
|
||||||
entity_id: media_player.kodi
|
method: System.Shutdown
|
||||||
method: System.Shutdown
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Turn on and off the TV with the Kodi JSON-CEC Add-on
|
#### Turn on and off the TV with the Kodi JSON-CEC Add-on
|
||||||
@ -166,28 +187,29 @@ 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:
|
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
|
```yaml
|
||||||
media_player:
|
script:
|
||||||
- platform: kodi
|
turn_on_kodi_with_cec:
|
||||||
host: 192.168.0.123
|
sequence:
|
||||||
turn_on_action:
|
|
||||||
service: kodi.call_method
|
|
||||||
data:
|
|
||||||
entity_id: media_player.kodi
|
|
||||||
method: Addons.ExecuteAddon
|
|
||||||
addonid: script.json-cec
|
|
||||||
params:
|
|
||||||
command: activate
|
|
||||||
turn_off_action:
|
|
||||||
- service: media_player.media_stop
|
|
||||||
data:
|
|
||||||
entity_id: media_player.kodi
|
|
||||||
- service: kodi.call_method
|
- service: kodi.call_method
|
||||||
data:
|
data:
|
||||||
entity_id: media_player.kodi
|
entity_id: media_player.kodi
|
||||||
method: Addons.ExecuteAddon
|
method: Addons.ExecuteAddon
|
||||||
addonid: script.json-cec
|
addonid: script.json-cec
|
||||||
params:
|
params:
|
||||||
command: standby
|
command: activate
|
||||||
|
|
||||||
|
turn_off_kodi_with_cec:
|
||||||
|
sequence:
|
||||||
|
- service: media_player.media_stop
|
||||||
|
data:
|
||||||
|
entity_id: media_player.kodi
|
||||||
|
- service: kodi.call_method
|
||||||
|
data:
|
||||||
|
entity_id: media_player.kodi
|
||||||
|
method: Addons.ExecuteAddon
|
||||||
|
addonid: script.json-cec
|
||||||
|
params:
|
||||||
|
command: standby
|
||||||
```
|
```
|
||||||
|
|
||||||
<div class='note'>
|
<div class='note'>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user