I get this ugly error in my log when I attempt to turn off the Kodi media_player while it is already turned off:
TransportError trying to run API method media_player.kodi.System.Shutdown({})
How can I prevent this error? Any ideas?
This is my configuration:
media_player:
- platform: kodi
host: x.x.x.x
turn_on_action:
- service: wake_on_lan.send_magic_packet
data:
mac: xx:xx:xx:xx:xx:xx
broadcast_address: xx.xx.xx.255
turn_off_action: #service template was an attempt but threw other ugly errors
# - service_template: >
# {% if is_state('media_player.kodi','off') %}
# script.dummy
# {% else %}
# kodi.call_method
# {% endif %}
- service: kodi.call_method
data:
entity_id: media_player.kodi
method: System.Shutdown
I’d prefer to solve it in the turn_off action if at all possible. An alternative would be to add checks in all automations before running the turn_off service. But that would mean a lot of code duplication.