Homey Community

Get value from MQTT and set a variable



my idea is to receive a value over MQTT or HTTP request and write this value to a virtual Device or variable.

In case of MQTT there is a tag “message received from topic”, but this tag is only available for comparison/Logic in the AND flow. I see no possibilities to use the value that is in the message Tag to use it in the THEN flow.

I think the main reason will be, that the message is a STRING and it has to be converted to a number before it can be used for a “set value”.

Are there any other possibilities to receive values from outside and use this values in homey flows?


Homey 2.0.0 Experimental discussion [EN]

I had the same issue and used Homey script to convert the value to an integer.


to use HomeyScript sounds good. Bu I have no experience with that.
Can anyone help me to program this function to get a start?

My idea is to create a general function with two arguments.

StringToNumber(String, Number)



ok, I found a solution:

HomeyScript that converts the argument to a number and create a Tag “RetNum” with the result

// Converts a atring to a number
var MyNum = parseFloat(args[0])
await setTagValue("RetNum", {type: "number", title: "RetNum"}, MyNum);
return true;

The flow looks like this: