Ah okay, I misunderstood. In that case, try log(MyNum) in your script to see what the actual value of that variable is, perhaps it’s not being parsed correctly.
And/or try setting a fixed value to try and see if it appears:
Can you make a screenshot of the opened “Set a virtual sensor value” card? And I see now that you’re using the Temperature tag there, but the tag you are setting in your code is called RetNum. That’s the tag whose value you want to assign to measure_temperature.
Also, logging the value can be done like this:
log(args);
var MyNum = parseFloat(args[0]);
...the rest of your script...
Perhaps it’s easier if you visit the Homey Slack channel, more people are active there and you can probably get answers much quicker.
You are right. Now I can get it to change values when I press Test flow.
Problem now is that when the message come from MQTT server it look like this:
{ 18.4 }
And when I push test flow and enter the message as { 18.4 } it dont update virtual sensor.
I assume its now the script comes in ?!
Did you try adding an MQTT Device, which is available from the MQTT Hub (beta)? It has the sole purpose of linking capabilities to mqtt topics. Also adds some flow triggers.
I have read so much bad about the MQTT Hub so I want to stick with mosquitto.
What I want to do is getting data from my weatherstation into Homey. And the software I use can send MQTT messages.
Just disable the hub service (app settings, so it will take 0 resources). Try using the MQTT device. Implementation is based on the Virtual Devices.
Maybe it works for ya, maybe not…
You’re not passing any arguments (in the form of a tag) to the script, so args is an empty array. You did pass an argument (Message received from topic) earlier on in this thread.
I now have built a Arudino unit that send MQTT with temp and hum
Problem now is that parseFloat(args[0].match(/[\d.-]+/)[0]); cant get my values beacuse the messages dont look the same. So i need something that can get me values fom this message:
Are your devices (El, Multisensor and Motion sensor) on screenshot virtual or real?
If they are virtual, how did you manage to show value on badget?
I’m very interested to do the same, especially with Lux and Watts. I have to go inside each badget to read value.
P.S
Okay, i found answer. You are using homeydash.