Okay, I am really a newbie in scripting… I have copy/pasted from the best of my knowledge, but I fail!
I am trying to read the Wind angle from a Netatmo Aneometer but this script return: Undefined
var angle
let devices = await Homey.devices.getDevices();
_.forEach(devices, device => {
if (device.name ==‘Netatmo - Vind’) {
angle = device.capabilities.measure_wind_angle;
}
});
return angle;
Well, thank you both. I did look in the delveloper tools and copy/pasted from there. Tried with device.capabilities[‘measure_wind_angle’]; but nothing else than Undefined…sadly
My script works just fine, thanks to you. But now I want to use the output, directions[ section ], to be used as a logical alpha for use in a flow. This is how the script looks like:
// Part I - getting the wind direction in degrees from my Netatomo Anemometer
var angle
let devices = await Homey.devices.getDevices();
_.forEach(devices, device => {
if (device.name ==‘Netatmo - Vind’) {
angle = device.capabilitiesObj?.measure_wind_angle?.value;
}
});
// Part II - converting wind direction in degrees to Cardinals
let directions = [“N”,“NNE”,“NE”,“ENE”,“E”,
“ESE”, “SE”, “SSE”,“S”,
“SSW”,“SW”,“WSW”,“W”,
“WNW”,“NW”,“NNW” ];
let section = parseInt( angle/22.5 + 0.5 );
section = section % 16;
return directions[ section ];
After the variable you want. Is your variable directions[section]? In that case:
await tag(‘Directions’, directions[section]).
‘Directions’ maybe any given name you want as Tag, directions[section] has to be the name of your variable