Hello, its me again.
im using a few switches to do administrative things like reboot, restart oh and so on.
Now I want to use a simple python script to delete old entries in mysql db. The script works but I can’t get it run when I press the switch. If im using “interval=10” for ex. than
the script will be started every 10 seconds and works good. so my question: What is the difference between this auto call and the manual start? I don’t see any entries in log file but when I press my switch I can see a entry in events.log.
If I understood correctly you can run the script when run manually but not when started via an openHAB switch. When started via openHAB the script is run by the user “openhab”, which is not the same as when run manually.
Maybe it’s the way you have things configured.
We can’t see that.
You’re going to have to give us a little more to work with.
ok, I try to show u everything:
things:
Thing exec:command:oh2service [command="sudo rm /var/log/openhab2/openhab.log && sudo /bin/systemctl %2$s openhab2.service", autorun=true]
Thing exec:command:piservice [command="sudo rm /var/log/openhab2/openhab.log && sudo %2$s", autorun=true]
Thing exec:command:dbcleani [command="/usr/bin/python3 /etc/openhab2/scripts/%2$s.py", interval=0, timeout=10, autorun=true]
sitemap:
Group item=gSystem label="System" icon="energy"
{
Text item=InnoBind
Text item=KM200Thing
Text item=BaerThing
Switch item=DBclean mappings=[dbclean="DB-Clean"]
Text item=DBclean_out
Switch item=OH2_Service mappings=[restart="Restart" ]
Switch item=PI_Service mappings=[reboot="Reboot" ]
Switch item=INO_Service mappings=[enable="Enable",disable="Disable"]
Switch item=KM200_Service mappings=[enable="Enable",disable="Disable"]
Switch item=Baer_Service mappings=[enable="Enable",disable="Disable"]
}
items
String OH2_Service "OH2 Service" (gSystem) {channel="exec:command:oh2service:input"}
String PI_Service "PI Service" (gSystem) {channel="exec:command:piservice:input"}
String DBclean "DB-Clean" (gSystem) {channel="exec:command:dbcleani:input", autoupdate="false"}
String DBclean_out "DB-Out [%s]" (gSystem) {channel="exec:command:dbcleani:output"}
String INO_Service "Ino Restart" (gSystem) {channel="exec:command:inoservice:input", autoupdate="false"}
String KM200_Service "KM200 Service" (gSystem) {channel="exec:command:km200service:input", autoupdate="false"}
String Baer_Service "Bär Service" (gSystem) {channel="exec:command:baerservice:input", autoupdate="false"}
String InnoBind "Status Innogy Thing [%s]" <energy>
String KM200Thing "Status KM200 Thing [%s]" <energy>
String BaerThing "Status Bär Thing [%s]" <energy>
the missing things are defined in paper ui.
All switches work well except DBclean.
the event reported in events.log is:
2020-09-15 14:54:35.114 [ome.event.ItemCommandEvent] - Item ’ DBclean ’ received command dbclean
You have made your Item DBclean as a string type. This won’t work here. The exec binding run channel is a switch type.
Oh wait - ignore that, you’re not using the run channel. (You probably should, though).
You need to read the hint in the docs that you only get an auto run triggered by input channel when the command is different from the last command.
Perfect, thanks a lot I have not seen this hint in the docs. Now its working …