How to set device value on script

Thanks for good advice and direction to go… needed some help with AI to create code but helped a lot how to push it to correct direction :+1:

For records if someone else finds idea useful:

const devices = await Homey.devices.getDevices();

sensorName = "_HiidenSite";
capabilityTitle = "currentOutTemp";
newValue = "-18.2";


  for (const device of Object.values(devices)) {
    if (device.name === sensorName) {
      for (const capability of Object.values(device.capabilitiesObj)) {
        if (capability.title === capabilityTitle) {
          try {
            await device.setCapabilityValue(capability.id, newValue);
            console.log(`Changed '${capabilityTitle}' value to ${newValue} for ${sensorName}`);
            return newValue; // Indicate the value has been updated
          } catch (error) {
            console.error("Failed to update value:", error);
            return -999; // Indicate update failure
          }
        }
      }
      return -1999; // Indicate capability title not found for the sensor
    }
  }
  return -2999; // Indicate sensor not found

Changed ‘currentOutTemp’ value to -18.2 for _HiidenSite

———————————————————
:white_check_mark: Script Success

:leftwards_arrow_with_hook: Returned: “-18.2”

and

image