Hello,
I have a Samsung TV i’d like to switch off.
It’s not possible with the SAMSUNG TV Binding.
I have a PI connected to the TV with KODI running.
[EDIT: the KODI addon is not necessary see below]
There’s a KODI addon to control CEC via RPC JSON
My rule to switch the TV ON or OFF is not working, here it is
var String kodiUrl = 'http://kodi:kodi@192.168.1.42:9090/jsonrpc?request='
rule "kodi CEC activate"
when
Item MENU_VIDEO_TV_ON received command
then
var String content1 = '{"jsonrpc":"2.0","method":"Addons.ExecuteAddon","params":{"addonid":"script.json-cec","params":{"command":"activate"}},"id":"1"}'
sendHttpPostRequest(kodiUrl,'application/json',content1)
end
rule "kodi CEC standby"
when
Item MENU_VIDEO_TV_OFF received command
then
var String content2 = '{"jsonrpc":"2.0","method":"Addons.ExecuteAddon","params":{"addonid":"script.json-cec","params":{"command":"standby"}},"id":"1"}'
sendHttpPostRequest(kodiUrl,'application/json',content2)
end
There is another option that doesn’t require the use of any Kodi addons, which can potentially be broken by a Kodi update…
Given the Pi will be running a flavour of linux you can configure OpenHAB to execute a command remotely on the Pi to send the cec commands to the television using the exec binding with SSH key access.
I use exactly this method to switch my Samsung TV and Virgin Media set top box on and off via a voice command thru Alexa.
Are you running Kodi on Raspbian or via something such as OSMC or RaspBMC?
My PI attached to the TV is running Libreelec KODI (IP 192.168.1.42). I didn’t change anything on it.
root user’s password is ‘libreelec’
Here’s what I did on the PI running Openhabian
Install sshpass
sudo apt-get install sshpass
Connect once to librelec to validate the certificate (with user openhab, because this is with this user’s context the Exec Binding is executed)
sudo -u openhab ssh 192.168.1.42
The authenticity of host '192.168.1.42 (192.168.1.42)' can't be established.
ECDSA key fingerprint is SHA256:iPpN3RPJdbnMm/b8iY6SwAsvmBExgQgYTbvkpwljayA.
Are you sure you want to continue connecting (yes/no)? yes