This page last changed on Nov 18, 2015 by ptruman.

Hello

It's been a while, but I've just acquired a new Smart TV (WebOS) and am slowly wiring it up to OpenRemote. Amusingly the TV can be shutdown via TCP/IP but not started, and some of the APIs are lacking, so I've got a split between IR and TCP controls. This means I have to start the TV with IR, and don't have a discrete IR code (yet) so am using a sensor to track the power state. Except it's not working.

In logs/dev/dev/log I can see :

2015-11-18 11:06:52,652 WARN HTTP\-Thread\-64: Unknown virtual protocol property '<property name = "name" value = "TV_Power_Set_Off"/>'.
2015-11-18 11:06:59,616 WARN HTTP\-Thread\-62: Unknown virtual protocol property '<property name = "name" value = "TV_Power_Set_On"/>'.

In controller.xml I have the following defined (from the designer) :

The Sensor - which uses TV_Power_Get_State to find the 'status' of the IMVC 'tvpower' :

<sensor id="107672269" name="Sensor_TV_Power" type="switch">
<include type="command" ref="740" />
<state name="on" />
<state name="off" />
</sensor>

My IMVC is defined thus (on, off and status) :

<command id="738" protocol="virtual">
<property name="address" value="tvpower" />
<property name="command" value="on" />
<property name="name" value="TV_Power_Set_On" />
</command>
<command id="739" protocol="virtual">
<property name="address" value="tvpower" />
<property name="command" value="off" />
<property name="name" value="TV_Power_Set_Off" />
</command>
<command id="740" protocol="virtual">
<property name="address" value="tvpower" />
<property name="command" value="status" />
<property name="name" value="TV_Power_Get_State" />
</command>

A switch, to test it (which uses the IMVC commands to set on/off) :

<sensor id="107672269" name="Sensor_TV_Power" type="switch">
<include type="command" ref="740" />
<state name="on" />
<state name="off" />
</sensor>

And in the modeler_rules.drl I have:

rule "Turn_TV_On"
when
Switch( source == "Sensor_TV_Power", value == "on" )
then
execute.command("TV_Power");
end

rule "Turn_TV_Off"
when
Switch( source == "Sensor_TV_Power", value == "off" )
then
execute.command("TV_Off");
end

My modeler rules match what I have for another device which works.

What am I missing?!

In other news - if anyone else wants to play with LG WebOS TVs - I'm using NPM with an NPM package called lgtv, and have wrapped some scripts to call some functions and it's working - although there are some npm permissions I need to sort out as it got installed with specific user permissions :\

Hi

Just a curve ball...

Have you tried sending the TV a Wake On LAN signal?

I've no idea how that could be fired from OpenRemote, but it might give you an option to 'Switch On' TV.

Good luck

Posted by mdar at Nov 18, 2015 20:42

Hi Stuart

Doesnt work - The TV shuts down the NIC when in standby. Stupid, but true.

And either way, my code should be working

Also re WOL, if you have a WOL executable, OR can run it, just set the device type appropriately

Posted by ptruman at Nov 18, 2015 21:26

Hi Peter,

Have you tried HDMI CEC? There was some mention of it on the forum. Anyway, I have RP2 with Kodi and CEC. It is able to power on my Samsung TV.

Posted by aktur at Nov 19, 2015 07:24

Hi Michal,

Yes, I've tried HDMI CEC but my setup makes that a problem.

My TV is connected to an Onkyo AMP, which has RHID (aka CEC) pass through enabled, and the TV can wake up when another downstream device (PS3, PS4 etc) wake up....the TV can also see all HDMI CEC compliant devices linked via the Onkyo (PS3, PS4 and a Chromecast).

However:

a) My cable box does not send HDMI CEC, so there is an issue there in waking up (without first turning on something else, switching inputs and switching the first device back off)

b) For some reason, if I use the TV remote to change input to HDMI1 (which is connected to the Onkyo), the Onkyo seems to pass a signal to the Chromecast (or the Chromecast just listens to anything) and defaults the Onkyo input to the Chromecast (which is quite annoying)

c) Due to the lack of cable box CEC, the TV will not shutdown if the cable box shutsdown (although I can work aound that)

d) I'm tempted to hook my rPi back up, as that's got HDMI with CEC (via Kodi etc) so might be capable of a kludge

But that still doesn't answer why my IMVC/rule isn't working

Posted by ptruman at Nov 19, 2015 09:19

You can also install libcec on RP2 standalone, without KODI. Then you can call it through command line interface.

Posted by aktur at Nov 19, 2015 11:31

But that still doesn't answer why my IMVC/rule isn't working

Please show your whole rule file or at least header of the file including rules. Also take a look in logs/boot.log to see if there were no errors when parsing the drl.
Also, I never have a reason to use other sensors than custom one and use 'when Event()' in rules. Linking the output of sensor to a label usually shows what it really is. For example

"ON"!="on"!="On"!=1
etc.

Posted by aktur at Nov 19, 2015 11:35

Hi

Here are the last boot.log restart messages....
I have put a >> at the start of the line referencing the relevant sensor...
No parse errors shown.

INFO 2015-11-18 01:46:55,756 : Initialized event processor : Drools Rule Engine
INFO 2015-11-18 01:46:55,781 : Initialized event processor : RRD4J Data Logger
INFO 2015-11-18 01:46:55,781 : Initialized event processor : EmonCMS Data Logger
INFO 2015-11-18 01:46:55,838 : Registered sensor : Sensor (Name = 'Hue_2_Sensor_Power', ID = '103568792', State Mappings: {true=on, false=off})
INFO 2015-11-18 01:46:55,839 : Registered sensor : Sensor (Name = 'Hue_2_Sensor_Reachable', ID = '103568793', State Mappings: {false=Unavailable, true=Available})
INFO 2015-11-18 01:46:55,840 : Registered sensor : Range Sensor (Name = 'Hue_0_Sensor_Bri', ID = '103568694', Min: 0, Max: 255)
INFO 2015-11-18 01:46:55,841 : Registered sensor : Range Sensor (Name = 'Hue_Side_Sensor_Bri', ID = '102962225', Min: 0, Max: 255)
INFO 2015-11-18 01:46:55,842 : Registered sensor : Switch Sensor (Name = 'Sensor_Heating_State', ID = '103568764')
INFO 2015-11-18 01:46:55,842 : Registered sensor : Sensor (Name = 'Hue_0_Sensor_Power_Custom', ID = '103568696', State Mappings: {true=on, false=off})
INFO 2015-11-18 01:46:55,850 : Registered sensor : Level Sensor (Name = 'Fireplace_Dimmer_LevelSensor', ID = '106629083', Min: 0,Max: 100)
INFO 2015-11-18 01:46:55,852 : Registered sensor : Sensor (Name = 'Hue_5_Sensor_Power', ID = '103568784', State Mappings: {true=on, false=off})
INFO 2015-11-18 01:46:55,857 : Registered sensor : Sensor (Name = 'Hue_Side_Sensor_Reachable', ID = '102962743', State Mappings: {false=Unavailable, true=Available})
INFO 2015-11-18 01:46:55,857 : Registered sensor : Sensor (Name = 'Hue_0_Sensor_Virtual_Colour', ID = '103568698', State Mappings: {})
INFO 2015-11-18 01:46:55,858 : Registered sensor : Sensor (Name = 'Hue_Side_Sensor_Power_Custom', ID = '102962742', State Mappings: {true=on, false=off})
>> INFO 2015-11-18 01:46:55,868 : Registered sensor : Switch Sensor (Name = 'Sensor_TV_Power', ID = '107672269')
INFO 2015-11-18 01:46:55,868 : Registered sensor : Range Sensor (Name = 'Fireplace_Dimmer_SetDimmer', ID = '106629087', Min: 0, Max: 32)
INFO 2015-11-18 01:46:56,216 : Registered sensor : Sensor (Name = 'Hue_5_Sensor_Reachable', ID = '103568783', State Mappings: {false=Unavailable, true=Available})
INFO 2015-11-18 01:46:56,223 : Registered sensor : Sensor (Name = 'Hue_Side_Sensor_Virtual_Colour', ID = '102962221', State Mappings: {})
INFO 2015-11-18 01:46:56,232 : Registered sensor : Switch Sensor (Name = 'Sensor_Fireplace_Lights_State', ID = '103568680')
INFO 2015-11-18 01:46:56,239 : Registered sensor : Switch Sensor (Name = 'Sensor_Fire_State', ID = '103595148')
INFO 2015-11-18 01:46:56,250 : Startup complete.

Here is the header of the modeler_rules.drl file :

package org.openremote.controller.model.event

import java.awt.Color;
global org.openremote.controller.statuscache.CommandFacade execute;
global org.openremote.controller.statuscache.SwitchFacade switches;
import org.openremote.controller.protocol.*;

Full file is 103 lines - relevant sensor related event lines in the OP.
I'm using other sensors for Lightwave and those work ok....

