📺 Bravia REST API — Full Sony Bravia integration for Home Assistant

Hi everyone! I’d like to share a new custom integration I’ve been working on: Bravia REST API.

The existing bravia integration is quite limited. I wanted full access to everything Sony Bravia TVs expose via their REST API — IRCC infrared codes, app control, screen management, Wake-on-LAN and more — so I built this from scratch.


:sparkles: What it does

Exposes the full Sony Bravia REST API as native Home Assistant entities:

  • :satellite_antenna: Media Player — power, volume (absolute + step), source selection mixing HDMI inputs and Android apps
  • :video_game: Remote — send any IRCC command by name (VolumeUp, Home, Back…) or raw base64 code
  • :radio_button: Buttons — one-tap actions: Blank Screen, Picture On, Reboot, Close Apps, and all directional/navigation IR buttons
  • :downwards_button: Selects — Sound output (speaker/HDMI/audio system), Screen rotation
  • :bar_chart: Sensors — Model, Firmware, Serial Number, MAC address
  • :on_arrow: Switches — LED Indicator, Wake-on-LAN
  • :gear: Custom Servicesopen_app, send_ircc, set_audio_output, blank_screen, get_installed_apps

Key features:

  • :magnifying_glass_tilted_left: Auto-discovers TV model and capabilities at setup time
  • :zzz: Works with TVs in standby (no need to have the TV on to configure)
  • :globe_with_meridians: Wake-on-LAN support to power on from standby
  • :mobile_phone: Discovers all installed Android apps and lets you launch them from the source list
  • :electric_plug: Local polling — no cloud, no account needed. Just IP + PSK

:clipboard: Requirements

  • Sony Bravia TV with Pre-Shared Key (PSK) enabled
    • Settings → Network → IP Control → Authentication → set a PSK
  • Home Assistant 2024.1+
  • TV on same local network as HA

:rocket: Installation via HACS

  1. HACS → Integrations → ⋮ → Custom repositories
  2. Add https://github.com/cmos486/Bravia-REST-API → Category: Integration
  3. Install Bravia REST API
  4. Restart Home Assistant
  5. Settings → Devices & Services → Add Integration → search Bravia REST API
  6. Enter your TV’s IP and PSK — that’s it!

:video_game: Example: sending IR commands from automations

service: remote.send_command
target:
  entity_id: remote.kd_65xh9096
data:
  command: Home

Or open Netflix directly:

service: bravia_rest_api.open_app
target:
  entity_id: media_player.kd_65xh9096
data:
  app_name: Netflix

:link: Links


Tested on a KD-65XH9096 running firmware 5.7.0. Should work on any Bravia with PSK support, though some features depend on the model. If you try it on a different model I’d love to hear how it goes — feedback and PRs welcome! :raising_hands:

6 Likes

Why not enhance the existing core integration instead of creating a new custom integration? This will be the third integration for Bravia TVs.

3 Likes

+1, would have been a lot better :wink:

1 Like

