As a matter of fact, this topic is only conceptually a migration issue, as I completely developed a new solution migrating from OH2 to OH3.
I have some Python scripts activated by Exec Things/Channels/Items. They are similar but one of these is not executed without any error, simply it is not executed and I do not understand why, I tried many different Thing parameter settings, and also using exec commandline, but always the same behaviour, no errors, no results.
The Thing definitions are the following:
Bridge mqtt:broker:MqttMain [ host="192.xxx.xxx.xxx", secure=false ]
{
Thing topic MqttSpeakersVolume "Mqtt Speakers Volume" {
Channels:
Type string: SpeakersVolumeChannel "Speakers Volume Channel" [ stateTopic="house/speakers/volume" ]
}
Thing topic MqttSpeakersMusic "Mqtt Speakers Music" {
Channels:
Type string: SpeakersMusicChannel "Speakers Music Channel" [ stateTopic="house/speakers" ]
}
Thing topic MqttSpeakersSong "Mqtt Speakers Song" {
Channels:
Type string: SpeakersSongChannel "Speakers Song Channel" [ stateTopic="house/speakers/song" ]
}
}
Thing exec:command:change_volume [command="python3 /etc/openhab/scripts/play_speakers_volume.py %2$s", interval=0, timeout=15, autorun=true]
Thing exec:command:play_music [command="python3 /etc/openhab/scripts/play_speakers_music.py %2$s", interval=0, timeout=15, autorun=false]
Thing exec:command:play_song [command="python3 /etc/openhab/scripts/play_speakers_song.py %2$s", interval=0, timeout=15, autorun=false]type or paste code here
The first two scripts work fine, the third does not work, Items of the last thing (the others are similar):
tyString Song300 "Mqtt Speakers Song" { channel="mqtt:topic:MqttMain:MqttSpeakersSong:SpeakersSongChannel"}
String RF300args { channel="exec:command:play_song:input" }
Switch RF300switchrun { channel="exec:command:play_song:run", autoupdate="false" }
String RF300out{ channel="exec:command:play_song:output" }pe or paste code here
The rules:
rule "Set song on speakers"
when
Item Song300 received update
then
logInfo ("inizio: ", "Set song on speakers")
logInfo ("prima di esecuzione ", Song300.state.toString)
createTimer(now.plusSeconds(300), [ |
RF300args.sendCommand(Song300.state.toString)
])
//var result=executeCommandLine("nohup", "-u", "/usr/bin/python3", "/etc/openhab/scripts/play_speakers_song.py", Song300.state.toString)
logInfo ("after the input command ", "AAA A RF300args : " ) //+result)
end
rule "Begin play song execution"
when
Item RF300args received command
then
logInfo ("inizio: ", "Begin play song execution")
// Separately triggering RUN allows subsequent executions with unchanged parameter %2
// which autorun does not.
if (RF300switchrun.state != ON) {
RF300switchrun.sendCommand(ON)
logInfo("Your command non ON: ", "RF300args.state")
// the Run indicator state will go ON shortly, and return OFF when script finished
}else{
logInfo("Your command exec", "Script already in use, skipping execution.")
}
end
rule "Play song results"
when
Item RF300out received update
then
logInfo ("inizio ", "Play song results")
logInfo("comando di esecuzione musica ", "risultato: " + RF300out.state.toString )
end
//---------------------------------------------------------------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------------
rule "Set music on speakers"
when
Item Music30 received update
then
logInfo ("prima di esecuzione ", Music30.state.toString)
logInfo ("prima di esecuzione2 ", " dddddddddd")
RF30args.sendCommand(Music30.state.toString)
// RF33args.sendCommand("1.0")
logInfo ("dopo di esecuzione ", "AAAAAAAAAABBBBBBBB ")
end
rule "Begin play music execution"
when
Item RF30args received command
then
// Separately triggering RUN allows subsequent executions with unchanged parameter %2
// which autorun does not.
if (RF30switchrun.state != ON) {
RF30switchrun.sendCommand(ON)
logInfo("Your command non ON: ", "RF30args.state")
// the Run indicator state will go ON shortly, and return OFF when script finished
}else{
logInfo("Your command exec", "Script already in use, skipping execution.")
}
end
Results in openhab.log
2021-03-11 09:37:06.357 [INFO ] [.openhab.core.model.script.inizio: ] - Set song on speakers
2021-03-11 09:37:06.361 [INFO ] [re.model.script.prima di esecuzione ] - prove/doorbell.mp3
2021-03-11 09:37:06.367 [INFO ] [odel.script.after the input command ] - AAA A RF300args :
type or paste code here
RF300switchrun state remains ON.
I’d be very grateful if someone can help me to solve the issue.