I think I found a solution by creating a small script. The only thing I miss in this script is how do I get the result in a var which I can use for a logic decision and should I create a true part because the result is underfunded.
The format of the line where you store the value to the BL variable, must be like: let result=BLApp.apiPut("RadioDag/" + randomNumber);
"RadioDag" is the Variable Name, / (backslash) is also very important, it must be added after the Variable name randomNumber is the value that is inserted into the BL Variable.
I tried a lot of things but did not succeed to get the result in a var.
Looking to the script I am using, what is the name of the var I should make in Better Logic?
Sorry but I do not have knowledge about scripting… Learning a bit… takes time.
You can use a name of your choice, as long as you use exactly the same name in the script routine, also the variable type must be the same (String or number or boolean)
As the last line of your script you can use; return true; so you can run this script in the AND column.
There is one thing to solve. I think I have to create a 2nd script which reads the MQTT Topic. The 1st script was about : Message received via Topic.
The received Topic is: opensprinkler/station/#
‘#’ is a number between 0 & 7.
What will be a simple way to put this number in a var? That means the Topic wil be (example):
opensprinkler/station/7
var ZoneNumber = 7
Doesn’t the MQTT Client app provide the topic in a token that you can pass as second argument (args[1]) to your script? Then you can extract the number from the topic name.
This is wat I receive as Topic message: opensprinkler/station/7. I only need the last digit.
This text does not look the same as the Topic message: {“state”:1}.
Oh right, I thought that Homeyscript also had a card that would accept multiple arguments, but apparently it only has a card that accepts one argument.
I got the topic in a var. This problem has been solved. But I created a new one.
the MQTT ‘message’ is the total of the message + topic. See used script below and result: