How do I use the results of a kodi service call in an automation?

I am fairly new to Home Assistant, so please excuse me if I am missing something obvious. I’m running Home Assistant 0.107.7 on docker.

I am trying to have Home Assistant change the lens memory of my projector automatically while playing media on Kodi. I have successfully used kodi.call_method to get the correct aspect ratio from Kodi. I see the result from the service call on the kodi_call_method_result event. Here is the result:

{
    "event_type": "kodi_call_method_result",
    "data": {
        "entity_id": "media_player.kodi",
        "result": {
            "VideoPlayer.VideoAspect": "1.78"
        },
        "result_ok": true,
        "input": {
            "method": "XBMC.GetInfoLabels",
            "params": {
                "labels": [
                    "VideoPlayer.VideoAspect"
                ]
            }
        }
    },
    "origin": "LOCAL",
    "time_fired": "2020-05-03T04:19:28.041848+00:00",
    "context": {
        "id": "f23970eeb6034300856c9e3afed0a613",
        "parent_id": null,
        "user_id": null
    }
}

The value I want to use is in the result (1.78 above), but I am stuck with trying to use that to trigger/action the automation. I plan on using the Harmony Elite integration to send a device command to my projector to change the lens memory.

So what I need is a way to interpret the result on the event from the service call, and depending on the result send the correct command via Harmony.

Any thoughts on how I could make this work?

Any help is appreciated. Cheers.

Have you seen the event trigger ?

1 Like

Yes, but I can’t figure out how to use the returned data. I have an automation that will send the kodi.call_method whenever the kodi state changes to playing. It then returns the kodi_call_method_result like I posted above. What I need is for a way to interpret that event, and take the aspect ratio to do the next command.

So every time Home Assistant detects the kodi_call_method_result event, analyze the event to take the aspect ratio (1.78, 2.00, 2.35, etc.) and then send the corresponding command through Harmony.

I can’t seem to figure out a way to interpret the event result.

Thanks for your help.

This will get the value you want:

{{ json_value['data']['result']['VideoPlayer.VideoAspect'] }}

1 Like

Thank you, I will try that out when I get some time to work on this.

Thanks, that did the trick.