# How to use a wildcard for a device capability

**URL:** https://community.homey.app/t/how-to-use-a-wildcard-for-a-device-capability/74925
**Category:** Developers
**Tags:** homeyscript
**Created:** [January 11, 2023, 2:11pm UTC](https://community.homey.app/t/how-to-use-a-wildcard-for-a-device-capability/74925 "2023-01-11T14:11:50Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)
#### Post date: [January 11, 2023, 2:11pm UTC](https://community.homey.app/t/how-to-use-a-wildcard-for-a-device-capability/74925/1 "2023-01-11T14:11:50Z")

</div>

Hi guys, I can’t get my head around this.

I have this piece of HS code and, next to other data, I want to return the `lastUpdated` timestamp. That works, but only for _one_ capability (and I have three):

```auto
invalidatedDevices.push("- " + device.name + " - " + device.capabilitiesObj?.measure_temperature?.lastUpdated?.substring(0,16) + "\n (zone: " + device.zoneName + ")" );

```

Now I thought, I need the device capability `measure_temperature` to be a wildcard, so it returns any capability.  
(The capabilities are narrowed down alr on beforehand, to that one and `alarm_contact` and `alarm_motion`)

Is it even possible, and if yes, how?

Many thanks in advance!  
~Peter

#### The complete script:

```auto
// Sensor.Check, to check on sensor last update time. Argument: inactive time (in seconds):

const INVALIDATE_AFTER = 86400

const invalidatedDevices = [];
for (const device of Object.values(await Homey.devices.getDevices())) {
  if (! device.capabilitiesObj) continue;
  let count = 0;
  for (const capabilityObj of Object.values(device.capabilitiesObj)) {
    
    if (device.capabilitiesObj.measure_temperature || device.capabilitiesObj.alarm_contact || device.capabilitiesObj.alarm_motion ) { 

      if (! capabilityObj?.lastUpdated || (Date.now() - new Date(capabilityObj?.lastUpdated) > INVALIDATE_AFTER * 1000)) {
        count++;
        }
    }
  }
  if (count && count === Object.keys(device.capabilitiesObj).length) {
  invalidatedDevices.push("- " + device.name + " - " + device.capabilitiesObj?.measure_temperature?.lastUpdated?.substring(0,16) + "\n (zone: " + device.zoneName + ")" ); 
  }
}

// When there are matching sensors
if ( invalidatedDevices.length != 0 ) {
  console.log("Devices without updates for " + INVALIDATE_AFTER / 3600 + "hrs: \n" + invalidatedDevices.join('\n'));
  return("Devices without updates for " + INVALIDATE_AFTER / 3600 + "hrs: \n" + invalidatedDevices.join('\n'));
}

// Original script by Robert Klep  
// https://community.homey.app/t/a-script-to-check-sensor-last-update/63142/9

```

@Arie_J_Godschalk any thoughts?
