OpenHAB3 EXEC Configuration with Text Files on Windows 10

I am migrating my OpenHAB installation from 2.4.0 where the legacy exec1 binding is used to 3.0.1.
I use the EXEC binding to restart and reboot my Windows 10 computer on which OpenHAB is running.
The exec1 binding was easy to use:

OH2.4 .items

Switch IP_HS5150_Exec_R	"IP_HS5150_Exec [%s]"	{exec="ON:shutdown /r /t 10"}
Switch IP_HS5150_Exec_S	"IP_HS5150_Exec [%s]"	{exec="ON:shutdown /s /t 10"} 

OH2.4 .rules

sendCommand(IP_HS5150_Exec_R, ON)
Thread::sleep(5000)
sendCommand(IP_HS5150_Exec_R, OFF)

and

sendCommand(IP_HS5150_Exec_S, ON)
Thread::sleep(5000)
sendCommand(IP_HS5150_Exec_S, OFF)

Now for OpenHAB3. Using Belkin Wemo - Bindings | openHAB for a reference, I have:

OH3 .things (OH3 says it has parsing errors)

	Thing exec:command: ExecRestart  [command="ON:shutdown /r /t 10", interval=15, timeout=5, autorun=false]	
	Thing exec:command: ExecShutdown [command="ON:shutdown /s /t 10", interval=15, timeout=5, autorun=false]
  • 1 - I get a Things parsing error. My syntax must be wrong but comparing the documentation and google threads I don’t see the problem.

  • 2 - I’m new to `things’. I have wemo running for the 1st time and those channels do not require “Thing” at the beginning of each line. Is it needed here?

OH3 .items

Switch IP_HS5150_Exec_R	"IP_HS5150_Exec [%s]"	{channel="exec:"ExecRestart", autoupdate="false"}
Switch IP_HS5150_Exec_S	"IP_HS5150_Exec [%s]"	{channel="exec:"ExecShutdown", autoupdate="false"} 
  • I think this is correct. Do you agree?

OH3 .rules

IP_HS5150_Exec_R.sendCommand(ON)
Thread::sleep(5000)
IP_HS5150_Exec_R.sendCommand(OFF)

and

IP_HS5150_Exec_S.sendCommand(ON)
Thread::sleep(5000)
IP_HS5150_Exec_S.sendCommand(OFF)
  • I think this is correct. Do you agree?

OH3 .whitelist (I’m totally guessing at the syntax here because I can’t find any reference documentation for OH3)

"shutdown /r /t 10"
"shutdown /s /t 10"
  • The whitelist file is named “exec.whitelist”. I assume that to be correct in that it does not follow the naming convention for .items .things .sitemaps .rules etc. Again, I have no clue for correct syntax

Thanks in advance for your help.

Sorry, wrong reference. Here’s the correct reference: Exec - Bindings | openHAB

I was able to piece together several threads I luckily stumbled on to and developed the answer to my own question. Hopefully this will help others looking for the same or similar :slight_smile:

.things

Thing exec:command:ExecReStart 	[command="shutdown /r /t 2", interval=0, timeout=5, autorun=false]
Thing exec:command:ExecShutdown [command="shutdown /s /t 2", interval=0, timeout=5, autorun=false]

.items

Switch IP_HS5150_Exec_R		"IP_HS5150_Exec_R [%s]"		{channel="exec:command:ExecReStart:run",  autoupdate="false"}
Switch IP_HS5150_Exec_S		"IP_HS5150_Exec_S [%s]"		{channel="exec:command:ExecShutdown:run", autoupdate="false"}

.rules

IP_HS5150_Exec_R.sendCommand(ON)
IP_HS5150_Exec_S.sendCommand(ON)

\conf\misc\exec.whitelist

# For security reasons all commands that are used by the exec binding or transformation need to be whitelisted.
# Every command needs to be listed on a separate line below.
#
#
#	EXEC BINDING
shutdown /s /t 2
shutdown /r /t 2

.

I have added a new EXEC command, this one to reset the system clock on my Windows 10 PC because it drifts. The problem I’m having is that I get an error message

Couldn't transform response because tranformationService of type 'REGEX' is unavailable

My thing is:

Thing exec:command:PCExecTimeSync [command=“w32tm /resync”, interval=0, timeout=5, autorun=false]

My item is:

Switch IP_PC4996_Exec_T “IP_PC4996_Exec_T [%s]” {channel=“exec:command:PCExecTimeSync:run”, autoupdate=“false”}

and my rule is:

IP_PC4996_Exec_T.sendCommand(ON)
Thread::sleep(5000)
IP_PC4996_Exec_T.sendCommand(OFF)

From what I read online the problem is that I need to include the default REGEX((.*)) transformation in my transform folder?

I’ve searched around but have not been able to find it. Where can I download it from?

Thanks.

It’s complaining about the service not found, It’s an installable option, an add-on just like a binding is an add-on.

So I should add it to the addons.cfg file here ?

# A comma-separated list of miscellaneous services to install (e.g. "misc = openhabcloud")
#misc = 
misc = openhabcloud, REGEX

I tried

# A comma-separated list of miscellaneous services to install (e.g. "misc = openhabcloud")
#misc = 
misc = openhabcloud, regex

and now get a warning:

19:23:49.826 [WARN ] [.core.karaf.internal.FeatureInstaller] - The misc add-on 'regex' does not exist - ignoring it.

I’ve seen RegEx rand regex referenced suggesting case matters.

In OH3 you would usually use the UI to install REGEX transformation service, just a you would for a binding.

If you must buck the trend and use addons.cfg instead, you would need to find out how to put transformation services in there.

transformation = regex, anyothertransforns

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.