LG WebOS Binding Toast

Hi All,

I’ve had the official LG web(os) binding working perfectly for a while now, but have just decided to use the toast option, (ie send a message to the TV), in a couple of rules to push a message onto the TV.

However, it isn’t working and I’m not sure why. I know the thing / items / channels are working fine as everything else is ok…

Items:

Switch TV_LG_Power         "TV Power"      <television>    { autoupdate="false", channel="lgwebos:WebOSTV:my_code_here:power" }
Switch TV_LG_Mute          "TV Mute"                       { channel="lgwebos:lgwebos:WebOSTV:my_code_here:mute"}
Dimmer TV_LG_Volume        "Volume [%S]"                   { channel="lgwebos:lgwebos:my_code_here:volume" }
Number TV_LG_VolDummy      "VolumeUpDown"                  
Number TV_LG_ChannelNo     "Channel [%d]"                  { channel="lgwebos:lgwebos:WebOSTV:my_code_here:channel" }
Number TV_LG_ChannelDummy  "ChannelUpDown"
String TV_LG_Channel       "Channel [%S]"                  { channel="lgwebos:lgwebos:WebOSTV:my_code_here:channelName"}
String TV_LG_Toast                                         { channel="lgwebos:lgwebos:WebOSTV:my_code_here:toast"}
Switch TV_LG_Stop          "Stop"                          { autoupdate="false", channel="lgwebos:lgwebos:WebOSTV:my_code_here:mediaStop" }
String TV_LG_Application   "Application [%s]"              { channel="lgwebos:lgwebos:WebOSTV:my_code_here:appLauncher"}
Player TV_LG_Player                                        { channel="lgwebos:lgwebos:WebOSTV:my_code_here:mediaPlayer"}
Switch TV_LG_WOL           "WOL"                           { wol="my broadcast IP#TV Mac" }

I set a dummy item to use on the basic UI as a switch for testing my rule:

Switch vTVMessage "TV Message"

And then here’s the basic rule:

rule "Send Message"
when 
Item vTVMessage changed
then
    actions.showToast("Hello World")
    actions.showToast("http://opehabIP:8080/icon/energy?format=png","Hello World")
end

Thought I’d try just a simple rule to get it working. There are 2 different actions.showToast in the rule as I wanted to see if either / both ways worked and if there was a difference on the TV.

However, with one, both, either of the actions in the rule I still get the same error. Pretty unhelpful as far as I can see…

Rule 'Send Message': An error occurred during the script execution: index=0, size=0

I’ve trawled the forums to see what the error means and if others have had an issue. It does seem that the toast option is a bit hit and miss but I’d love some comments on if there is an error in the code, what the error means and if anyone else has had success with the toast method.

Rasp Pi 3, openhabian 2.4, LG webOS Binding / binding-lgwebos-2.4.0

At least in your posted rule code the actions variable seems to be uninitialized. Did you see this code fragment in the binding’s documentation?

Hi,

Yes, I can’t see until I get home but I think that bit of code might sit outside the rule, sorry forgot to copy it in here…I’m now wondering if it is, then it should go inside the rule “Send Message” or if it needs some extra wrapper or script around it…

Hi,

So I’ve added the snippet into the rule and it now runs but it returns null as it shows the loginfo rather than running the showToast…

rule "Send Message"
when 
Item vTVMessage changed
then
    val actions = getActions("lgwebos","my binding id")
    if(null === actions) 
    {
        logInfo("actions", "Actions not found, check thing ID")
        return
    }
    actions.showToast("Hello World")
    actions.showToast("http://my pi IP:8080/icon/energy?format=png","Hello World")
end

Any ideas where I’m going wrong? What do I have to put into the first part of the

 val actions = getActions("lgwebos","my binding id")

?

Hi,

A bit of fiddling and I’ve got it working simply using:

my LG Toast item name.sendCommand(“Hello World”)

within a rule, think I was perhaps making it a bit too complicated…

Hi,

I have a similar problem.
I don´t get the actions working. I´m using the same code as MadFrankie

when 
Item vTVMessage changed
then
    val actions = getActions("lgwebos","my binding id")
    if(null === actions) 
    {
        logInfo("actions", "Actions not found, check thing ID")
        return
    }
    actions.showToast("Hello World")
  end

But in my Log there is always the error message: “Actions not found, check thing ID”. But I checked the ID and it should be right, but the error is still the same. I don´t find my mistake.