How to read a sensor with a homey script

I am writing my first script and want to read the temperature of an Aqara sensor with name “Aqara ute”.
What is missing in this script?

var temp
let devices = await Homey.devices.getDevices();
_.forEach(devices, device => {
if (device.name == “Aqara ute”) {
temp = device.state.measure_temperature;
}
});
return temp;

Script Error:
Cannot read property ‘measure_temperature’ of undefined

I’m not sure why you’re using device.state, AFAIK that property doesn’t exist.

Reading the current value of a capability from Homeyscript was discussed here.