Philips Hue Play HDMI sync

This looks like something :slight_smile:

1 Like

I’m also interested. But I’ve moved my hue lights to zha, so I’m curious if it will work with zha also. :crossed_fingers:

There seems to be a API on the Hue HDMI Sync Box. Wonder if someone more experienced could take a look at it.
There is some info about it here: https://github.com/ebaauw/homebridge-hue/issues/552#issuecomment-572256796

I’ve managed to get a rest command working to switch inputs. First you need an accesstoken to use it. For that I used a small python script.

import requests
import json
from time import sleep

url = "https://<INSERT IP OF SYNCBOX HERE>/api/v1/registrations"
data = {'appName': 'hass', 'appSecret': 'MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI=', 'instanceName': 'hass' }
headers = {'Content-type': 'application/json'}
while True:
    sleep(1)
    r = requests.post(url, data=json.dumps(data), headers=headers, verify=False)
    if r.json().get('accessToken') != None:
        print("Your accessToken is " + r.json().get('accessToken'))
        break

Run the script and then hold the button on the sync box to pair. The token should print out.

Use this token in the rest command like this:

rest_command:
  syncbox_input1:
    url: https://<INSERT IP OF SYNCBOX HERE>/api/v1/execution
    method: PUT
    headers:
      Authorization: "Bearer <INSERT TOKEN HERE>"
    payload: '{"hdmiSource":"input1"}'
    content_type:  'application/json; charset=utf-8'
    verify_ssl: false

Change input1 to input2, input3 or input4 for other ports.

Hopefully this is of use for someone. If/When the API is made official maybe someone can make a nice media_player entity for it.

6 Likes

Thank you so much for sharing. I was able to add buttons to HA to swap input.
Can I ask you another detail? Do you know how switch on/off the box with a similar rest command?
Thank you

The HDMI Sync Box has published its API (You have to create a free dev-account to see content). The API is still in beta but you can use it to create rest-api calls. (Would be awesome if someone can integrate this in HA :slight_smile: )

Blockquote @ste.luci “Do you know how switch on/off the box with a similar rest command?”

To do this, use this example (thanks @NoedelVreter)

rest_command:
 syncbox_powersave:
   url: https://<INSERT IP OF SYNCBOX HERE>/api/v1/execution
   method: PUT
   headers:
     Authorization: "Bearer <INSERT TOKEN HERE>"
   payload: '{"mode":"powersave"}'
   content_type:  'application/json; charset=utf-8'
   verify_ssl: false

Change powersave to “passthrough”, “video”, “game”, “music” or “ambient” to set it accordingly. If that does not turn of the TV, try this payload: {"toggleHdmiActive": false} or {"hdmiActive":false}

1 Like

GREAT!!! It works.

If anybody needs to do sth similar here is what I did:

configuration.yaml

rest_command:
  syncbox_input1:
    url: https://  BRIDGE IP  /api/v1/execution
    method: PUT
    headers:
      Authorization: "Bearer   TOKEN  "
    payload: '{"hdmiSource":"input1"}'
    content_type:  'application/json; charset=utf-8'
    verify_ssl: false
  syncbox_input2:
    url: https://  BRIDGE IP  /api/v1/execution
    method: PUT
    headers:
      Authorization: "Bearer   TOKEN  "
    payload: '{"hdmiSource":"input2"}'
    content_type:  'application/json; charset=utf-8'
    verify_ssl: false
  syncbox_input3:
    url: https://  BRIDGE IP  /api/v1/execution
    method: PUT
    headers:
      Authorization: "Bearer   TOKEN  "
    payload: '{"hdmiSource":"input3"}'
    content_type:  'application/json; charset=utf-8'
    verify_ssl: false
  syncbox_input4:
    url: https://  BRIDGE IP  /api/v1/execution
    method: PUT
    headers:
      Authorization: "Bearer   TOKEN  "
    payload: '{"hdmiSource":"input4"}'
    content_type:  'application/json; charset=utf-8'
    verify_ssl: false


  syncbox_standby:
    url: https://  BRIDGE IP  /api/v1/execution
    method: PUT
    headers:
      Authorization: "Bearer   TOKEN  "
    payload: '{"mode":"powersave"}'
    content_type:  'application/json; charset=utf-8'
    verify_ssl: false
  syncbox_passthrough:
    url: https://  BRIDGE IP  /api/v1/execution
    method: PUT
    headers:
      Authorization: "Bearer   TOKEN  "
    payload: '{"mode":"passthrough"}'
    content_type:  'application/json; charset=utf-8'
    verify_ssl: false