Posted by ptruman at Nov 19, 2015 14:32

It's an option - but given my boxes HDMI fighting, I'd prefer to sort that separately
Currently I can't use TV ARC without CEC being on either - but need to find out why the Chromecast is a focus stealer when it's not in the signal instruction path.

Posted by ptruman at Nov 19, 2015 14:34

Hmmm, even though it's not showing any parse errors, it's definitely looking like something in there.
I recreated (entirely) my commands/switch/sensor with new names, and got the same error.

I also noticed my lights (sensor based) were not working.

I removed the new chunk in the rules, lights work. I moved the chunk, lights work, but still get the original error.

Here is the rules file WITHOUT the new TV bits as posted above. The two/three line gap is where I removed it from.
Any clues? I can't find a drules parser, but setup Notepad++ for drules and it still looks ok to me....

package org.openremote.controller.model.event

import java.awt.Color;
global org.openremote.controller.statuscache.CommandFacade execute;
global org.openremote.controller.statuscache.SwitchFacade switches;
import org.openremote.controller.protocol.*;


function int[] rgb2hue(Object param) {
   String value = (String) param;
    int r = Integer.parseInt(value.substring(0, 2), 16);
    int g = Integer.parseInt(value.substring(2, 4), 16);
    int b = Integer.parseInt(value.substring(4, 6), 16);
    float hsb[] = Color.RGBtoHSB(r, g, b, null);
    int[] result = new int[3];

    result[0] = (int) (hsb[0] * 65535);
    result[1] = (int) (hsb[1] * 255);
    result[2] = (int) (hsb[2] * 255);
    return result;
}

rule "Hue_0_Colour_Picker"
when
  CustomState ( source == "Hue_0_Sensor_Virtual_Colour", $rgb : value )
then
  execute.command("Hue_0_Set_Hue", rgb2hue($rgb)[0]);
  execute.command("Hue_0_Set_Sat", rgb2hue($rgb)[1]);
  execute.command("Hue_0_Set_Bri", rgb2hue($rgb)[2]);
end

rule "Hue_Side_Colour_Picker"
when
  CustomState ( source == "Hue_Side_Sensor_Virtual_Colour", $rgb : value )
then
  execute.command("Hue_Side_Set_Hue", rgb2hue($rgb)[0]);
  execute.command("Hue_Side_Set_Sat", rgb2hue($rgb)[1]);
  execute.command("Hue_Side_Set_Bri", rgb2hue($rgb)[2]);
end



rule "Turn_Fireplace_Lights_On"
when
    Switch( source == "Sensor_Fireplace_Lights_State", value == "on" )
then
  execute.command("Fireplace_Lights_On");
end

rule "Turn_Fireplace_Lights_Off"
when
    Switch( source == "Sensor_Fireplace_Lights_State", value == "off" )
then
  execute.command("Fireplace_Lights_Off");
end

rule "Turn_Heating_On"
when
    Switch( source == "Sensor_Heating_State", value == "on" )
then
  execute.command("Heating_On");
end

rule "Turn_Heating_Off"
when
    Switch( source == "Sensor_Heating_State", value == "off" )
then
  execute.command("Heating_Off");
end

rule "Turn_Fire_On"
when
    Switch( source == "Sensor_Fire_State", value == "on" )
then
  execute.command("Fire_On");
end

rule "Turn_Fire_Off"
when
    Switch( source == "Sensor_Fire_State", value == "off" )
then
  execute.command("Fire_Off");
end
Posted by ptruman at Nov 20, 2015 10:00

Please try replace 'when Switch()' with 'when Event()'. Personally, I never used 'when Switch()' so I cannot be sure that there is no bug there. Also remember, that in some older versions of the controller you must reboot the controller after design syncing. This is particularly true when using rules and command-line execution protocol. I would not be too much surprised if some other parts are broken too.

Posted by aktur at Nov 20, 2015 10:57

Will try that later.
I'm (still) using OpenRemote-Controller-2.1.0_FM_SNAPSHOT-2013-07-18 as I seem to recall I had problems with Hue in a later build.

Posted by ptruman at Nov 20, 2015 12:25

I tried CEC again last night and realised I forgot to post something else.

Not only does switching TV to HDMI1 bizarrely switch the Onkyo to the Chromecast input, it also sends a CEC power on to my PS4. Both are on different Onkyo HDMI ports. The PS4 then hijacks the input signal - so definitely more bother than required

Posted by ptruman at Nov 20, 2015 12:26
Document generated by Confluence on Jun 05, 2016 09:33