Kodi / LibreElec trigger lights, only for media over 60 minutes in length?

platform: device
device_id: ec27768ae1c9094da87ea2ed71f1cf27
domain: media_player
entity_id: media_player.libreelec
type: playing
for:
  hours: 1
  minutes: 0
  seconds: 0
  milliseconds: 0

This works if I set the time to nothing but zeroes, however then the lights fade even when my wife watches terrible TV shows.

We only want the lights to enter “movie mode” when a movie begins (average length of film is at least 70 to 300 minutes) the TV shows are all less than this, so that would be perfect.

Can I do that?
If I can’t no big deal, but it would be nice,

You’ll need a condition that contains the media playing length. Does Kodi expose that ? If yes , easy doing. If no, challenge ahead

Any idea where I should start looking for that?

Dev tools menu, States tab. Find Kodi entities and have media playing. Search for media info and something that relates to timeduration for that media

Kodi has the following attribute: media_content_type
Create a condition: if media_content_type = movie

I just found that myself, yeah thanks!

Hey so smart people how do set a condition, to only apply my new movie mode automation, if the libreelec content playing

media_content_type = movie
condition:
  - condition: state
    entity_id: media_player.kodi
    state: movie
    attribute: media_content_type

It spat this back at me, am I doing something incorrectly?
I figured out the triger and I’ve tested it but I don’t know about the condition formatting?

Select the 3 Dots in the top right corner to edit the total automation. Or start a movie so you can select the attribute from the dropdown ui menu

Condition > state > select kodi device > select media_content_type > movie

I think you have doubled up on conditions. Should be just

condition: state
entity_id: media_player.libreelec
state: movie
attribute: media_content_type

Well it no longer fails to save but it doesn’t work, odd.

alias: All warm soft colour - movie mode!
description: ''
trigger:
  - platform: device
    device_id: ec27768ae1c9094da87ea2ed71f1XXXX
    domain: media_player
    entity_id: media_player.libreelec
    type: playing
condition:
  - condition: state
    entity_id: media_player.libreelec
    state: movie
    attribute: media_content_type
action:
  - service: light.turn_on
(etc etc blah blah)

Clearing the condition works, too, so I know the trigger is ok.

volume_level: 1
is_volume_muted: false
media_content_id:
  unknown: tt0053285
media_content_type: movie
media_duration: 4510
media_position: 0
media_position_updated_at: '2021-09-15T06:06:39.513582+00:00'
media_title: Sleeping Beauty
media_album_name: ''
media_series_title: ''
media_season: -1
media_episode: -1
friendly_name: LibreELEC
entity_picture: >-
  /api/media_player_proxy/media_player.libreelec?token=4eb0f5bc955897XXXXXX2c4003851c85ba8fd574fb889c46b7711c1c591&cache=e417ce168697b3bb
supported_features: 186303

I wonder if it’s because state = playing?
state does not = “media_content_type: movie” ?
It’s not reading the correct attibute or something, I figure?

I found when doing a similar thing that there was a slight delay between playing starting and media_content_type being set. I think a 1 second delay solved it.

1 Like

Gents and all, thanks - I’m up and running.

I’ll look into reverting the lights on a pause or end of the movie, but I suspect that’s particularly more advanced. Right now I’m happy as it is.

Yeah I just go to a dimmish state when paused (on the basis you don’t need to blind yourself when just going to get more drinks/popcorn) and back to full on stop. Not too complex, but then again I am not distinguishing between movie and the wife’s crap TV :slight_smile: