[SOLVED] OpenHAB2 exec Binding

It cannot be made much plainer. Whatever you think you have, your system has no Item called Power_Plug_Socket_B
(Your UI is probably trying to send it commands, because you told the UI in your sitemap that an Item was called Power_Plug_Socket_B)

So if you think you have defined that Item in an Items file, the likelihood is that your Items file is failing to load. There will be a log in openhab.log if it tries.

OK i have modified
the rule
r> ule “Poweroutlet B”

when
Item Remote_Send_Out received update
then
logInfo(“Power_Plug”, "Results are: " + Remote_Send_Out.state.toString)
end

and the log

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

2019-09-22 21:12:14.308 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model ‘powerplugs.sitemap’
2019-09-22 21:24:48.485 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘powerplugs.rules’ has errors, therefore ignoring it: [1,6]: no viable alternative at input ‘“’

2019-09-22 21:40:22.941 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘powerplugs.rules’ has errors, therefore ignoring it: [5,12]: no viable alternative at input ‘“’
[5,13]: no viable alternative at input ‘Power_Plug’
[5,74]: extraneous input ‘)’ expecting ‘end’

2019-09-22 21:41:43.609 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘powerplugs.rules’
2019-09-22 21:43:45.166 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model ‘powerplugs.rules’

==> /var/log/openhab2/events.log <==
2019-09-22 21:42:09.878 [ome.event.ItemCommandEvent] - Item ‘Power_Plug_Socket_B’ received command ON
2019-09-22 21:42:10.017 [vent.ItemStateChangedEvent] - Power_Plug_Socket_B changed from OFF to ON
2019-09-22 21:42:10.348 [ome.event.ItemCommandEvent] - Item ‘Power_Plug_Socket_B’ received command OFF
2019-09-22 21:42:10.459 [vent.ItemStateChangedEvent] - Power_Plug_Socket_B changed from ON to OFF
2019-09-22 21:44:08.349 [ome.event.ItemCommandEvent] - Item ‘Power_Plug_Socket_B’ received command ON
2019-09-22 21:44:08.453 [vent.ItemStateChangedEvent] - Power_Plug_Socket_B changed from OFF to ON
2019-09-22 21:44:09.502 [ome.event.ItemCommandEvent] - Item ‘Power_Plug_Socket_B’ received command OFF
2019-09-22 21:44:09.597 [vent.ItemStateChangedEvent] - Power_Plug_Socket_B changed from ON to OFF
2019-09-22 21:44:10.479 [ome.event.ItemCommandEvent] - Item ‘Power_Plug_Socket_B’ received command ON
2019-09-22 21:44:10.582 [vent.ItemStateChangedEvent] - Power_Plug_Socket_B changed from OFF to ON

Nothing happen sorry but i don’t understand all english isn’t my fluent langage

Something is wrong with your rules file syntax.

There is obviously something wrong with that, but perhaps it is just a fomatting issue in this forum.

What are you using to edit your files? You need to save them in UTF-8 format.

You also need to take care about quote marks " " especially if you copy-paste from the forum.

If you look closely at this part of your rule

