Introduction
This article will guide you on how to remotely control the TV screen's ON/OFF function. To achieve remote control, the media player will send a HDMI CEC command to control the power status of the TV. This article will showcase the use of the EnableJS and EELM APIs to send HDMI CEC commands with your media player.
Prerequisites
Understanding of how to program with EnableJS. The ability to use restful APIs.
Having the required key pair to access HTTPS EELM (for secure deployment).
Summary
There are 2 methods to accomplish the goal of remote controlling the TV screen ON/OFF:
- EnableJS
- EELM APIs
Which method you choose depends on the programming language of your application and the network of your deployment.
Control with EnableJS
To remote control the power status of the TV Screen you are required to enable the CEC feature and configure the required CEC standby direction. Under normal circumstances, the CEC feature should be "enabled" with "stb2tv" as the CEC standby direction. To achieve the requirement, you are advised to configure the following JS call:
ENABLE.cec.setCecSettings({"cec_enable":true, "cec_standby":"stb2tv"})
The current CEC setting can be obtained with the following JS Call:
ENABLE.cec.getCecSettings();
Checking the CEC configuration of your media player:
cec_enable: true
cec_one_touch_play: true
cec_osd_name: "H200"
cec_remote_control: true
cec_standby: "stb2tv"
To Turn ON your TV Screen, run the following command:
ENABLE.cec.setTVConfig({"power_on":true})
To Turn OFF your TV Screen, run the following command :
ENABLE.cec.setTVConfig({"power_on":false})
Control with EELM API
For simplicity of illustration, all the EELM calls shown below are plain HTTP requests. Consider using HTTPS with an SSL certification and encryption key for security reasons.
Similar to the previous section. You are required to "enable" CEC and configure "stb2tv" as the direction of CEC control. To achieve the requirement, you are advised to configure the following EELM call:
curl -X 'PUT' 'http://<Your_mediaplayer_ip>:8090/api/v2/device/hdmiCec/standbyMode' -d '{"mode": "stb2tv"}'
The current CEC setting can be obtained with the following EELM Call:
curl -X 'GET' 'http://<Your_mediaplayer_ip>:8090/api/v2/device/hdmiCec/standbyMode'
Checking the CEC configuration of your media player:
{
"mode": "tv2stb"
}
To Turn ON your TV Screen, run the following command:
curl -X 'PUT' http://<Your_mediaplayer_ip>:8090/api/v2/device/hdmiCec/tv -d '{"power_on": true}'
To Turn OFF your TV Screen, run the following command:
curl -X 'PUT' http://<Your_mediaplayer_ip>:8090/api/v2/device/hdmiCec/tv -d '{"power_on": false}'