is there a way to implement an item in a executeCommandLine?
rule "SmartTable"
when
Item SmartTable changed
then
executeCommandLine("ssh pi@192.168.178.49 omxplayer /home/pi/Desktop/GameTable/"+ SmartTable +".mp4")
end
As you see, i want in the executeCommandLine an ttem called SmartTable to be added to the String.
When i set SmartTable to “Halloween” i want it to send the command
It describes how to concatenate the string you need during runtime.
Instead of using “+” you need to use StringVariable.append to concatenate your string components.
So for my understanding the code needs to look like this:
var video = SmartTable
val StringBuilder myCommand = new StringBuilder
myCommand.append(ssh pi@192.168.178.49 omxplayer /home/pi/Desktop/GameTable/)
myCommand.append(video)
myCommand.append(.mp4)
executeCommandLine(myCommand.toString, 200)
Am i right?
My Filename must be storaged in a String-Item. Can i add the item this easily to the variable using “var video = SmartTable”?
You need to add double quotes around the string containing the ‘fixed’ strings.
To put the string of the item SmartTable into the variable video you need add .toString ( ? ) to SmartTable.
var video = SmartTable.toString
val StringBuilder myCommand = new StringBuilder
myCommand.append("ssh pi@192.168.178.49 omxplayer /home/pi/Desktop/GameTable/")
myCommand.append(video)
myCommand.append(".mp4")
executeCommandLine(myCommand.toString, 200)
Like this? The Item SmartTable is already a String-Item. Is it still necessary to add “.toString” to the SmartTable Item?
Since SmartTable is an Item, you need to get its State first. It will be a StringType, which you can then convert it to a string with .toString. Also, since video is not changing, use val instead of var.
rule "Mapauswahl"
when
Item SmartTable changed
then
val video = SmartTable.state.toString
val StringBuilder myCommand = new StringBuilder
myCommand.append("ssh pi@192.168.178.49 omxplayer \"/home/pi/Desktop/GameTable/")
myCommand.append(video)
myCommand.append(".mp4\" --loop --no-osd")
executeCommandLine(myCommand.toString)
end