Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
P

pylips

> 编程语言
Open source

Control Philips TVs (2015+) and Ambilight (+ Hue) through their reverse-engineered API (+ MQTT support!)

391 stars0 likes1 views
WebsiteGitHub

About

Control Philips TVs (2015+) and Ambilight (+ Hue) through their reverse-engineered API (+ MQTT support!)

Pylips

Pylips is a Python tool to control Philips TVs (2015+) through their reverse-engineered API.

  1. Supports both Android and non-Android TVs
  2. 80+ built-in commands + support for custom "GET" and "POST" requests to the API
  3. All commands work on TVs with API version 6, most of them also work for API version 5
  4. Full control of Ambilight including color, brightness, mode and 'Ambilight + Hue'
  5. Allows sending TV status updates and receiving commands over MQTT

The current version of the API does not allow switching input sources anymore. For Android TVs with Google Assistant, Pylips can switch between any input sources that your TV has. For Android TVs without Google Assistant, see some options here.

Table of contents

  1. Prerequisites
  2. Setting up Pylips
    1. New users
    2. Migrating from older versions
  3. Controlling the TV (manual mode)
    1. Built-in commands
    2. Custom commands
  4. Controlling the TV (MQTT mode)
  5. Switching input sources
  6. API reference
  7. Change log
  8. TO-DO
  9. Acknowledgements
  10. Contact details

Prerequisites

Provided that you have python (version 3+) on your system, install all the dependencies first:

pip3 install -r requirements.txt

You may have to use pip and python instead of pip3 and python3 depending on how these tools are installed on your system.

Setting up Pylips

New users

To begin using Pylips you first need to add the ip adress of your TV to the [TV] section in the settings.ini file. If you want to use MQTT, you will also need to fill in the [MQTT] section and set the required flags in the [DEFAULT] section:

…

