Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X
Hi gentlemen,
I'm using the MQTT extension to get values from my home-automation system. The problem is, that in e.g. the property BRIGHTNESS the MQTT text is a long "story" and not the value itself: This is the String: {"val":150,"ts":"1460135379176","lc":"1460135379176","hm_addr":"MEQ0246804:1"}
Now I want to use the DataChange event to create a small snippet that transfer the value in my new property BRIGHTNESS_NUMBER. Also the last String "MEQ..." is interesting to me and I want to post this into another variable if not already set in the same Thing.
Could anyone help me with the parsing? The String is with the {} at the begin and end. "," is the separator and ":" the separator between the property and its value.
Thanks a lot.
Solved! Go to Solution.
Found my answer by Mr Google:
var array = JSON.parse("[" +me.BRIGHTNESS+ "]")
logger.info("Value: " + array[0].val);
logger.info("TypeID: " + array[0].hm_addr);
me.BRIGHTNESS_VALUE = parseFloat(array[0].val);
Found my answer by Mr Google:
var array = JSON.parse("[" +me.BRIGHTNESS+ "]")
logger.info("Value: " + array[0].val);
logger.info("TypeID: " + array[0].hm_addr);
me.BRIGHTNESS_VALUE = parseFloat(array[0].val);
Hello Stefan,
What base type is used for the new property "me.Brightness_Value"?
I am trying to accomplish the same thing however my property is not displaying the data changed value.