I was unaware of that possibility, my apologies ;(

You don’t have to apologize, it’s great that you want to support the community and create something new :muscle:
However, I encourage you to develop the core integration so that more users can benefit from your work.
You can find the integration source here: core/homeassistant/components/braviatv at dev · home-assistant/core · GitHub
Pybravia (backend library) source: GitHub - Drafteed/pybravia: Python async library for remote control of Sony Bravia TVs 2013 and newer. · GitHub

3 Likes

does your integration do remote and app launching differently from the official one? those features already exist and function the same way as your as far as i can tell

Very nice! Does it detect the currently running app and its playback status, if applicable?

Yes, it does! The integration polls the TV every 15 seconds and detects: -

Currently running app

— shown as the current source (e.g. "Netflix", "YouTube", "Disney+") -

Playback status

— the media player entity reflects

playing, paused, idle, or off

based on what the TV reports So if you're watching Netflix, the entity will show "Netflix" as the source and "playing" as the state. You can also use

media_player.select_source

to launch any installed app directly.

1 Like

Hi @cmos486 Thanks for the integration, it will definitely make automating our TV easier. Just a quick question.. I’m not sure if this is a bug, but it’s likely an issue with how the entity names, and ids are generated.

After adding the TV, I named the device "Sony Bravia Rest API" instead of the default model code. The names for the remote entities are correct, but for some of the others, it seems a bit confusing to me. See the screenshot.


entities
select.sony_bravia_rest_api_5
  - name: Sony Bravia Rest Api
  - icon: mdi:brightness-6
select.sony_bravia_rest_api_4
  - name: Sony Bravia Rest Api
  - icon: mdi:timer-outline
switch.sony_bravia_rest_api_2
  - name: Sony Bravia Rest Api
  - icon: mdi:power-plug
select.sony_bravia_rest_api_3
  - name: Sony Bravia Rest Api
  - icon: mdi:image-filter-hdr
select.sony_bravia_rest_api_2
  - name: Sony Bravia Rest Api
  - icon: mdi:screen-rotation
switch.sony_bravia_rest_api
  - name: Sony Bravia Rest Api
  - icon: mdi:led-on
sensor.sony_bravia_rest_api_4
  - name: Sony Bravia Rest Api
  - icon: mdi:ethernet
sensor.sony_bravia_rest_api_3
  - name: Sony Bravia Rest Api
  - icon: mdi:identifier
sensor.sony_bravia_rest_api_2
  - name: Sony Bravia Rest Api
  - icon: mdi:chip
sensor.sony_bravia_rest_api
  - name: Sony Bravia Rest Api
  - icon: mdi:television
select.sony_bravia_rest_api
  - name: Sony Bravia Rest Api
  - icon: mdi:speaker
number.sony_bravia_rest_api
  - name: Sony Bravia Rest Api
  - icon: mdi:brightness-6
button.sony_bravia_rest_api_remote_input
  - name: Sony Bravia Rest Api Remote: Input
  - icon: mdi:import
button.sony_bravia_rest_api_remote_stop
  - name: Sony Bravia Rest Api Remote: Stop
  - icon: mdi:stop
button.sony_bravia_rest_api_remote_pause
  - name: Sony Bravia Rest Api Remote: Pause
  - icon: mdi:pause
button.sony_bravia_rest_api_remote_play
  - name: Sony Bravia Rest Api Remote: Play
  - icon: mdi:play
button.sony_bravia_rest_api_remote_netflix
  - name: Sony Bravia Rest Api Remote: Netflix
  - icon: mdi:netflix
button.sony_bravia_rest_api_remote_channel_down
  - name: Sony Bravia Rest Api Remote: Channel Down
  - icon: mdi:arrow-down-bold
button.sony_bravia_rest_api_remote_channel_up
  - name: Sony Bravia Rest Api Remote: Channel Up
  - icon: mdi:arrow-up-bold
button.sony_bravia_rest_api_remote_mute
  - name: Sony Bravia Rest Api Remote: Mute
  - icon: mdi:volume-mute
button.sony_bravia_rest_api_remote_volume_down
  - name: Sony Bravia Rest Api Remote: Volume Down
  - icon: mdi:volume-minus
button.sony_bravia_rest_api_remote_volume_up
  - name: Sony Bravia Rest Api Remote: Volume Up
  - icon: mdi:volume-plus
button.sony_bravia_rest_api_remote_options
  - name: Sony Bravia Rest Api Remote: Options
  - icon: mdi:dots-vertical
button.sony_bravia_rest_api_remote_ok
  - name: Sony Bravia Rest Api Remote: OK
  - icon: mdi:checkbox-marked-circle
button.sony_bravia_rest_api_remote_right
  - name: Sony Bravia Rest Api Remote: Right
  - icon: mdi:chevron-right
button.sony_bravia_rest_api_remote_left
  - name: Sony Bravia Rest Api Remote: Left
  - icon: mdi:chevron-left
button.sony_bravia_rest_api_remote_down
  - name: Sony Bravia Rest Api Remote: Down
  - icon: mdi:chevron-down
button.sony_bravia_rest_api_remote_up
  - name: Sony Bravia Rest Api Remote: Up
  - icon: mdi:chevron-up
button.sony_bravia_rest_api_remote_back
  - name: Sony Bravia Rest Api Remote: Back
  - icon: mdi:arrow-left
button.sony_bravia_rest_api_remote_home
  - name: Sony Bravia Rest Api Remote: Home
  - icon: mdi:home
button.sony_bravia_rest_api_4
  - name: Sony Bravia Rest Api
  - icon: mdi:monitor
button.sony_bravia_rest_api_3
  - name: Sony Bravia Rest Api
  - icon: mdi:monitor-off
button.sony_bravia_rest_api_2
  - name: Sony Bravia Rest Api
  - icon: mdi:close-box-multiple
button.sony_bravia_rest_api
  - name: Sony Bravia Rest Api
  - icon: mdi:restart
remote.sony_bravia_rest_api_remote
  - name: Sony Bravia Rest Api Remote
  - icon: none
media_player.sony_bravia_rest_api
  - name: Sony Bravia Rest Api
  - icon: none

:smiley: Sorry for the silly question, but which one is the second one?

Hi! Thanks for reporting this — you're right, it was a bug.

The issue was that entities relying on translation_key for their names weren't getting them resolved properly in HACS custom components, so they all fell back to just the device name with numeric suffixes. The IRCC buttons worked because they
had explicit name attributes.

Fixed in v1.5.1 — added explicit name fallbacks on all affected entities (selects, switches, sensors, buttons, number) and created a proper translations/en.json file.

After updating, you'll likely need to remove and re-add the integration for the entity IDs to regenerate correctly (e.g., select.sony_bravia_rest_api_sound_output instead of select.sony_bravia_rest_api_2). Alternatively, you can rename them
manually in Settings → Devices & Services → Entities.

Thanks again for the detailed report — the screenshot made it very easy to diagnose!

1 Like

I'm just giving feedback, bugs are fixed, entity ids and names have automatically changed. Thanks! :rocket:

btw, the brand folder with icons is not in the component folder, which is why the icon is not visible in the integration dashboard. :eyes:

Hi all

I have the Sony Bravia 5 4k AE2 https://www.sony.co.uk/bravia/products/bravia-5?sku=k65xr55bp.uka

And I cannot get this integration to work (also not the build in SONY Bravia integration). There seems to be an issue with the Authentification with the PSK (it says that there is an invalid key).
However when I check with my macbook if I can connect via PSK and https, it works. Google Chromecast and Android Remote is also working.
I am trying for some time now w/o success. I did not find someone with similar issues though in the web. AI help was also very limited.
Could someone please help me here.
Thank you!

Hi @gueee007, thanks for reporting this!

We’ve identified a likely cause: the integration was hardcoded to HTTP only, but newer consumer Bravia TVs like the Bravia 5 may serve the REST API over HTTPS — which matches
your observation that HTTPS works from your Mac.

We’ve just released v1.5.8 with the following fixes:

  • HTTPS auto-detection — the setup flow now tries HTTP first, then automatically falls back to HTTPS (with self-signed certificate support)
  • PSK whitespace stripping — a trailing space in the PSK field would also cause “invalid key”
  • HTTP 401 handling — some newer models return 401 instead of 403 for auth failures

To update: go to HACS → Integrations → Bravia REST API → Update, then restart Home Assistant and try adding the TV again.

If it still doesn’t work, these steps will help us debug:

  1. Enable debug logging — add to your configuration.yaml:
    logger:
      logs:
        custom_components.bravia_rest_api: debug
    
  2. Restart HA, try adding the integration, and share the relevant log output.
  3. From the machine running Home Assistant, test which protocol works:

Try HTTPS

curl -sk -X POST https://<TV_IP>/sony/system
-H “X-Auth-PSK: <YOUR_PSK>”
-H “Content-Type: application/json”
-d ‘{“method”:“getSystemInformation”,“id”:1,“params”:,“version”:“1.0”}’

Try HTTP

curl -s -X POST http://<TV_IP>/sony/system
-H “X-Auth-PSK: <YOUR_PSK>”
-H “Content-Type: application/json”
-d ‘{“method”:“getSystemInformation”,“id”:1,“params”:,“version”:“1.0”}’

Let us know how it goes!

Guys this is AMAZING, it works, THANK YOU!
It seems the new SONY Bravia 5 TVs require HTTPS.
I’m still stunned how fast you were able to help here :grinning_face:

1 Like

Thanks for the new release 16.0 and the ability to set polling interval, is possible to have a polling set for when the TV is On and one for when its in standby to save on network traffic?

Yes, absolutely! This is now available in v1.7.0 which I just released.

You can now configure two separate polling intervals in the integration options:

Setting Description Default Max
Refresh Interval (TV On) Polling rate when the TV is active 15s 60s
Refresh Interval (Standby) Polling rate when the TV is off 60s 300s

The integration automatically switches between the two based on the TV’s power state. So you can keep fast updates while watching (e.g. 10s) and a much slower rate in standby
(e.g. 120s) to save on network traffic.

Just update via HACS and go to the integration’s Configure options to set it up. Thanks for the great suggestion! :tada:

1 Like

Wow, thank you​:wink:

1 Like