I’ve been running OH2 for the past few years and have refined my rules over this time. Now seems to be a good time to migrate onto OH3 and use some of the new bindings and functionally on offer. My plan is to migrate in small steps and with the least amount of impact.
As I take my first steps I’ve come across a problem that I need help to resolve.
I live in the UK and use the Satellite TV provider Sky, they don’t offer any form of API to work with their set-top box. Named Sky Q. However thanks to sky-remote-cli - npm and GitHub - dalhundal/sky-q: A Node module for interacting with Sky Q boxes it’s possible to interact with the Sky Q box to a degree.
I the idea of the script below is to check the status of the Sky Q box when the TV is switched on and to update a virtual/proxy Switch. However I get this error:
Script execution of rule with UID 'Living_Room-1' failed: An error occurred during the script e
xecution: array element type mismatch in Living_Room
The output of vSkyQ_Status is: null. Where, as you can see from the script below it should either be ON or OFF. The rule works fine using OH2, so clearly something needs to be adjusted to make it now work in the same way with OH3 and therefore I’m looking for some assistance.
rule "Check SkyQ Status"
when
Item Livingroom_TV_vSwitch changed
then
logInfo(logName, "System Message: Updating SkyQ Status.")
var vSkyQ_Status executeCommandLine("/etc/openhab/scripts/SkyQ.sh")
Livingroom_SkyQ_Switch.sendCommand(vSkyQ_Status)
end
Below is the contains of SkyQ.sh
const SkyQ = require('/etc/openhab/scripts/node_modules/sky-q');
const box = new SkyQ({ip:'192.168.10.59'})
// Where 10.10.10.10 is the address of the SkyQ box you want to interact with
box.getPowerState().then(isOn=>{
if (isOn) {
console.log("ON")
// $('.btn').click(function()) {
// $.post(Url,"ON");
} else {
console.log("OFF")
}
// $('.btn').click(function()) {
// $.post(Url,"OFF");
})