I’ve made a script that calculates the dim level depending on the luminance of a Hue sensor. The values I’m sending in as arguments are the luminance, max level of luminance and the max level of the dim level, ie "214.4,50,0.7"
.
const tokens = args[0].split(',');
const lumOrg = parseFloat(tokens[0]);
const maxLuminance = parseInt(tokens[1], 10);
const maxLight = parseFloat(tokens[2]);
const lumPercent = (lumOrg > maxLuminance) ? 1 : lumOrg / maxLuminance;
const lumPercentRev = 1-lumPercent;
const lumLightValue = Math.round(lumPercent * maxLight, 1);
let lumLightValueRev = lumPercentRev * maxLight;
lumLightValueRev = lumLightValueRev < 0 ? 0 : Math.round(lumLightValueRev * 10) / 10;
await setTagValue('lumvalue', {type: 'number', title: 'lumVal'}, lumLightValue);
await setTagValue('lumvaluereverse', {type: 'number', title: 'lumValReverse'}, lumLightValueRev);
return true;
The thing is that if I set a string (ie await setTagValue('lumvalue', {type: 'string', title: 'lumVal'}, '' + lumLightValue);
) it works fine, but when trying to set a number I get an error:
Flow Card Error: invalid_type
Can anyone please send me into the right direction here and tell me what I should do to set the tag value to the right variable type?