Python remote control gateway for sony bravia tv
Project description
Python remote control for Sony Bravia TV
Author | Denis Machard d.machard@gmail.com |
License | MIT |
PyPI | https://pypi.org/project/sonybravia-remotecontrol/ |
This is a Python remote control gateway for Sony Bravia TV with minimal but sufficient basic controls. This remote control acts as a websocket Gateway of the Simple IP API for more reactivity. More details on Simple IP control https://pro-bravia.sony.net/develop/integrate/ssip/overview/index.html
Table of contents
Installation
pip install sonybraviatv_remotecontrol
Start remote control
As prerequisite configure your TV,
-
Enable remote device control
[HOME] Settings > Network > Home network setup > Renderer > Renderer function > Enable [Default: Enable]
-
Enable “Simple IP control”
[HOME] Settings > Network > Home network setup > IP control > Simple IP control > Enable [Default: Disable]
After that, you can start the remote control and provides the address IP of your Sony bravia TV.
sonybraviatv_remotecontrol --help
usage: sonybraviatv_remotecontrol [-h] [--destport DESTPORT] [--desthost DESTHOST]
[--bindport BINDPORT] [--bindhost BINDHOST]
optional arguments:
-h, --help show this help message and exit
--destport DESTPORT destination backend tcp port default=20060
--desthost DESTHOST destination backend host address default=127.0.0.1
--bindport BINDPORT bind on port default=8081
--bindhost BINDHOST bind on host default=0.0.0.0
Available buttons
To interact with the remote control, you need to use a websocket client and
send the following JSON commands to the address ws://<remotecontrol_ip>:8081
.
Power ON/OFF
{"button": "press_poweron"} // press on power on button
{"button": "press_poweroff"} // press on power off button
Channel selection
{"button": "press_channel<id>"} // press on channel<1...XX> button
Volume
{"button": "press_volup"} // press on volume up button
{"button": "press_voldown"} // press on volume down button
{"button": "press_mute"} // press on mute button
TV Navigation
{"button": "press_up"} // press on up button
{"button": "press_down"} // press on down button
{"button": "press_left"} // press on left button
{"button": "press_right"} // press on right button
{"button": "press_back"} // press on back button
{"button": "press_confirm"} // press on confirm button
HDMI selection
{"button": "press_hdmi<id>"} // press on channel<1..4> button
Miscs buttons
{"button": "press_netflix"} // press on netflix button
{"button": "press_home"} // press on home button
Websocket client
Basic demo
<html>
<head>
<title>RemoteControl demo</title>
<style type="text/css">
.buttons {
font-size: 1em;
display: flex;
justify-content: center;
}
.button {
padding: 2rem;
border: medium solid;
min-height: 1em;
min-width: 1em;
cursor: pointer;
user-select: none;
}
</style>
</head>
<body>
<div class="buttons">
<div class="poweron button">ON</div>
<div class="poweroff button">OFF</div>
</div>
<script>
var websocket = new WebSocket("ws://localhost:8081/");
var poweron = document.querySelector('.poweron')
var poweroff = document.querySelector('.poweroff')
poweron.onclick = function (event) {
websocket.send(JSON.stringify({button: 'press_poweron'}));
}
poweroff.onclick = function (event) {
websocket.send(JSON.stringify({button: 'press_poweroff'}));
}
</script>
</body>
</html>
Systemd service
Example of system service file for Centos7
vim /etc/systemd/system/sonybraviatv_remotecontrol.service
[Unit]
Description=Sony Bravia TV remote control Service
After=network.target
[Service]
ExecStart=/usr/local/bin/sonybraviatv_remotecontrol --desthost=10.0.0.200
Restart=on-abort
Type=simple
User=root
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl start sonybraviatv_remotecontrol
systemctl status sonybraviatv_remotecontrol
systemctl enable sonybraviatv_remotecontrol
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for sonybraviatv_remotecontrol-0.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2a9da6e65f42154cbf932e0e088d3e2dfc4868dcc272845ffbef00315816570 |
|
MD5 | b97e94fc7f78095ca01543b4e664db97 |
|
BLAKE2b-256 | 9c88f3e4f013f012ba8ecfb1e926cf4cb34658396aaede18fcdf86b1b4b93499 |
Hashes for sonybraviatv_remotecontrol-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ff67682e5b6797f230eb639adb499b9b29c7dc0dda654b54678606638024dae |
|
MD5 | 519ba370353cff55a4d24b7cf0d985c2 |
|
BLAKE2b-256 | 5e621995cf903d06701b43446a5ce18bceaa1c68d02b85a755d334adc4e72ba2 |