In lovelace

      - cards:
          - type: vertical-stack
            cards:
              - type: button
                tap_action:
                  action: call-service
                  service: rest_command.syncbox_passthrough
                hold_action:
                  action: none
                show_icon: true
                show_name: true
                icon: 'mdi:power-on'
                name: 'On'
              - type: button
                tap_action:
                  action: call-service
                  service: rest_command.syncbox_standby
                hold_action:
                  action: none
                show_icon: true
                show_name: true
                icon: 'mdi:power-off'
                name: 'Off'
                entity: switch.transmission_switch_2
          - hold_action:
              action: none
            icon: 'mdi:set-top-box'
            name: UPC
            show_icon: true
            show_name: true
            tap_action:
              action: call-service
              service: rest_command.syncbox_input1
            type: button
          - hold_action:
              action: none
            icon: 'mdi:amazon'
            name: Fire
            show_icon: true
            show_name: true
            tap_action:
              action: call-service
              service: rest_command.syncbox_input2
            type: button
          - hold_action:
              action: none
            icon: 'mdi:google-chrome'
            name: Chrome
            show_icon: true
            show_name: true
            tap_action:
              action: call-service
              service: rest_command.syncbox_input3
            type: button
          - hold_action:
              action: none
            icon: 'mdi:disc-player'
            name: DVD
            show_icon: true
            show_name: true
            tap_action:
              action: call-service
              service: rest_command.syncbox_input4
            type: button
        type: horizontal-stack

Result:

HueSyncBox

P.S. I also created scripts so I can call them through vocal commands in google home.
Script example:

script_hue_sync_input_1:
  alias: Hue Sync Input 1
  sequence:
  - service: rest_command.syncbox_input1
1 Like

Nice to see!

I also tried to do the same thing with a rest sensor. When using the same endpoints with GET you will get the status. I used to reflect that back into HA, and created a dropdown input-select that also updates when the source was changed the app (with a lot of automations).

Whole thing was “houtje-touwtje”, and something broke. Had no time to fix it yet, but I’ll try to fix it and share it next weekend.

Awesome, tracking this for future updates. I tried to do it myself, but I’m not experienced enough to build a sensor to get all the states of the Hue box.

All right, here are is my setup for the Sync box. It allows me to set the box to Powersave or Video and change source. When one of those values changes, it will also be updated (with a delay due to the RestFull sensor).

Please use these components somewhere in your Lovelace, the rest is just some internal stuff.

- switch.syncbox_hdmi_active
- input_select.sync_box_source

I’m planning to do:

  • Brightness control
  • Convert this to a media-player (somehow)
  • Change of names in source select.

Hope this is useful!

configuration.yaml

binary_sensor:
  - platform: template
    sensors:
      syncbox_sync_active:
        friendly_name: "Sync Box Sync Active"
        value_template: '{{ states.sensor.sync_box.attributes.syncActive }}'
        entity_id: sensor.sync_box
      syncbox_hdmi_active:
        friendly_name: "Sync Box HDMI Active"
        value_template: '{{ states.sensor.sync_box.attributes.hdmiActive }}'
        entity_id: sensor.sync_box
input_select:
  sync_box_source:
    name: "Sync Box Source"
    icon: mdi:import
    options:
      - input1
      - input2
      - input3
      - input4
rest_command:
  syncbox_set_input_source:
    url: 'https://<IP_ADDRESS>/api/v1/execution'
    method: PUT
    verify_ssl: false
    payload: '{"hdmiSource":"{{ states.input_select.sync_box_source.state }}"}'
    headers:
      Authorization: !secret sync_box_token
  syncbox_powersave:
    url: 'https://<IP_ADDRESS>/api/v1/execution'
    method: PUT
    verify_ssl: false
    payload: '{"mode":"powersave"}'
    headers:
      Authorization: !secret sync_box_token
  syncbox_passthrough:
    url: 'https://<IP_ADDRESS>/api/v1/execution'
    method: PUT
    verify_ssl: false
    payload: '{"mode":"passthrough"}'
    headers:
      Authorization: !secret sync_box_token
  syncbox_video:
    url: 'https://<IP_ADDRESS>/api/v1/execution'
    method: PUT
    verify_ssl: false
    payload: '{"mode":"video"}'
    headers:
      Authorization: !secret sync_box_token
  
  syncbox_set_sync_active:
    url: 'https://<IP_ADDRESS>/api/v1/execution'
    method: PUT
    verify_ssl: false
    payload: '{"syncActive":true}'
    headers:
      Authorization: !secret sync_box_token
