Your rule works, the command will be sent, but only the first time. I took a video on how the switch reacts the first time and then no longer. the first time the light bulb lights up and then it is off.when i restart the raspi it works again the first time
What else can you change about the rule? you’re great thanks for everything so far.
log:
13:52:47.794 [INFO ] [.dashboard.internal.DashboardService] - Started dashboard at https://192.168.8.111:8443
13:52:48.352 [INFO ] [basic.internal.servlet.WebAppServlet] - Started Basic UI a t /basicui/app
13:52:48.432 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Started Paper UI a t /paperui
13:52:48.516 [INFO ] [panel.internal.HABPanelDashboardTile] - Started HABPanel a t /habpanel
13:52:48.702 [INFO ] [ui.habmin.internal.servlet.HABminApp] - Started HABmin ser vlet at /habmin
13:54:35.708 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'Wohnzimmer' received command ON
13:54:35.773 [INFO ] [marthome.event.ItemStateChangedEvent] - Wohnzimmer changed from NULL to ON
13:54:36.102 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'Remote_Send_ Args' received command 13108705
13:54:36.112 [INFO ] [marthome.event.ItemStateChangedEvent] - Remote_Send_Args c hanged from NULL to 13108705
13:54:36.119 [INFO ] [marthome.event.ItemStateChangedEvent] - Remote_Send change d from NULL to ON
13:54:36.639 [INFO ] [marthome.event.ItemStateChangedEvent] - Remote_Send change d from ON to OFF
13:54:36.653 [INFO ] [marthome.event.ItemStateChangedEvent] - Remote_Send_Out ch anged from NULL to sending code[13108705]
13:54:37.167 [INFO ] [se.smarthome.model.script.Wohnzimmer] - Resuts: sending co de[13108705]
13:54:37.188 [INFO ] [marthome.event.ItemStateChangedEvent] - Wohnzimmer changed from ON to OFF
13:54:38.311 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'Wohnzimmer' received command ON
13:54:38.322 [INFO ] [marthome.event.ItemStateChangedEvent] - Wohnzimmer changed from OFF to ON
13:54:38.323 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'Remote_Send_ Args' received command 13108705
13:54:38.326 [INFO ] [se.smarthome.model.script.Wohnzimmer] - Resuts: sending co de[13108705]
13:54:38.334 [INFO ] [marthome.event.ItemStateChangedEvent] - Wohnzimmer changed from ON to OFF
13:54:39.270 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'Wohnzimmer' received command ON
13:54:39.282 [INFO ] [marthome.event.ItemStateChangedEvent] - Wohnzimmer changed from OFF to ON
13:54:39.293 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'Remote_Send_ Args' received command 13108705
13:54:39.299 [INFO ] [se.smarthome.model.script.Wohnzimmer] - Resuts: sending co de[13108705]
13:54:39.314 [INFO ] [marthome.event.ItemStateChangedEvent] - Wohnzimmer changed from ON to OFF
13:54:40.296 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'Wohnzimmer' received command ON
13:54:40.317 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'Remote_Send_ Args' received command 13108705
13:54:40.322 [INFO ] [marthome.event.ItemStateChangedEvent] - Wohnzimmer changed from OFF to ON
13:54:40.327 [INFO ] [se.smarthome.model.script.Wohnzimmer] - Resuts: sending co de[13108705]
13:54:40.340 [INFO ] [marthome.event.ItemStateChangedEvent] - Wohnzimmer changed from ON to OFF
13:54:41.590 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'Wohnzimmer' received command ON
13:54:41.600 [INFO ] [marthome.event.ItemStateChangedEvent] - Wohnzimmer changed from OFF to ON
13:54:41.606 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'Remote_Send_ Args' received command 13108705
13:54:41.616 [INFO ] [se.smarthome.model.script.Wohnzimmer] - Resuts: sending co de[13108705]
13:54:41.628 [INFO ] [marthome.event.ItemStateChangedEvent] - Wohnzimmer changed from ON to OFF
I’ve done a video update! I have replaced the rule with the new one, but it does not change, send command only at the first time i push the button (look at the video).
The things are only used by this one rule, so far I have only this one configuration.
Thank you
log file:
17:46:01.207 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'wohnzimmer.items'
17:46:08.572 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'wohnzimmer.rules'
17:46:09.962 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'funklicht.sitemap'
17:46:10.014 [INFO ] [home.event.ItemChannelLinkAddedEvent] - Link 'Remote_Send_Out-exec:command:remote-send:output' has been added.
17:46:10.019 [INFO ] [home.event.ItemChannelLinkAddedEvent] - Link 'Remote_Send_Args-exec:command:remote-send:input' has been added.
17:46:10.021 [INFO ] [home.event.ItemChannelLinkAddedEvent] - Link 'Remote_Send-exec:command:remote-send:run' has been added.
17:46:10.367 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'funklicht.things'
17:46:10.473 [INFO ] [smarthome.event.ThingAddedEvent ] - Thing 'exec:command:remote-send' has been added.
17:46:10.499 [INFO ] [me.event.ThingStatusInfoChangedEvent] - 'exec:command:remote-send' changed from UNINITIALIZED to INITIALIZING
17:46:10.506 [INFO ] [me.event.ThingStatusInfoChangedEvent] - 'exec:command:remote-send' changed from INITIALIZING to ONLINE
17:46:13.155 [WARN ] [g.eclipse.smarthome.core.net.NetUtil] - Found multiple local interfaces - ignoring 192.168.8.109
17:46:13.158 [INFO ] [.dashboard.internal.DashboardService] - Started dashboard at http://192.168.8.111:8080
17:46:13.163 [WARN ] [g.eclipse.smarthome.core.net.NetUtil] - Found multiple local interfaces - ignoring 192.168.8.109
17:46:13.165 [INFO ] [.dashboard.internal.DashboardService] - Started dashboard at https://192.168.8.111:8443
17:46:13.797 [INFO ] [basic.internal.servlet.WebAppServlet] - Started Basic UI at /basicui/app
17:46:13.989 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui
17:46:14.080 [INFO ] [panel.internal.HABPanelDashboardTile] - Started HABPanel at /habpanel
17:46:14.239 [INFO ] [ui.habmin.internal.servlet.HABminApp] - Started HABmin servlet at /habmin
17:46:47.240 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'Wohnzimmer' received command ON
17:46:47.297 [INFO ] [marthome.event.ItemStateChangedEvent] - Wohnzimmer changed from NULL to ON
17:46:47.680 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'Remote_Send_Args' received command 13108705
17:46:47.689 [INFO ] [marthome.event.ItemStateChangedEvent] - Remote_Send_Args changed from NULL to 13108705
17:46:47.694 [INFO ] [marthome.event.ItemStateChangedEvent] - Remote_Send changed from NULL to ON
17:46:48.201 [INFO ] [marthome.event.ItemStateChangedEvent] - Remote_Send changed from ON to OFF
17:46:48.209 [INFO ] [marthome.event.ItemStateChangedEvent] - Remote_Send_Out changed from NULL to sending code[13108705]
17:46:48.702 [INFO ] [se.smarthome.model.script.Wohnzimmer] - Resuts: sending code[13108705]
17:46:48.721 [INFO ] [marthome.event.ItemStateChangedEvent] - Wohnzimmer changed from ON to OFF
17:46:48.733 [INFO ] [marthome.event.ItemStateChangedEvent] - Remote_Send_Args changed from 13108705 to
17:46:55.277 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'Wohnzimmer' received command ON
17:46:55.287 [INFO ] [marthome.event.ItemStateChangedEvent] - Wohnzimmer changed from OFF to ON
17:46:55.300 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'Remote_Send_Args' received command 13108705
17:46:55.308 [INFO ] [marthome.event.ItemStateChangedEvent] - Remote_Send_Args changed from to 13108705
17:46:55.312 [INFO ] [se.smarthome.model.script.Wohnzimmer] - Resuts: sending code[13108705]
17:46:55.333 [INFO ] [marthome.event.ItemStateChangedEvent] - Wohnzimmer changed from ON to OFF
17:46:55.339 [INFO ] [marthome.event.ItemStateChangedEvent] - Remote_Send_Args changed from 13108705 to
rule "Wohnzimmer"
when
Item Wohnzimmer received command ON
then
// Check if an other rule uses the transmitter
while(Remote_Send.state == ON){
Thread::sleep(500)
}
Remote_Send_Args.sendCommand("13108705")
// triger sending manually
Remote_Send.sendCommand(ON);
// wait for the command to complete
while(Remote_Send.state != OFF){
Thread::sleep(500)
}
logInfo("Wohnzimmer", "Resuts: " + Remote_Send_Out.state )
// After command is done
// Set button back so you can reuse it
Wohnzimmer.postUpdate(OFF)
end
This works for me and executes the command everytime.
Some sidenotes.
If the reseting is done with sendCommand instead of postUpdate it will also work, but it will trigger an execution which is not a good idea.
Hi Josar,
great tutorial. Tried it on a Raspberry Pi 3 with OpenHAB2. Followed exactly your steps. But I get the “An exception occurred while formatting the command line with the current time and input values : 'Format specifier ‘%2$s’” but as I’m quite new to OpenHAB, I don’t know how to handle your explanation to this error. Can you give me some newbe step-by-step advice?
I 99% copy and pasted exactly what you postet in your tutorial. The 1% difference is the code I send to receiver. It’s 11111 1 1 and of cource 11111 1 0.
So there is Remote_Send_Args.sendCommand(“11111 1 1”) for example.
I manually installed regex transformation via openhab console and feature:install openhab-transformation-regex.
What else could it be?
I deinstalled the regex binding and reinstalled it - both via paper ui this time. I also installed exec transformation.
I deinstalled and reinstalled the exec binding. And this is the log:
21:58:32.930 [INFO ] [smarthome.event.ExtensionEvent ] - Extension ‘binding-exec’ has been installed.
21:58:32.994 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - ‘exec:command:remote-send’ changed from UNINITIALIZED to INITIALIZING
21:58:33.012 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - ‘exec:command:remote-send’ changed from INITIALIZING to ONLINE
21:58:46.633 [INFO ] [smarthome.event.ExtensionEvent ] - Extension ‘transformation-regex’ has been installed.
21:58:57.561 [INFO ] [smarthome.event.ExtensionEvent ] - Extension ‘transformation-exec’ has been installed.
21:59:54.450 [INFO ] [del.core.internal.ModelRepositoryImpl] - Refreshing model 'exec.things’
21:59:54.505 [INFO ] [smarthome.event.ThingUpdatedEvent ] - Thing ‘exec:command:remote-send’ has been updated.
22:00:42.946 [INFO ] [smarthome.event.ItemCommandEvent ] - Item ‘Remote_Send’ received command ON
22:00:42.993 [INFO ] [smarthome.event.ItemStateChangedEvent] - Remote_Send changed from NULL to ON
22:00:43.013 [ERROR] [nhab.binding.exec.handler.ExecHandler] - An exception occurred while formatting the command line with the current time and input values : 'Format specifier ‘%2$s’'
22:00:43.043 [INFO ] [smarthome.event.ItemStateChangedEvent] - Remote_Send changed from ON to OFF
@muhackl666 i dont see where you pressed a switch in the log. As there is no output logged from the rules and also no state change from the switches.
How does Remote_Send gets triggered to change to ON?
When the input channel in this case Remote_Send_Args is not set before triggering the execution there will be this error.
What is shown in the log when you press a switch?
PS: please use the icons above the writing field to format your code or log.
Exactly this is shown, when I switch the switch in basic ui. The switch goes to the right and after that automatically back to the left (off). In the log, that’s everything that happens:
19:41:52.043 [INFO ] [smarthome.event.ItemCommandEvent ] - Item ‘Remote_Send’ received command ON
19:41:52.060 [ERROR] [nhab.binding.exec.handler.ExecHandler] - An exception occurred while formatting the command line with the current time and input values : 'Format specifier ‘%2$s’'
19:41:52.092 [INFO ] [smarthome.event.ItemStateChangedEvent] - Remote_Send changed from OFF to ON
19:41:52.147 [INFO ] [smarthome.event.ItemStateChangedEvent] - Remote_Send changed from ON to OFF
rule "Poweroutlet B"
when
Item Power_Plug_Socket_B received command
then
// wait for transmitter to be free
// State will be NULL if not used before or ON while command is executed
while(Remote_Send.state == ON){
Thread::sleep(500)
}
if(receivedCommand == ON){
Remote_Send_Args.sendCommand("11111 1 1")
}else{
Remote_Send_Args.sendCommand("11111 1 0")
}
// wait for the command to complete
while(Remote_Send.state != OFF){
Thread::sleep(500)
}
logInfo("Power_Plug", "Result:" + Remote_Send_Out.state )
end
@muhackl666 only thing i can advise now is a fresh install of openhab or the whole pi. I have no further ideas.
But why does your switch automatically turn off again?
And what is the version of your openhab? Mine is
dpkg --list | grep openhab
ii openhab2 2.2.0-1 all openhab2
So I set up another raspberry pi3 - everything totally freshly.
And it works fine - at least in basic ui.
So something must have been misconfigured in my previous setup.
Hey Josar,
thanks for your great tutorial - I’ve been searching for a way to control my powerplugs via Alexa and openHAB for a long time. Your solution works fine for me.
But sometimes my transmitter signal gets lost or isn’t recognized by the receiver. I’d like to send every command multiple times to make sure the digital and physical state of the device are equal. What is the smartest way to do this? In this thread I found a few helpful things but I don’t know how to put them together.
I’m not sure if this works if I set the thing’s autorun to false:
rule "Poweroutlet B"
when
Item Power_Plug_Socket_B received command
then
var i = 0
// wait for transmitter to be free
// State will be NULL if not used before or ON while command is executed
while(Remote_Send.state == ON){
Thread::sleep(500)
}
if(receivedCommand == ON){
Remote_Send_Args.sendCommand("11111 1 1")
}else{
Remote_Send_Args.sendCommand("11111 1 0")
}
// send the command e.g. 5 times
while((i=i+1) < 6){
Remote_Send.sendCommand(ON)
// wait for the command to complete
while(Remote_Send.state != OFF){
Thread::sleep(500)
}
}
logInfo("Power_Plug", "Result:" + Remote_Send_Out.state )
end
I know that I could just edit and test the rule until it works but I’d like to get into openHAB and understand how it’s working.