I am running openhab2 on Windows 10 as a service
My question: How do I write the rule that will allow me to restart openhab by sending a message from the telegram?
rule "reboot system"
when
Item telegram_telegramBot_Telegram_Bot_lastMessageText changed to reboot openhab
then
????????
end
Ooops, sorry - I missed that part.
Nevertheless you may try executeCommandLine together with a windows command to restart the computer. Command to be used is explained here: https://its.uiowa.edu/support/article/109196
If I run this command it works fine executeCommandLine ("shutdown / r", 100)
But I want to run a bat file and not restart the computer so I try to run the following command but it does not work, the file does not open executeCommandLine ("C:\Users\razse\Desktop\reboot.bat", 100)
Try to escape the back-slashes: C:\Users\razse\Desktop\reboot.bat
There is a space between executeCommandLine and parenthesis. Is that just here or also in your rule ?
do you see any message in the openhab.log / events.log that gives a hint ?
add a lines like this surrounding the execute command
logInfo( "MyRule", "Before ...." )
logInfo( "MyRule", "After ...." )
in case you see the messages but the batch file is not executed you can conclude that the rule itself is ok
add something to your batch file that at the beginning creates a file in e.g. c:\temp; if that one is available your file is being executed but there might be permssion issue with the command that you want to execute from within the batch file; if the file is not created in c:\temp then there is a permission issue with the batch file or it cannot be found
there should be a scripts directory next to the rules directory you may place the batch file in that directory to get around permission problems accessing a users directory
Stop/Start a bundle
executeCommandLine(“C:\openhab-2.5.2\runtime\bin\client.bat@@bundle:stop@@293”,15000)
executeCommandLine(“C:\openhab-2.5.2\runtime\bin\client.bat@@bundle:start@@293”,15000)
Restart a bundle
executeCommandLine(“C:\openhab-2.5.2\runtime\bin\client.bat@@bundle:restart@@293”,5000)
the remaining means: bundle:start, bundle:stop, bundle:restart ?
These commands require a number as argument. The number will be different on each individual system and need to be detected during runtime. So the 293 is the id of a specific bundle on your system as the same bundle has a different id on my system.
I changed to the location where the correct openhab2 is installed on my computer
But does not work
And how do I find the bundle: restart / stop / start id?
I wrote in console bundle:list
What is it called in the list?