I’d suspect your rules file may not have loaded and this running an old version of your rule. Check openhab.log for “yourrulesfile.rules Loaded” messages
Alright, you are configured for that to trigger an exec run.
The exec binding would update this Switch Item’s state to ON when it runs the call. (as you have correctly suppressed autoupdate in the config)
Not present in the events.log snippet you show us - is it snipped or not present? Suggests not called, and I’d expect to find some reason in openhab.log
Okay, one step forward. What you want arriving in “args”
Next -
This is a problem.
Commanding this ON should trigger your exec Thing.
That in turn should update state to ON.
That is missing; exec is not triggered.
Perhaps exec v2.x binding is not installed.
Perhaps your xxx.things file is not loading correctly - check openhab.log
Hmm, now I notice that you’ve made up syntax for your exec Thing
Nope.
Follow the binding documentation. You must specify the Thing type, the exec binding supports only one Thing type, command.
Then add any name you like for this particulatr Thing.
Thing exec:command:MYTV [ ...
Obviously you will need edit your Item channel links to match new valid Thing name.
the log says:
2020-01-13 00:40:20.988 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘exec.things’
According to paperUI, i have binding-exec - 2.5.1.SNAPSHOT installed.
Im not sure if this is relevant, but on the sitemap in the basicUI, the power symbol next to the “TV_pwr” does go red for off, green for on.
Heh oops…
I did fix exec:command in items and things files, now i get the command reported onto the “result” sitemap item!
…but the TV stays on…
…fresh event log:
2020-01-13 01:00:49.709 [ome.event.ItemCommandEvent] - Item 'tvCommand' received command ON
2020-01-13 01:00:49.726 [vent.ItemStateChangedEvent] - tvCommand changed from OFF to ON
2020-01-13 01:00:49.735 [ome.event.ItemCommandEvent] - Item 'tvCommand_Args' received command echo on 0 | cec-client -s -d 1
2020-01-13 01:00:49.754 [ome.event.ItemCommandEvent] - Item 'tvCommand_Run' received command ON
2020-01-13 01:00:49.770 [nt.ItemStatePredictedEvent] - tvCommand_Args predicted to become echo on 0 | cec-client -s -d 1
2020-01-13 01:00:49.783 [vent.ItemStateChangedEvent] - tvCommand_Args changed from echo standby 0 | cec-client -s -d 1 to echo on 0 | cec-client -s -d 1
2020-01-13 01:00:49.801 [vent.ItemStateChangedEvent] - tvCommand_Run changed from OFF to ON
2020-01-13 01:00:49.837 [vent.ItemStateChangedEvent] - tvCommand_Run changed from ON to OFF
2020-01-13 01:00:49.857 [vent.ItemStateChangedEvent] - tvCommand_Out changed from standby 0 | cec-client -s -d 1 to on 0 | cec-client -s -d 1
2020-01-13 01:00:49.862 [vent.ItemStateChangedEvent] - theReturn changed from standby 0 | cec-client -s -d 1 to on 0 | cec-client -s -d 1
I can’t comment on what you’re telling it to do.
I note in post 1 that you had quotes in that echo statement. Are those not needed now?
Mind you, I think it’s still just doing what you asked ? Executing echo on 0 | cec-client -s -d 1
echoes on 0 | cec-client -s -d 1
into your results. Is it supposed to go somewhere?
I don’t know linuxy stuff but imagined echo just “types out” what you tell it.
The command is supposed to send “standby” to HDMI-CEC-device 0 (tv) via cec-client, -s = single command, -d 1 = seems to be debug level, controls how much feedback info i get.
cec-client is a part of a “toolbox”, its a progam i downloaded off internet…
A little digging seems to show cec-client does not support direct command line parameters. Seems stupid to me, but I am not linuxy.
Here’s a script that seems to tackle that- https://www.raspberrypi.org/forums/viewtopic.php?t=67899
Here’s an old thread (using a little script to workaround pipe)
Im now using the script you linked to, seems to work just fine and does cover all my needs!
However, im trying to figure out how to link to that OFF-function in the habpanel, and how to group the off-function with my AllOff group, to turn off all lights and devices with a “goodnight”-button.
So if anything comes to mind, i would greatly appreciate the hint!
Thank you rossko57, for all your help and efforts, i would certainly not have solved this problem without your guidance!
When you log into a command line on a Linux/Unix/BSD type machine you are using what is called a “shell”. That is what sh, bash, ksh, zsh, fish (my favorite) etc. are all about. They provide your user interface between the terminal and the operating system. I want to say that again, it is a user interface.
A lot of the stuff that you find when using the command line is implemented by the shell. This includes anything that has to do with text redirection and kicking off programs. So pipes, >, ; to separate commands on one line, && between commands on a line to only run the second command if the first one succeeds, etc. are all features that are provided by the shell. And not all features are provided by all shells and sometimes they are different. For example the following in bash
sudo apt update && sudo apt upgrade
would be the following in fish.
sudo apt update; and sudo apt upgrade
When you are running commands from openHAB using the Exec binding or executeCommandLine, you don’t have a shell. So all of those nice features like pipes and running multiple commands on one line and such are not available to you. So the above two lines can not be run from openHAB directly.
If you need features like pipe or you need to execute more than one command, you need to put it all into a script and call the script. When you have a shell script the first line (for example #!/bin/bash) is a directive that tells it to execute the following code in the given shell. This is what lets you use stuff like pipes in a shell script.