Now turn your TV on and run Pylips without any arguments to complete setting it up (it will discover your TV's API version, port and protocol, and will also pair and save the credentials if required):

python3 pylips.py

Once it's done, you are ready to use Pylips!

Security note:

To pair with the Android TVs we need to create a HMAC signature using an 88-character (?) key. As far as I can tell the key is used for pairing only. With that in mind and to make this tool as user-friendly as possible, the key is hardcoded. I see no security issues with this but if you are extremely paranoid you can change it: look for a secret_key in the beginning of the code.

Custom config path:

You can load a custom config by specifying its absolute path with a --config parameter:

python pylips.py --config '/home/eslavnov/repos/Pylips/some_settings.ini'

Controlling the TV (manual mode)

You can take advantage of some of the built-in commands or send your own custom commands.

Built-in commands

python3 pylips.py --host %TV's_ip_address% --user %username% --pass %password% --command %command%

Any passed arguments will override the settings in settings.ini without overwriting them. If you have already run the discovery for new users, you don't have to specify --host, --user and -pass parameters. Also skip the --user and --pass parameters if your TV does not have Android. Add --verbose False to any command if you don't want to see the feedback in your terminal (useful for command line sensors).

Available built-in commands:

        TV status:

  1. powerstate - Returns current power state of the TV ('On' or 'Off')

  2. volume - Returns current volume and mute status

  3. current_channel - Returns current channel (if in TV mode)

  4. current_app - Returns current app (Android TVs only)

    TV input (only for TVs with Google Assistant):

  5. input_hdmi_1 - Switches TV's input to HDMI 1

  6. input_hdmi_2 - Switches TV's input to HDMI 2

  7. input_hdmi_3 - Switches TV's input to HDMI 3

  8. input_hdmi_4 - Switches TV's input to HDMI 4

    TV remote keys:

  9. standby - Sends Standby key

  10. mute - Sends Mute key

  11. volume_up - Sends VolumeUp key

  12. volume_down - Sends VolumeDown key

  13. channel_up - Sends ChannelStepUp key

  14. channel_down - Sends ChannelStepDown key

  15. play - Sends Play key

  16. pause - Sends Pause key

  17. play_pause - Sends PlayPause key

  18. stop - Sends Stop key

  19. fast_forward - Sends FastForward key

  20. rewind - Sends Rewind key

  21. next - Sends Next key

  22. previous - Sends Previous key

  23. cursor_up - Sends CursorUp key

  24. cursor_down - Sends CursorDown key

  25. cursor_left - Sends CursorLeft key

  26. cursor_right - Sends CursorRight key

  27. confirm - Sends Confirm key

  28. back - Sends Back key

  29. home - Sends Home key

  30. options - Sends Options key

  31. info - Sends Info key

  32. find - Sends Find key

  33. adjust - Sends Adjust key

  34. watch_tv - Sends WatchTV key

  35. viewmode - Sends Viewmode key

  36. teletext - Sends Teletext key

  37. subtitle - Sends Subtitle key

  38. record - Sends Record key

  39. online - Sends Online key

  40. source - Sends Source key

  41. ambilight_onoff - Sends AmbilightOnOff key

  42. red - Sends RedColour key

  43. green - Sends GreenColour key

  44. yellow - Sends YellowColour key

  45. blue - Sends BlueColour key

  46. dot - Sends Dot key

  47. digit_0 - Sends Digit0 key

  48. digit_1 - Sends Digit1 key

  49. digit_2 - Sends Digit2 key

  50. digit_3 - Sends Digit3 key

  51. digit_4 - Sends Digit4 key

  52. digit_5 - Sends Digit5 key

  53. digit_6 - Sends Digit6 key

  54. digit_7 - Sends Digit7 key

  55. digit_8 - Sends Digit8 key

  56. digit_9 - Sends Digit9 key

    TV channels:

  57. set_channel - Turns a specified channel on. Requires a valid --body argument, see the API reference to get it.

  58. list_channels - Returns channel list

  59. list_favorite - Returns favorite list

    Ambilight:

  60. ambilight_on - Turns ambilight on

  61. ambilight_off - Turns ambilight off

  62. ambihue_status - Returns the current status of 'Ambilight + Hue'

  63. ambihue_on - Turns 'Ambilight + Hue' on

  64. ambihue_off - Turns 'Ambilight + Hue' off

  65. ambilight_color - Sets ambilight color (in HSB format). Requires a valid --body argument: {"hue": 360, "saturation": 100, "brightness": 255}

  66. ambilight_brightness - Sets ambilight brightness. Requires a valid --body argument: {"value": 10}

  67. ambilight_video_immersive - Sets Ambilight to 'Follow video' (Immersive)

  68. ambilight_video_standard - Sets Ambilight to 'Follow video' (Standard)

  69. ambilight_video_natural - Sets Ambilight to 'Follow video' (Natural)

  70. ambilight_video_vivid - Sets Ambilight to 'Follow video' (Vivid)

  71. ambilight_video_game - Sets Ambilight to 'Follow video' (Game)

  72. ambilight_video_comfort - Sets Ambilight to 'Follow video' (Comfort)

  73. ambilight_video_relax - Sets Ambilight to 'Follow video' (Relax)

  74. ambilight_color_hot_lava - Sets Ambilight to 'Follow color' (Hot lava)

  75. ambilight_color_warm_white - Sets Ambilight to 'Follow color' (Warm white)

  76. ambilight_color_cool_white - Sets Ambilight to 'Follow color' (Cool white)

  77. ambilight_color_fresh_nature - Sets Ambilight to 'Follow color' (Fresh nature)

  78. ambilight_deep_water - Sets Ambilight to 'Follow color' (Deep water)

  79. ambilight_audio_adapt_brightness - Sets Ambilight to 'Follow audio' (Energy Adaptive Brightness)

  80. ambilight_audio_adapt_colors - Sets Ambilight to 'Follow audio' (Energy Adaptive Colors)

  81. ambilight_audio_vu_meter - Sets Ambilight to 'Follow audio' (VU Meter)

  82. ambilight_audio_spectrum - Sets Ambilight to 'Follow audio' (Spectrum Analyzer)

  83. ambilight_audio_knight_rider_1 - Sets Ambilight to 'Follow audio' (Knight Rider Clockwise)

  84. ambilight_audio_knight_rider_2 - Sets Ambilight to 'Follow audio' (Knight Rider Alternating)

  85. ambilight_audio_flash - Sets Ambilight to 'Follow audio' (Random Pixel Flash)

  86. ambilight_audio_strobo - Sets Ambilight to 'Follow audio' (Stroboscope)

  87. ambilight_audio_party - Sets Ambilight to 'Follow audio' (Party)

  88. ambilight_audio_random - Sets Ambilight to 'Follow audio' (Random Mode)

    Other:

  89. launch_app - Launches an app (Android TVs only). Requires a valid --body argument. See the API reference to get a list of installed apps, find your app in this list and use it as a --body argument.

  90. power_on - Turns on the TV even if it's in a deep sleep mode. You might need to run allow_power_on first, although it was not needed for me.

  91. allow_power_on - Allows to remotely power on the TV via chromecast requests.

  92. google_assistant - Allows to pass requests to Google Assistant if your model supports it. Requires a --body argument containing a query with the command that you want to pass to Google Assistant. See example below.

Examples of using the built-in commands:

Send Stop key:

python3 pylips.py --host %TV's_ip_address% --user %username% --pass %password% --command stop

Turn Ambilight on:

python3 pylips.py --host %TV's_ip_address% --user %username% --pass %password% --command ambilight_on

Launch YouTube:

…

Launch Netflix:

python3 pylips.py --host %TV's_ip_address% --user %username% --pass %password% --command launch_app --body '{"label":"Netflix","intent":{"component":{"packageName":"com.netflix.ninja","className":"com.netflix.ninja.MainActivity"},"action":"Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 pkg=com.netflix.ninja cmp=com.netflix.ninja/.MainActivity }"},"order":0,"id":"com.netflix.ninja.MainActivity-com.netflix.ninja","type":"app"}'

Launch Amazon Prime Video:

python3 pylips.py --host %TV's_ip_address% --user %username% --pass %password% --command launch_app --body '{"id":"com.amazon.amazonvideo.livingroom","order":0,"intent":{"action":"Intent{act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 pkg=com.amazon.amazonvideo.livingroom }","component":{"packageName":"com.amazon.amazonvideo.livingroom","className":"com.amazon.ignition.IgnitionActivity"}},"label":"Prime Video"}'

Launch Kodi:

python3 pylips.py --host %TV's_ip_address% --user %username% --pass %password% --command launch_app --body '{"id":"org.xbmc.kodi","order":0,"intent":{"action":"Intent{act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 pkg=org.xbmc.kodi }","component":{"packageName":"org.xbmc.kodi","className":"org.xbmc.kodi.Splash"}},"label":"Kodi"}'

Switch input to HDMI 1 using a built-in command (requires Google Assistant):

python3 pylips.py --host %TV's_ip_address% --user %username% --pass %password% --command input_hdmi_1

Switch input to any source (for example, SCART) using Google Assistant directly:

python3 pylips.py --host %TV's_ip_address% --user %username% --pass %password% --command google_assistant --body '{"query":"SCART"}'

Control connected lights in your house using Google Assistant:

python3 pylips.py --host %TV's_ip_address% --user %username% --pass %password% --command google_assistant --body '{"query":"Turn on lights"}'

Custom commands

The tools exposes two general commands to talk to the TV's API: get (sends GET request and gets back some data like ambilight mode) and post (sends POST request that posts some data and changes something in the TV - like turning the ambilight off). You can also add custom commands to available_commands.json.

Read the API reference first to understand available endpoints and how to use them. There are some unexpected things like:

  • Pairing process returns objects like '{"error_id":"SUCCESS"}' (why, Philips?!)
  • Using strings like 'On'/'Off' for boolean variables (really, Philips?!)
  • API returns 'Nodeid' for some GET r

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Pythonambilighthome-automationphilipsphilips-hue

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言