openhab-core
openhab-core copied to clipboard
Bug executecommandline? - Commands running at the END of Duration.ofSeconds
Ive just upgraded to 4.0.3-1 today. Im working with a DSL rule to run the Samsung smarthings cli to turn a device on/off with an Linux/Ubuntu 22.04 Openhab setup.
At the terminal window, if I manually run my command, it takes 3-4 seconds to execute, and returns a "Command executed successfully".
When I run the command from a rule (my DSL rules are below), the command DOESNT actually run until after the Duration.ofSeconds has elapsed (Easy to spot as the device doesn't turn on or off until that amount of seconds has elapsed). So if I set Duration.ofSeconds to 50, then its not until about 50 seconds that my device turns on or off as requested. Set it to 10, then 10 seconds etc.
It does always complete successfully, but I always get an error as follows:
Timeout occurred when executing commandLine '[sudo, smartthings, devices:commands, g31-MY-DEVICE-ID-HERE-6fl, switch:on, --token=d60-MY-API-KEY-HERE-a7]'
It very much appears that its running the command at the END of the timeout, not the start of the Duration.ofSeconds timeout.
EDIT: Doing a bit more of a deep dive with this, I note 2 things:
- I dont suffer the same issue with the ADB command from a script.
- I have to use "sudo" in my command line for the DSL rule for it to run.
My Rules - This is the entire DSL rule!
if (SoundbarS60APower.state == ON) {executeCommandLine(Duration.ofSeconds(10),"sudo", "smartthings", "devices:commands", "g31-MY-DEVICE-ID-HERE-6fl", "switch:on", "--token=d60-MY-API-KEY-HERE-a7")};
if (SoundbarS60APower.state == OFF) {executeCommandLine(Duration.ofSeconds(10),"sudo", "smartthings", "devices:commands", "g31-MY-DEVICE-ID-HERE-6fl", "switch:off", "--token=d60-MY-API-KEY-HERE-a7")}
Full error here:
2023-10-24 01:07:06.534 [WARN ] [rg.openhab.core.io.net.exec.ExecUtil] - Timeout occurred when executing commandLine '[sudo, smartthings, devices:commands, g31-MY-DEVICE-ID-HERE-6fl, switch:on, --token=d60-MY-API-KEY-HERE-a7]'
I couldn't spot anything to do with this in the milestone builds fixes, so apologies if Ive missed something! Or if this is just a "me" problem!
Thanks
@kaikreuzer I guess this has to be moved to openHAB core.