[SOLVED] Command exec works in sitemap but not in rules anymore

Hi,

  • Platform information:

    • Hardware: Raspberry 3
    • OS: Openhabianpi
    • Java Runtime Environment:
    • openHAB version: 2.4.0-SNAPSHOT (#1302)
  • Issue of the topic:
    I have a rule which turns 4 items on.
    This has worked in the past but after a few updates of the openhabianpi platform, suddenly the command exec items seem to have a problem,
    Manually turning each item of the command exec items on via the smartphone app works fine.
    The log also shows no problem.

Can you advise on what I can check?
Thanks

things:

Thing exec:command:elro1 [ command="/usr/local/bin/pilight-control -d elrostecker1 -s %2$s", interval=0, timeout=5, autorun=true ]
Thing exec:command:elro2 [ command="/usr/local/bin/pilight-control -d elrostecker2 -s %2$s", interval=0, timeout=5, autorun=true ]
Thing exec:command:elro3 [ command="/usr/local/bin/pilight-control -d elrostecker3 -s %2$s", interval=0, timeout=5, autorun=true ]
Thing exec:command:elro4 [ command="/usr/local/bin/pilight-control -d elrostecker3 -s %2$s", interval=0, timeout=5, autorun=true ]
Thing exec:command:elro5 [ command="/usr/local/bin/pilight-control -d elrostecker4 -s %2$s", interval=0, timeout=5, autorun=true ]
  • Items configuration related to the issue:
String elroexe_1 { channel="exec:command:elro1:input"}
String elroexe_2 { channel="exec:command:elro2:input"}
String elroexe_3 { channel="exec:command:elro3:input"}
String elroexe_4 { channel="exec:command:elro4:input"}
String elroexe_5 { channel="exec:command:elro5:input"}
  • Sitemap configuration related to the issue
sitemap i2 label="impaler2's realm"
{




  Frame label="Lights" icon="network" {
Switch item=gLights

Switch  item=elroexe_1 label="Fluter" mappings=[ on="ON", off="OFF" ]
Switch  item=elroexe_2 label="TV Backlight" mappings=[ "on"="ON", "off"="OFF" ]
Switch  item=elroexe_3 label="Bath" mappings=[ "on"="ON", "off"="OFF" ]
Switch  item=elroexe_4 label="Bath new" mappings=[ "on"="ON", "off"="OFF" ]
Switch  item=elroexe_5 label="TV & Sound" mappings=[ "on"="ON", "off"="OFF" ]

Switch      item=Ufoled_11 label="Power"
Colorpicker item=Ufoled_13 label="Color"
Slider      item=Ufoled_12 label="White"
Slider      item=Ufoled_14 label="White2"

Switch      item=Ufoled_21 label="Power"
Colorpicker item=Ufoled_23 label="Color"
Slider      item=Ufoled_22 label="White"
Slider      item=Ufoled_24 label="White2"

Colorpicker item=Ufoledshare label="Colorshare"
  }



	Frame label="Presence" icon="network" {

Switch item=Presence_Mobile_S7 label="impaler2's mobile"
Switch item=Presence_Dash label="dash"
Switch item=Presence_Ddwrt label="ddwrt"
Switch item=Presence_libreelec label="kodi"
Switch item=Presence_Apple label="iphone"
Switch item=Presence_stfu323 label="NAS stfu323"
Switch item=Presence_stfuplay label="NAS stfuplay"
Switch item=Presence_tablet label="tablet"
Switch item=Presence_openhabianpi label="openhab"
Switch item=Presence_stfu7 label="PC win7"
	
}


Frame label="Sensors" icon="network" {

  Switch item=Door_Sensor label="door sensor 45"	


}


    Frame label="myKodi" {
        Switch    item=myKodi_mute
        Slider    item=myKodi_volume
        Selection item=myKodi_control mappings=[PLAY='Play', PAUSE='Pause', NEXT='Next', PREVIOUS='Previous', FASTFORWARD='Fastforward', REWIND='Rewind']
        Default   item=myKodi_control
        Switch    item=myKodi_stop
        Text      item=myKodi_title
        Text      item=myKodi_showtitle
        Text      item=myKodi_album
        Text      item=myKodi_artist
        Text      item=myKodi_pvrchannel
        Selection item=myKodi_input mappings=[Up='Up', Down='Down', Left='Left', Right='Right', Select='Select', Back='Back', Home='Home', ContextMenu='ContextMenu', Info='Info']
        Selection item=myKodi_systemcommand mappings=[Shutdown='Herunterfahren', Suspend='Bereitschaft', Reboot='Neustart']
        Text      item=myKodi_mediatype
    }






}
  • Rules code related to the issue
rule "gLights all on"

  when
    Item gLights received command ON
  then {
    logInfo("Network", "turning elroexe_1, elroexe_2, Ufoled_11, Ufoled_21 on")
    elroexe_1.sendCommand("on")
    elroexe_2.sendCommand("on")
    Ufoled_11.sendCommand(ON)
    Ufoled_21.sendCommand(ON)

    //sendCommand(Ufoled_13,HSBType::BLUE)

var Integer RandomInterval = ((Math::random * 360) + 1).intValue

   logInfo( "Ufoled_13", "random value:" + RandomInterval ) 
var DecimalType hue = new DecimalType(RandomInterval) // 0-360; 0=red, 120=green, 240=blue, 360=red(again) 25=light orange 60=yellow 306=purple 173=turquoise
var PercentType sat = new PercentType(100) // 0-100
var PercentType bright = new PercentType(50) // 0-100
var HSBType light = new HSBType(hue,sat,bright)
sendCommand(Ufoled_13, light)
sendCommand(Ufoled_23, light)
  }
end
  • If logs where generated please post these here using code fences:
2018-06-24 18:23:26.198 [ome.event.ItemCommandEvent] - Item 'gLights' received command ON

==> /var/log/openhab2/openhab.log <==

2018-06-24 18:23:26.215 [INFO ] [lipse.smarthome.model.script.Network] - turning elroexe_1, elroexe_2, Ufoled_11, Ufoled_21 on

==> /var/log/openhab2/events.log <==

2018-06-24 18:23:26.234 [ome.event.ItemCommandEvent] - Item 'elroexe_1' received command on

2018-06-24 18:23:26.253 [ome.event.ItemCommandEvent] - Item 'elroexe_2' received command on

==> /var/log/openhab2/openhab.log <==

2018-06-24 18:23:26.278 [INFO ] [pse.smarthome.model.script.Ufoled_13] - random value:297

==> /var/log/openhab2/events.log <==

2018-06-24 18:23:26.273 [ome.event.ItemCommandEvent] - Item 'Ufoled_11' received command ON

2018-06-24 18:23:26.308 [ome.event.ItemCommandEvent] - Item 'Ufoled_21' received command ON

2018-06-24 18:23:26.328 [vent.ItemStateChangedEvent] - elroexe_1 changed from off to on

2018-06-24 18:23:26.334 [vent.ItemStateChangedEvent] - elroexe_2 changed from off to on

2018-06-24 18:23:26.339 [vent.ItemStateChangedEvent] - Ufoled_11 changed from OFF to ON

2018-06-24 18:23:26.356 [ome.event.ItemCommandEvent] - Item 'Ufoled_13' received command 297,100,50

2018-06-24 18:23:26.367 [vent.ItemStateChangedEvent] - Ufoled_21 changed from OFF to ON

2018-06-24 18:23:26.374 [ome.event.ItemCommandEvent] - Item 'Ufoled_23' received command 297,100,50

2018-06-24 18:23:26.391 [vent.ItemStateChangedEvent] - Ufoled_13 changed from 92.12598323822021484375000,100,49.8039215803146362304687500 to 297,100,50

2018-06-24 18:23:26.402 [vent.ItemStateChangedEvent] - Ufoled_23 changed from 92.12598323822021484375000,100,49.8039215803146362304687500 to 297,100,50

==> /var/log/openhab2/openhab.log <==

2018-06-24 18:23:26.404 [INFO ] [pse.smarthome.model.script.Ufoled_13] - current values:297,100,50

What is the problem? The log seems to be ok. The rule works.

The problem is, elroexe_1 and elroexe_2 is not turned on like physically.
Only Ufoled_11, Ufoled_21 is turned on.

Only if I trigger it via the sitemap on the app, elroexe_1 and elroexe_2 are turned on physically.

They are lights by the way.

update
Ok it was not the problem of the brackets {} but somehow with the speed of execution or something.
I added now 2 sleep commands.

rules:

var HSBType hsbValue
var int redValue
var int greenValue
var int blueValue
var String RGBvalues

rule "gLights all on new"
  when
    Item gLights received command ON
  then 
    logInfo("Network", "turning elroexe_1, elroexe_2, Ufoled_11, Ufoled_21 on")
    elroexe_1.sendCommand("on")
    Thread::sleep(1000)
    Ufoled_11.sendCommand(ON)
    Ufoled_21.sendCommand(ON)
    Thread::sleep(1000)
    elroexe_2.sendCommand("on")

    //sendCommand(Ufoled_13,HSBType::BLUE)
    var Integer RandomInterval = ((Math::random * 360) + 1).intValue
    logInfo( "Ufoled_13", "random value:" + RandomInterval ) 
    var DecimalType hue = new DecimalType(RandomInterval) // 0-360; 0=red, 120=green, 240=blue, 360=red(again) 25=light orange 60=yellow 306=purple 173=turquoise
    var PercentType sat = new PercentType(100) // 0-100
    var PercentType bright = new PercentType(50) // 0-100
    var HSBType light = new HSBType(hue,sat,bright)
    sendCommand(Ufoled_13, light)
    sendCommand(Ufoled_23, light)
end

Do you try to send data to different devices from a 433mhz transciever? Then you should configure your setup a little bit differently, IMHO.

You should only have one thing for the transmitter and use a reentrantlock to prevent concurrent access to the transmitter. E.g. when you switch two devices in short time. So both switches will try to send data with the single transmitter at the same time, this will not work.

And sometimes the end of the transmission takes some time, so waiting after each send command is necessary.

And it is also good to read back the return value of the execution to see when things go awry.

Maybe you can adapt shown things from here.