Pearl & Dean Intro Movie Mode with Harmony, Hue, and Kodi

My setup involves pressing “Watch a Movie” on my Logitech Harmony which then plays a Pearl & Dean 20 second video clip streamed from Youtube on Kodi, whilst dimming my Philips Hue lights to a soft glow. Turning off the activity turns the Hue lights back on.

I found an excellent Kodi CLI project on github which makes playing videos remotely on Kodi very easy: GitHub - nawar/kodi-cli: Kodi/XBMC bash script to send Kodi commands from the command line

  1. On your HASS server, download kodi-cli
    cd ~
    git clone GitHub - nawar/kodi-cli: Kodi/XBMC bash script to send Kodi commands from the command line

  2. Create a new script for HASS to execute the kodi-cli command. Your HASS homedir may be different to mine and you can name the script something other than playpearl.sh
    sudo vim /home/homeassistant/playpearl.sh

  3. Within playpearl.sh, add the following line (alter the path to suit your environment). The Youtube ID “3WQrLuaMBMw” points to https://www.youtube.com/watch?v=3WQrLuaMBMw which is a HD version of the 90s Pear & Dean intro. Change this ID to which ever video you prefer.
    /home/pi/kodi-cli/kodi-cli -y 3WQrLuaMBMw

  4. Change permissions so that the file is owned by home assistant and can be executed.
    sudo chown homeassistant:homeassistant /home/homeassistant/playpearl.sh
    sudo chmod 755 /home/homeassistant/playpearl.sh

  5. Edit the kodi-cli file and enter your kodi details in the required fields:
    vim /home/pi/kodi-cli/kodi-cli

    KODI_HOST=192.168.0.2
    KODI_PORT=8080
    KODI_USER=
    KODI_PASS=

  6. Test it plays the video on Kodi. You may need to install the Youtube plugin and grant remote access from the Kodi screen.
    sudo /home/homeassistant/playpearl.sh

  7. The following entries in my configuration.yaml tied it all together:

remote:
- platform: harmony
  name: Lounge
  host: 192.168.0.3
  #Hue integration polls for activity state changes at a default 30 seconds. I changed this to 10 because activity status only changes once Harmony has finished executing all commands.
scan_interval: 10
automation:
- alias: "Watch Movie started from harmony hub"
  trigger:
    platform: state
    entity_id: remote.lounge
  condition:
    condition: template
    value_template: '{{ trigger.to_state.attributes.current_activity == "Watch a Movie" }}'
  action:
    - service: shell_command.playpearl
    #Within the official Hue app, you can create a new scene within a room and then reference it by name
    - service: light.hue_activate_scene
      data:
        group_name: "Lounge"
        scene_name: "Moviemode"
- alias: "Power Off"
  trigger:
    platform: state
    entity_id: remote.lounge
  condition:
    condition: template
    value_template: '{{ trigger.to_state.attributes.current_activity == "PowerOff" }}'
  action:
    - service: light.hue_activate_scene
      data:
        group_name: "Lounge"
        scene_name: "Evening"

shell_command:
playpearl: /home/homeassistant/playpearl.sh

#The following entry allows you to test running the script from HASS States page.
script:
play_pearanddean:
alias: Play Pear and Dean Video on Kodi
sequence:
- service: shell_command.playpearl

One thing I would like to add is the ability to slowly transition my hue lights to the new scene. Does anyone know if this is possible?

I don’t know how you can do it with Hue Scenes, but I do it with HA scenes by using the transition: property when setting my lights. E.G.

- name: Sunset
  entities:
    light.lightstrip4:
        state: on
        transition: 2
        brightness: 254
        xy_color: [ 0.5384, 0.445 ]
    light.lightstrip2:
        state: on
        transition: 2
        brightness: 251
        xy_color: [ 0.5493, 0.4351 ]
    light.lightstrip3:
        state: on
        transition: 2
        brightness: 254
        xy_color: [ 0.6168, 0.3737 ]
    light.tv_light_l:
        state: on
        transition: 2
        brightness: 236
        color_temp: 500
        xy_color: [ 0.6735, 0.322 ]
    light.tv_light_r:
        state: on
        transition: 2
        brightness: 236
        color_temp: 500
        xy_color: [ 0.6735, 0.322 ]

Yes same here. I have the lights dim when movie starts and come back to 100% when stopping the movie with transition. Pure automation calling a scene based on state off Kodi.

Thanks for the suggestions!!

Just to clarify then, it sounds like I can’t use transitions if calling a Hue scene directly using light.hue_activate_scene, but instead I need to transition each bulb with a HA scene?

Yes but I think that may be due to with either how Hue exposes things in the API or the supporting library so it may not be a permanent thing.

Kosi itself does have an addon to dim hue lights on play, with undimming on pause/stop. Works damn well.

Hi @jarrah

Being new to all this, would you be able to share your playpearl.sh file contents ?

Hi @nodecentral, no problems. The contents of the file was covered in step 3, though I admit it’s not all that clear in hindsight. Essentially it’s just the following line:

/home/pi/kodi-cli/kodi-cli -y 3WQrLuaMBMw