logInfo(“Power_Plug”, "Results are: "

you can see there are two different sorts of " marks.
The ones around Power_Plug are the wrong sort, and will not work.

Once you have fixed your rules file, you will also want to think about including the rule from your own post #22

thanks you are right past of the forum give ``instead " for the quotes

Hi again
i have modified my rules :

rule “Poweroutlet B”
when
Item Power_Plug_Socket_B received command
then
if(receivedCommand == ON) Remote_Send_Args.postUpdate(“00001 3 1”)
else Remote_Send_Args.postUpdate(“00001 3 0”)
when
Item Remote_Send_Out received update
then
logInfo(“Power_Plug”, "Results are: " + Remote_Send_Out.state.toString)
end

Log.

==> /var/log/openhab2/openhab.log <==
2019-09-22 23:53:29.620 [INFO ] [.dashboard.internal.DashboardService] - Started Dashboard at https://192.168.0.160:8443
2019-09-22 23:53:36.756 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui
2019-09-23 20:29:05.189 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model ‘powerplugs.sitemap’
2019-09-23 20:32:44.216 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model ‘powerplugs.items’
2019-09-23 20:41:33.289 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model ‘exec.things’
2019-09-23 20:54:36.259 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘powerplugs.rules’
2019-09-23 20:54:39.917 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model ‘powerplugs.rules’
2019-09-23 20:59:03.731 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘powerplugs.rules’ has errors, therefore ignoring it: [7,1]: no viable alternative at input ‘when’
[8,6]: no viable alternative at input ‘Remote_Send_Out’

==> /var/log/openhab2/events.log <==
2019-09-23 20:56:24.066 [ome.event.ItemCommandEvent] - Item ‘Power_Plug_Socket_B’ received command OFF
2019-09-23 20:56:24.159 [vent.ItemStateChangedEvent] - Power_Plug_Socket_B changed from ON to OFF
2019-09-23 20:56:47.542 [ome.event.ItemCommandEvent] - Item ‘Power_Plug_Socket_B’ received command ON
2019-09-23 20:56:47.648 [vent.ItemStateChangedEvent] - Power_Plug_Socket_B changed from OFF to ON
2019-09-23 20:56:48.796 [ome.event.ItemCommandEvent] - Item ‘Power_Plug_Socket_B’ received command OFF
2019-09-23 20:56:48.904 [vent.ItemStateChangedEvent] - Power_Plug_Socket_B changed from ON to OFF
2019-09-23 20:59:07.378 [ome.event.ItemCommandEvent] - Item ‘Power_Plug_Socket_B’ received command ON
2019-09-23 20:59:07.471 [vent.ItemStateChangedEvent] - Power_Plug_Socket_B changed from OFF to ON
2019-09-23 20:59:10.596 [ome.event.ItemCommandEvent] - Item ‘Power_Plug_Socket_B’ received command OFF
2019-09-23 20:59:10.697 [vent.ItemStateChangedEvent] - Power_Plug_Socket_B changed from ON to OFF

I see error in log do you know what’s wrong with my rules ?

I’ve copy-pasted your rule from your last into this forum’s “rules” fences.
(There is currently a problem with the forum keeping the icon for that invisible, which makes it hard to guess to use this!)

rule “Poweroutlet B”
when
Item Power_Plug_Socket_B received command
then
if(receivedCommand == ON) Remote_Send_Args.postUpdate(“00001 3 1”)
else Remote_Send_Args.postUpdate(“00001 3 0”)
when
Item Remote_Send_Out received update
then
logInfo(“Power_Plug”, "Results are: " + Remote_Send_Out.state.toString)
end

Anyway, having done this we can see that there are still the wrong kind of quote marks around
rule “Poweroutlet B”
which corresponds with error message
[7,1]: no viable alternative at input ‘when’
and also still at
logInfo(“Power_Plug”,
which corresponds to error message
no viable alternative at input ‘Remote_Send_Out’
because in both cases the rules parser was looking for a “string” and bumped into something else.

You will need to fix both your postUpdates as well, although the parser missed those and they won’t fail until runtime.

The other thing you have to do is un-mangle where you have mangled two rules into one.
Each “when” belongs to a different rule, each rule must have its own rule "xxx" line and end line, etc.

1 Like

Thx i have modified the quote and the config files
/etc/openhab2/items/powerplugs.items

Switch Power_Plug_Socket_B
Switch Remote_Send { channel="exec:command:remote-send:run" }
String Remote_Send_Args { channel="exec:command:remote-send:input"}
String Remote_Send_Out { channel="exec:command:remote-send:output" }

/etc/openhab2/rules/powerplugs.rules

rule "Poweroutlet B"
when
Item Power_Plug_Socket_B received command
then
if(receivedCommand == ON) Remote_Send_Args.postUpdate("00001 3 1")
else Remote_Send_Args.postUpdate("00001 3 0")
logInfo("Power_Plug", "Results are: " + Remote_Send_Out.state.toString)
end

/etc/openhab2/sitemaps/powerplugs.sitemap

sitemap powerplugs label="Wireless Poweroutlets"
{
        Frame label="Poweroutlets"
        {
          Switch item=Power_Plug_Socket_B label="Power Plug B"
        }
}

/etc/openhab2/things/exec.things

Thing exec:command:remote-send [
command="sudo /home/pi/src/433Utils/RPi_utils/send %2$s",
interval=0,
autorun=false]

karaf log

21:44:54.716 [INFO ] [smarthome.event.ItemCommandEvent ] - Item ‘Power_Plug_Socket_B’ received command OFF
21:44:55.014 [INFO ] [smarthome.event.ItemStateChangedEvent] - Power_Plug_Socket_B changed from NULL to OFF
21:44:56.939 [INFO ] [smarthome.event.ItemCommandEvent ] - Item ‘Power_Plug_Socket_B’ received command ON
21:44:57.145 [INFO ] [smarthome.event.ItemStateChangedEvent] - Power_Plug_Socket_B changed from OFF to ON
21:45:00.587 [INFO ] [smarthome.event.ItemStateChangedEvent] - Remote_Send_Args changed from NULL to 00001 3 1
21:45:00.639 [INFO ] [smarthome.event.ItemStateChangedEvent] - Remote_Send_Args changed from 00001 3 1 to 00001 3 0
21:45:00.714 [INFO ] [pse.smarthome.model.script.Power_Plug] - Results are: NULL
21:45:00.731 [ERROR] [untime.internal.engine.RuleEngineImpl] - Rule ‘Poweroutlet B’: An error occurred during the script execution: null

==> /var/log/openhab2/openhab.log <==
2019-09-25 21:20:38.980 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘powerplugs.items’
2019-09-25 21:21:05.153 [INFO ] [thome.model.lsp.internal.ModelServer] - Started Language Server Protocol (LSP) service on port 5007
2019-09-25 21:21:25.693 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘powerplugs.rules’
2019-09-25 21:21:31.009 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘powerplugs.sitemap’
2019-09-25 21:21:33.812 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘exec.things’
2019-09-25 21:21:50.537 [INFO ] [.dashboard.internal.DashboardService] - Started Dashboard at http://192.168.0.160:8080
2019-09-25 21:21:50.587 [INFO ] [.dashboard.internal.DashboardService] - Started Dashboard at https://192.168.0.160:8443
2019-09-25 21:21:57.393 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui
2019-09-25 21:45:00.714 [INFO ] [se.smarthome.model.script.Power_Plug] - Results are: NULL
2019-09-25 21:45:00.731 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘Poweroutlet B’: An error occurred during the script execution: null

==> /var/log/openhab2/events.log <==
2019-09-25 21:22:14.846 [hingStatusInfoChangedEvent] - ‘hue:0210:0017884165ce:4’ changed from INITIALIZING to ONLINE
2019-09-25 21:22:17.074 [hingStatusInfoChangedEvent] - ‘hue:0210:0017884165ce:4’ changed from ONLINE to OFFLINE: Hue bridge reports light as not reachable.
2019-09-25 21:22:25.912 [vent.ItemStateChangedEvent] - hue_0210_0017884165ce_4_color changed from NULL to 46,56,100
2019-09-25 21:22:26.032 [vent.ItemStateChangedEvent] - hue_0210_0017884165ce_4_color_temperature changed from NULL to 61
2019-09-25 21:44:54.716 [ome.event.ItemCommandEvent] - Item ‘Power_Plug_Socket_B’ received command OFF
2019-09-25 21:44:55.014 [vent.ItemStateChangedEvent] - Power_Plug_Socket_B changed from NULL to OFF
2019-09-25 21:44:56.939 [ome.event.ItemCommandEvent] - Item ‘Power_Plug_Socket_B’ received command ON
2019-09-25 21:44:57.145 [vent.ItemStateChangedEvent] - Power_Plug_Socket_B changed from OFF to ON
2019-09-25 21:45:00.587 [vent.ItemStateChangedEvent] - Remote_Send_Args changed from NULL to 00001 3 1
2019-09-25 21:45:00.639 [vent.ItemStateChangedEvent] - Remote_Send_Args changed from 00001 3 1 to 00001 3 0

Yes. You seemed to have misunderstood the purpose of two rules. When your script does (eventually) run, it will be asynchronous. The rule that triggers it will not stop and wait, so there’s no point looking for results immediately afterwards.

The second rule below triggers when results actually are available.

rule "Poweroutlet B"
when
   Item Power_Plug_Socket_B received command
then
   if (receivedCommand == ON)  {
      Remote_Send_Args.postUpdate("00001 3 1") 
   } else {
      Remote_Send_Args.postUpdate("00001 3 0")
   }
end

rule "Poweroutlet B responds"
when
   Item Remote_Send_Out received update
then
   logInfo("Power_Plug", "Results are: " + Remote_Send_Out.state.toString)
end

Okay. so your script doesn’t run.

You’ve chosen autorun=false
That means you would have to use the run channel to trigger your script, after you have sent the arguments.

rule "Poweroutlet B"
when
   Item Power_Plug_Socket_B received command
then
   if (receivedCommand == ON)  {
      Remote_Send_Args.postUpdate("00001 3 1") 
   } else {
      Remote_Send_Args.postUpdate("00001 3 0")
   }
   Thread::sleep(100)  // allow a moment for args to register
   Remote_Send.sendCommand(ON)
end

The other way to do it is to have autorun=true and that will make the script auto trigger when the input receives a new command.
The limitation there is that you cannot do the same thing twice in a row. That might not be a problem for you, with a switch involved, where two ON wouldn’t do anything useful anyway.

Hi
I have modified the files exec (false ->true) and the rules with every config it doesnt work and i see no error in log :confused:
Maybe something with right on files ?

Maybe. What result do you get in the log?

Hi thanks for the help, this is the config :

/etc/openhab2/items/powerplugs.items

Switch Power_Plug_Socket_B
Switch Remote_Send { channel="exec:command:remote-send:run" }
String Remote_Send_Args { channel="exec:command:remote-send:input"}
String Remote_Send_Out { channel="exec:command:remote-send:output" }

/etc/openhab2/rules/powerplugs.rules

rule "Poweroutlet B"
when
   Item Power_Plug_Socket_B received command
then
   if (receivedCommand == ON)  {
      Remote_Send_Args.postUpdate("00001 3 1")
   } else {
      Remote_Send_Args.postUpdate("00001 3 0")
   }
   Thread::sleep(100)  // allow a moment for args to register
   Remote_Send.sendCommand(ON)
end

/etc/openhab2/sitemaps/powerplugs.sitemap

sitemap powerplugs label="Wireless Poweroutlets"
{
    Frame label="Poweroutlets"
    {
      Switch item=Power_Plug_Socket_B label="Power Plug B"
    }
}

/etc/openhab2/things/exec.things

Thing exec:command:remote-send [
command="/home/pi/src/433Utils/RPi_utils/send %2$s",
interval=0,
autorun=true]

And the log

==> /var/log/openhab2/openhab.log <==
2019-09-27 21:20:31.257 [INFO ] [ebuilder.internal.HomeBuilderServlet] - Started Home Builder at /homebuilder
2019-09-27 21:20:32.701 [INFO ] [panel.internal.HABPanelDashboardTile] - Started HABPanel at /habpanel
2019-09-27 21:22:11.547 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'powerplugs.items'
2019-09-27 21:22:38.720 [INFO ] [thome.model.lsp.internal.ModelServer] - Started Language Server Protocol (LSP) service on port 5007
2019-09-27 21:23:00.691 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'powerplugs.rules'
2019-09-27 21:23:05.904 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'powerplugs.sitemap'
2019-09-27 21:23:08.880 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'exec.things'
2019-09-27 21:23:23.908 [INFO ] [.dashboard.internal.DashboardService] - Started Dashboard at http://192.168.0.160:8080
2019-09-27 21:23:23.954 [INFO ] [.dashboard.internal.DashboardService] - Started Dashboard at https://192.168.0.160:8443
2019-09-27 21:23:31.540 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui


   ==> /var/log/openhab2/events.log <==
2019-09-27 21:49:55.612 [vent.ItemStateChangedEvent] - Power_Plug_Socket_B changed from ON to OFF
2019-09-27 21:49:55.644 [nt.ItemStatePredictedEvent] - Remote_Send predicted to become NULL
2019-09-27 21:49:55.672 [nt.ItemStatePredictedEvent] - Remote_Send predicted to become NULL
2019-09-27 21:49:55.730 [ome.event.ItemCommandEvent] - Item 'Remote_Send' received command ON
2019-09-27 21:49:55.769 [nt.ItemStatePredictedEvent] - Remote_Send predicted to become NULL
2019-09-27 21:49:57.691 [ome.event.ItemCommandEvent] - Item 'Power_Plug_Socket_B' received command ON
2019-09-27 21:49:57.832 [vent.ItemStateChangedEvent] - Power_Plug_Socket_B changed from OFF to ON
2019-09-27 21:49:58.048 [vent.ItemStateChangedEvent] - Remote_Send_Args changed from 00001 3 0 to 00001 3 1
2019-09-27 21:49:58.160 [ome.event.ItemCommandEvent] - Item 'Remote_Send' received command ON
2019-09-27 21:49:58.199 [nt.ItemStatePredictedEvent] - Remote_Send predicted to become NULL

I don’t know how i can fix that :confused:

For some reason, having decided to use autorun=true in the exec Thing, you have also modified your rule to send an ON command to the the run channel.

Choose one or method or another, don’t do both.
Is it unclear what these options do?

For some reason, you have now changed the actual command line in your exec Thing. I’ve no idea what you really need in there, but do try getting one thing correct at a time.

For some reason, you have completely removed the extra rule that could give you some results/response from the output channel.

Hi rossko57
Thks for your answer i dont really manage to understand the difference with 2 rules.
I have modified the exec

Thing exec:command:remote-send [
command="/home/pi/src/433Utils/RPi_utils/send %2$s",
interval=0,
autorun=false]

And the rules

rule "Poweroutlet B"
when
   Item Power_Plug_Socket_B received command
then
   if (receivedCommand == ON)  {
      Remote_Send_Args.postUpdate("00001 3 1")
   } else {
      Remote_Send_Args.postUpdate("00001 3 0")
   }
end

rule "Poweroutlet B responds"
when
   Item Remote_Send_Out received update
then
   logInfo("Power_Plug", "Results are: " + Remote_Send_Out.state.toString)
end

The logs

==> /var/log/openhab2/events.log <==
2019-09-27 22:53:08.301 [ome.event.ItemCommandEvent] - Item ‘Power_Plug_Socket_B’ received command ON
2019-09-27 22:53:08.445 [vent.ItemStateChangedEvent] - Power_Plug_Socket_B changed from OFF to ON
2019-09-27 22:53:09.451 [ome.event.ItemCommandEvent] - Item ‘Power_Plug_Socket_B’ received command OFF
2019-09-27 22:53:09.643 [vent.ItemStateChangedEvent] - Power_Plug_Socket_B changed from ON to OFF
2019-09-27 22:53:09.915 [vent.ItemStateChangedEvent] - Remote_Send_Args changed from 00001 3 1 to 00001 3 0
2019-09-27 22:53:09.945 [vent.ItemStateChangedEvent] - Remote_Send_Args changed from 00001 3 0 to 00001 3 1
2019-09-27 22:53:09.956 [vent.ItemStateChangedEvent] - Remote_Send_Args changed from 00001 3 1 to 00001 3 0
2019-09-27 22:53:10.231 [ome.event.ItemCommandEvent] - Item ‘Power_Plug_Socket_B’ received command ON
2019-09-27 22:53:10.362 [vent.ItemStateChangedEvent] - Power_Plug_Socket_B changed from OFF to ON
2019-09-27 22:53:10.497 [vent.ItemStateChangedEvent] - Remote_Send_Args changed from 00001 3 0 to 00001 3 1

==> /var/log/openhab2/openhab.log <==
2019-09-27 21:22:11.547 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'powerplugs.items'
2019-09-27 21:22:38.720 [INFO ] [thome.model.lsp.internal.ModelServer] - Started Language Server Protocol (LSP) service on port 5007
2019-09-27 21:23:00.691 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'powerplugs.rules'
2019-09-27 21:23:05.904 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'powerplugs.sitemap'
2019-09-27 21:23:08.880 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'exec.things'
2019-09-27 21:23:23.908 [INFO ] [.dashboard.internal.DashboardService] - Started Dashboard at http://192.168.0.160:8080
2019-09-27 21:23:23.954 [INFO ] [.dashboard.internal.DashboardService] - Started Dashboard at https://192.168.0.160:8443
2019-09-27 21:23:31.540 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui
2019-09-27 22:50:04.506 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'exec.things'
2019-09-27 22:52:49.416 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'powerplugs.rules'

Maybe a clue i dont use openhabian but a raspberry pi with stable package of openhab

Okay, so now you have made autorun=false - that means the exec will not be triggered when you send arguments to the exec input channel.Item.

AND

You have removed the line from the rule that sent an ON command to the exec run channel Item.

So, taken together, your exec will never get triggered. Never.

When I said you must choose one or other, it means to choose one.
If you choose none, it will not work.

So, now you have a choice to make.
You can EITHER
change the Thing autorun=true
OR
You can put back the short delay and the command to the run Item.

Do not do both.

Okay -
The first rule is triggered when you send a command to your plug socket Item, I suppose by clicking in your UI…
This rule sends parameters to your exec Thing input.
If you make either of the changes mentioned just now, will trigger your exec script.

The second rule gets triggered if the exec output Item is updated, and tells you in the log what it contains, That’s all.

Yes, we do need a few of those.
It doesn’t really matter what system you are running on so far, because the last thirty posts have all been about getting your configuration correct. Try to leave things alone that aren’t a problem.

Your exec Thing command is still different to what you out started with - it began witha sudo, now it doesn’t. I don’t know if you need that.

Thks it’s more clear.
I have modified the files but it doens’t work
==> /var/log/openhab2/events.log <==
2019-09-28 00:23:11.784 [vent.ItemStateChangedEvent] - Remote_Send_Args changed from 00001 3 0 to 00001 3 1
2019-09-28 00:23:14.746 [ome.event.ItemCommandEvent] - Item ‘Power_Plug_Socket_B’ received command OFF
2019-09-28 00:23:14.905 [vent.ItemStateChangedEvent] - Power_Plug_Socket_B changed from ON to OFF
2019-09-28 00:23:15.111 [vent.ItemStateChangedEvent] - Remote_Send_Args changed from 00001 3 1 to 00001 3 0
2019-09-28 00:23:15.598 [ome.event.ItemCommandEvent] - Item ‘Power_Plug_Socket_B’ received command ON
2019-09-28 00:23:15.712 [vent.ItemStateChangedEvent] - Power_Plug_Socket_B changed from OFF to ON
2019-09-28 00:23:15.845 [vent.ItemStateChangedEvent] - Remote_Send_Args changed from 00001 3 0 to 00001 3 1
2019-09-28 00:23:22.423 [ome.event.ItemCommandEvent] - Item ‘Power_Plug_Socket_B’ received command OFF
2019-09-28 00:23:22.621 [vent.ItemStateChangedEvent] - Power_Plug_Socket_B changed from ON to OFF
2019-09-28 00:23:22.807 [vent.ItemStateChangedEvent] - Remote_Send_Args changed from 00001 3 1 to 00001 3 0
2019-09-28 00:25:50.515 [ome.event.ItemCommandEvent] - Item ‘Power_Plug_Socket_B’ received command ON
2019-09-28 00:25:50.725 [vent.ItemStateChangedEvent] - Power_Plug_Socket_B changed from OFF to ON
2019-09-28 00:25:50.982 [vent.ItemStateChangedEvent] - Remote_Send_Args changed from 00001 3 0 to 00001 3 1
2019-09-28 00:25:54.501 [ome.event.ItemCommandEvent] - Item ‘Power_Plug_Socket_B’ received command OFF
2019-09-28 00:25:54.654 [vent.ItemStateChangedEvent] - Power_Plug_Socket_B changed from ON to OFF
2019-09-28 00:25:54.818 [vent.ItemStateChangedEvent] - Remote_Send_Args changed from 00001 3 1 to 00001 3 0
2019-09-28 00:25:56.183 [ome.event.ItemCommandEvent] - Item ‘Power_Plug_Socket_B’ received command ON
2019-09-28 00:25:56.324 [vent.ItemStateChangedEvent] - Power_Plug_Socket_B changed from OFF to ON
2019-09-28 00:25:56.427 [vent.ItemStateChangedEvent] - Remote_Send_Args changed from 00001 3 0 to 00001 3 1
2019-09-28 00:25:57.263 [ome.event.ItemCommandEvent] - Item ‘Power_Plug_Socket_B’ received command OFF
2019-09-28 00:25:57.526 [vent.ItemStateChangedEvent] - Power_Plug_Socket_B changed from ON to OFF
2019-09-28 00:25:57.689 [vent.ItemStateChangedEvent] - Remote_Send_Args changed from 00001 3 1 to 00001 3 0
2019-09-28 00:25:58.388 [ome.event.ItemCommandEvent] - Item ‘Power_Plug_Socket_B’ received command ON
2019-09-28 00:25:58.503 [vent.ItemStateChangedEvent] - Power_Plug_Socket_B changed from OFF to ON
2019-09-28 00:25:58.784 [vent.ItemStateChangedEvent] - Remote_Send_Args changed from 00001 3 0 to 00001 3 1
2019-09-28 00:25:59.253 [ome.event.ItemCommandEvent] - Item ‘Power_Plug_Socket_B’ received command OFF
2019-09-28 00:25:59.384 [vent.ItemStateChangedEvent] - Power_Plug_Socket_B changed from ON to OFF
2019-09-28 00:25:59.504 [vent.ItemStateChangedEvent] - Remote_Send_Args changed from 00001 3 1 to 00001 3 0

/etc/openhab2/rules/powerplugs.rules

rule "Poweroutlet B"
when
   Item Power_Plug_Socket_B received command
then
   if (receivedCommand == ON)  {
      Remote_Send_Args.postUpdate("00001 3 1")
   } else {
      Remote_Send_Args.postUpdate("00001 3 0")
   }
end

rule "Poweroutlet B responds"
when
   Item Remote_Send_Out received update
then
   logInfo("Power_Plug", "Results are: " + Remote_Send_Out.state.toString)
end

/etc/openhab2/things/exec.things

Thing exec:command:remote-send [
command="/home/pi/src/433Utils/RPi_utils/send %2$s",
interval=0,
autorun=true]

I have remove sudo because the send command can be used without sudo

Your exec script is not attempting to run; we can tell this because you don’t see a message in events.log about you run Item Remote_Send changing to ON.

I don’t see anything wrong with your settings now, hurrah :smiley:
But after so many changes back and forth, who knows what openHAB thinks now.

I would advise a openHAB reboot.

EDIT - something you have never shown us from your events.log is any messages about links changing. You have installed exec binding?

1 Like

HI thanks for you answer i have installed exec and regex binding.
In my last post i have put the event logs with
=> /var/log/openhab2/events.log <==
2019-09-28 00:23:11.784 [vent.ItemStateChangedEvent] - Remote_Send_Args changed from 00001 3 0 to 00001 3 1
2019-09-28 00:23:14.746 [ome.event.ItemCommandEvent] - Item ‘Power_Plug_Socket_B’ received command OFF
2019-09-28 00:23:14.905 [vent.ItemStateChangedEvent] - Power_Plug_Socket_B changed from ON to OFF
2019-09-28 00:23:15.111 [vent.ItemStateChangedEvent] - Remote_Send_Args changed from 00001 3

I have already rebooted :confused:

hi
i have made another reboot
==> /var/log/openhab2/openhab.log <==
2019-09-28 14:01:22.624 [INFO ] [ebuilder.internal.HomeBuilderServlet] - Started Home Builder at /homebuilder
2019-09-28 14:01:25.783 [INFO ] [panel.internal.HABPanelDashboardTile] - Started HABPanel at /habpanel
2019-09-28 14:03:08.867 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘powerplugs.items’
2019-09-28 14:03:54.238 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘powerplugs.rules’
2019-09-28 14:03:56.035 [INFO ] [thome.model.lsp.internal.ModelServer] - Started Language Server Protocol (LSP) service on port 5007
2019-09-28 14:04:00.494 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘powerplugs.sitemap’
2019-09-28 14:04:03.123 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘exec.things’
2019-09-28 14:04:18.048 [INFO ] [.dashboard.internal.DashboardService] - Started Dashboard at http://192.168.0.160:8080
2019-09-28 14:04:18.119 [INFO ] [.dashboard.internal.DashboardService] - Started Dashboard at https://192.168.0.160:8443
2019-09-28 14:04:24.403 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui

==> /var/log/openhab2/events.log <==
2019-09-28 15:35:29.203 [vent.ItemStateChangedEvent] - Remote_Send_Args changed from 00001 3 1 to 00001 3 0
2019-09-28 15:35:31.980 [ome.event.ItemCommandEvent] - Item 'Power_Plug_Socket_B' received command ON
2019-09-28 15:35:32.157 [vent.ItemStateChangedEvent] - Power_Plug_Socket_B changed from OFF to ON
2019-09-28 15:35:32.297 [vent.ItemStateChangedEvent] - Remote_Send_Args changed from 00001 3 0 to 00001 3 1
2019-09-28 15:36:35.238 [ome.event.ItemCommandEvent] - Item 'Power_Plug_Socket_B' received command OFF
2019-09-28 15:36:35.391 [vent.ItemStateChangedEvent] - Power_Plug_Socket_B changed from ON to OFF
2019-09-28 15:36:35.760 [vent.ItemStateChangedEvent] - Remote_Send_Args changed from 00001 3 1 to 00001 3 0
2019-09-28 15:36:36.155 [ome.event.ItemCommandEvent] - Item 'Power_Plug_Socket_B' received command ON
2019-09-28 15:36:36.267 [vent.ItemStateChangedEvent] - Power_Plug_Socket_B changed from OFF to ON
2019-09-28 15:36:36.507 [vent.ItemStateChangedEvent] - Remote_Send_Args changed from 00001 3 0 to 00001 3 1

The two bindings have been installed with paper ui

When I copy/paste your Things file into my OH2.4 I get an error message


2019-09-28 17:34:16.881 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'exec.things'
2019-09-28 17:34:16.883 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'exec.things' is either empty or cannot be parsed correctly!

Maybe you are not looking at WARN messages with whatever you are using to look in openhab.log. It pays to look at it all when having problems.

The underlying cause is the hyphen in your Thing UID (“name”) remote-send
If I replace that with remote_send it fixes the failure.

Don’t forget you will need to edit your Item channels too, because of the channel name change.

This business with hyphens / dashes “-” in Thing UIDs is not at all clear to me; sometimes it doesn’t work.

Thanks i have modified the items ans things
I didn’t see the errors :confused:

==> /var/log/openhab2/events.log <==
2019-09-28 21:31:47.281 [ome.event.ItemCommandEvent] - Item 'Power_Plug_Socket_B' received command OFF
2019-09-28 21:31:47.440 [vent.ItemStateChangedEvent] - Power_Plug_Socket_B changed from ON to OFF
2019-09-28 21:31:47.640 [vent.ItemStateChangedEvent] - Remote_Send_Args changed from 00001 3 1 to 00001 3 0
2019-09-28 21:31:48.286 [ome.event.ItemCommandEvent] - Item 'Power_Plug_Socket_B' received command ON
2019-09-28 21:31:48.406 [vent.ItemStateChangedEvent] - Power_Plug_Socket_B changed from OFF to ON
2019-09-28 21:31:48.639 [vent.ItemStateChangedEvent] - Remote_Send_Args changed from 00001 3 0 to 00001 3 1

Does i need to reboot because the powerplug doesnt switch off ?