I want to start and power off my nas with openhab.
Powering on with openhab works with the WOL Binding.
Now i wrote a small shell script, that connects to the nas and exectutes the power off command.
The script works fine so far as i was able to test it on the command line. also running it with the openhab user works fine.
Now I installed the exec2 binding and added the command.
./etc/openhab2/scripts/poweroff_storage.sh
But how do I now create an item with paperui that makes the script run?
If that works, a nother nice step would be:
When switching on: It should use the WOL Binding, if switching off, it should use the exec binding with my script. But at first a simple button that makes the script run (from paperui) would be great
Thanks for you reply.
I read the readme and also a lot of stuff at the forum.
But even with your reply i’m not sure what to do.
Do I need do manually add the thing and item? No possibility to do it with paperui or Habmin? If so: where?
Where to find / enter what you wrote on paper UI?
I don’t think that you can create Things in PaperUI for Exec2. If you go to Configuration -> Things and hit the + and you don’t see Exec listed, you must use the text based .things files.
Once you have the Thing you can probably create the Item in Configuration -> Items.
Thanks for your replys.
Exec is listed under “things” within the configuration.
But there is no switch to run the script.
Already tested all possible channels.
You have to create an Item linked to the RUN channel to trigger the script. Or, if your script takes arguments then you sendCommand to an Item linked to the input channel.
That’s the Thing. PaperUI only shows Things. PaperUI is not intended to be the User’s Interface for your home automation. It is an Administration UI. As such, it provides the Control section and lets you interact with SOME of your Things for testing purposes. But for this you need to create a Switch Item, put that on a Sitemap or HABPanel, and tell the Script to run from there by toggling the Item.
Thank you very much.
I was able to get it work now.
Now I’ve made a other script for waking the server up.
Things:
Power On:
Thing exec:command:storage_power_on “Storage Power On” [command="/etc/openhab2/scripts/storage_poweron.sh", interval=0, timeout=15, autorun=false]
Power Off:
Thing exec:command:storage_power_off “Storage Power Off” [command="/etc/openhab2/scripts/storage_poweroff.sh", interval=0, timeout=15, autorun=false]
Items:
Power On:
Switch storage_poweron_item “Storage Power On” { channel=“exec:command:storage_power_on:run”}
Power Off:
Switch storage_poweroff_item “Storage Power Off” { channel=“exec:command:storage_power_off:run”}
And it works as it should.
But how can I do now the following:
One Item with the switch type (because i need a switch for alexa integration), that if its put “On” it runs the power on thing and if “Off” it runs the power off thing.
Your need to have something outside the container that OH talks to to issue the command.
The shutdown command probably doesn’t exist inside the Docker image and if it did I doubt it would be allowed to run, it at best it would shutdown the container. One of the whole points of containers is to prevent apps from doing this sorry of thing.
It’s the same problem. Inside the container there are a limited set of executables available. Ping isn’t even there.
Just thinking loud … that means I’m not sure OH should be the right app to put in a container … as the strength of OH is to communicate with things all around … does it make any sense?
Edit: no, it doesn’t you are right, but at least it should be able to shut down another host (in case, for example, you have OH in a server, and your media center in another nas). Makes sense?