sensor:
  - platform: rest
    name: Sync Box
    resource: https://<IP_ADDRESS>/api/v1/execution
    method: GET
    verify_ssl: false
    json_attributes:
      - syncActive
      - hdmiActive
      - hdmiSource
      - brightness
    value_template: '{{ value_json.mode }}'
    headers:
      Authorization: !secret sync_box_token
  - platform: template
    sensors:
      syncbox_hdmi_input:
        friendly_name: "Sync Box HDMI input"
        value_template: '{{ states.sensor.sync_box.attributes.hdmiSource }}'
        entity_id: sensor.sync_box
      syncbox_brightness:
        friendly_name: "Sync Box brightness"
        value_template: '{{ (states.sensor.sync_box.attributes.brightness / 2) | int }}'
        entity_id: sensor.sync_box
        unit_of_measurement: "%"

scripts.yaml

syncbox_set_powersave:
  alias: "Sync Box - Set Powersave"
  sequence:
    - service: rest_command.syncbox_powersave
    - service: homeassistant.update_entity
      entity_id: sensor.sync_box 
      
syncbox_set_video:
  alias: "Sync Box - Set Video"
  sequence:
    - service: rest_command.syncbox_video
    - service: homeassistant.update_entity
      entity_id: sensor.sync_box

automations.yaml

- alias: "Sync Box - Set Source"
  trigger:
    platform: state
    entity_id: input_select.sync_box_source
  condition:
    - condition: template
      value_template: "{{ states.input_select.sync_box_source.state != states.sensor.syncbox_hdmi_input.state}}"
  action:
    - service: rest_command.syncbox_set_input_source
    - service: homeassistant.update_entity
      entity_id: sensor.sync_box
    
- alias: "Sync Box - Update Source"
  trigger: 
    platform: state
    entity_id: sensor.syncbox_hdmi_input
  action:
    - service: input_select.select_option
      data_template:
        entity_id: input_select.sync_box_source
        option: "{{ states.sensor.syncbox_hdmi_input.state }}"

Edit: Updated ip-addresses to placeholders
Edit 2: Fixed config issue

2 Likes

I’ll test this out on my end – to be clear though I do want to put bearer before any token right?

Yes, so in your secrets.yaml you need to have it like this:

sync_box_token: “Bearer <token>”

I’ve made a full write-up on how to integrate the Play HDMI Sync Box in HA with bi-directional updates (I also pull state from the Hue Sync Box to make sure HA is showing the right state) : https://www.dennusb.nl/home-assistant-control-philips-hue-hdmi-sync-box/

2 Likes

Hello everybody

While the input change commands work fine, when trying to call the suync rest command I get the following in the HA log:

[homeassistant.components.rest_command] Error. Url: https://SYNC BOX IP/api/v1/execution. Status code 400.

Any suggestion?

The sync box API yells at you that the request was invalid, so you have made an error somewhere.

What rest command are you using? Can you share it?

Thank you Unsigus
This is the rest command giving the error:

  syncbox_startsync:
    url: 'https://10.25.20.156/api/v1/execution'
    method: PUT
    verify_ssl: false
    payload: '{"syncActive":"video"}'
    headers:
      Authorization: "Bearer MY TOKEN HERE"

Other commands like the following work:

  syncbox_passthrough:
    url: https://10.25.20.156/api/v1/execution
    method: PUT
    headers:
      Authorization: "Bearer SAME TOKEN HERE"
    payload: '{"mode":"passthrough"}'
    content_type:  'application/json; charset=utf-8'
    verify_ssl: false

I see, I have made an error in my config example. “syncActive” expects a boolean (true or false), not “Video”. So change your payload to:
"{syncActive": true}"
'{"syncActive": true}'

Also: I highly recommend to create a developer account at https://developers.meethue.com/. It’s free and all the information you need is there!

Edit: Fix typo in payload

1 Like

Unfortunately I get the same error. I’ll try with https://developers.meethue.com/

Thank you for your help.

Sorry, made a typo in the payload…
'{"syncActive": true}' will do.

Just tested it, this must work.

1 Like

GREAT!!! Thank you

1 Like

Hi everyone,

This post was very insightful. I have created a custom component that allows to control most features and also provides information from the device. You can see it on GitHub and on the Community post.

1 Like