Hello,
I run some script in DSL language
var azimuth_open_cuisine = 400
var azimuth_close_cuisine = 200
var azimuth_open_salle = 400
var azimuth_close_salle = 200
var azimuth_open_TV = 50
var azimuth_close_TV = 200
var azimuth_open_cour = 400
var azimuth_close_cour = 200
val state = executeCommandLine(java.time.Duration.ofSeconds(1), "cat", "/home/franck/canicule/state.txt")
logInfo("test",state)
if (state == "ON")
{
logInfo("test","success")
if ((DonneesAstroduSoleil_Azimut.state as Number).intValue > azimuth_open_TV)
{
shellyswitch25c46c01192168115_Alimentation.sendCommand("ON")
//executeCommandLine("/home/franck/canicule/tv_open.sh")
}
}
My file /home/franck/canicule/state.txt contains “ON” string. In log I see that variable “state” is indeed set to “ON” but with a newline. Making the condition if(state == “ON”) fail.
07:22:47.108 [INFO ] [org.openhab.core.model.script.test ] - ON
My question is how I can remove the newline when I read the content of file with cat ? Or how can I parse the variable content afterwards to remove it?
Thanks