Question regarding remote shutdown / abort shutdown

Is it possible to add spaces in the exex binding ?
I mean “Shutdown_via_smarthome” is ok for now. But a text like “Shutdown via Openhab. Your Computer will turn off in 2 Minutes” would be better (including spaces)

Second question: is it possible to give this switch a third state like “Abort” to cancel the shutdown process?
i mean there are commands, but how can i tell OpenHAB the third state?

Thank you in advance!

Switch PC_DESK “Computer Shutdown/WOL/Abort Shutdown” {wol=“10.255.255.255#00-DE-AD-BE-EF-00”, exec=“>[OFF:net rpc shutdown -C Shutdown_via_smarthome -I 10.0.1.10 -U openhab%%secret -f -t 120]” }

I’m not entirely certain what you are asking. But if you mean whether you can have spaces in an Item name, the answer is no. Spaces are not permitted in an Item name. And even if it were, remember that the Item name is basically code. Your suggested “Shutdown via Openhab…” is absolutely not better when you have to refer to the Item in the sitemap or in your rules.

However, your “better” name makes an excellent label. See the Item wiki page and the sitemap wiki page for how to assign a label to your Items. For example:

Switch Shutdown_via_smarthome "Shutdown via Openhab. Your Computer will turn off in 2 Minutes" {exec...

Maybe but not using a Switch.

Item:

Number PC_DESK "Computer Shutdown/WOL/Abort Shutdown" {wol="10.255.255.255#00-DE-AD-BE-EF-00", exec=">[1:net rpc shutdown -C Shutdown_via_smarthome -I 10.0.1.10 -U openhab%%secret -f -t 120]", exec=">[2:...Cancel shutdown]" }

NOTE: I don’t know if the wol will work in the above. If not you need to write a rule

Sitemap:

Switch item=PC_DESK mappings=[0="WOL",1="Shutdown",2="Cancel"]

This will put three buttons on the sitemap.

Sorry for the confusion. I mean if is possible to name the exec binding
parameters with spaces, to inform the user about the upcoming shutdown.
This string needs spaces. But the exec binding can’t handle spaces.

It is the ‘-C Shutdown_via_smarthome’ parameter. The output at the client
side should be ‘Shutdown via smarthome’ (without the underscores)

Thanks in advance

Dominic

Rich Koshak bot@community.openhab.org schrieb am Mo., 7. März 2016, 21:28:

Per the Exec binding wiki page if you are having problems with spaces use “@@” in place of the spaces.

-C@@Shutdown@@via@@Openhab.

Thanks for your investigation.
Now i managed to start and cancel a shutdown.
I did a small change in the item config (it does not work with two exec="> definitions in the binding section )

Number PC_DESK “Computer Shutdown/Abort/WOL” {wol=“10.255.255.255#00-DE-AD-BE-EF-00”, exec=“>[1:net rpc shutdown -C Shutdown_via_smarthome -I 10.0.1.10 -U openhab%%secret -f -t 120] >[2:net rpc abortshutdown -I 10.0.1.10 -U openhab%%secret]” }

But the spaces are not working within exec binding.
the syntax in command line would be:

net rpc shutdown -C “Shutdown via smarthome” -I 10.0.1.10 -U openhab%%secret -f -t 120
so i need two brackets and two spaces (for this example)

You’d need to escape the "… which I am not sure you can or not.

As a work around, you can just create a one line shell script which executes this for you, but contains the string as you’d like it… then just execute the script with the exec binding.

Thanks for your help, I will use executecommandline instead.
I got now some issues with the wol binding, it wakes up my computer once I start openhab. Is there a setting like the ‘autoupdate=false’ which would fix this wake on Lan behavior

In looking at your multi-select statement in the sitemap, the 0 option will trigger the WOL… so this is likely what is happening upon boot.

Why not create a 0 = nothing option, and move all of your other selections out by one number? The action will only happen on a change anyway, so changing from nothing to WOL. This may solve your problem.