# \[APP\]\[Pro\] Device Capabilities - Enhance the capabilities of devices

**URL:** <https://community.homey.app/t/app-pro-device-capabilities-enhance-the-capabilities-of-devices/43287>\
**Category:** Apps\
**Tags:** flow, virtual-device, homey-pro, device-capabilities, avd\
**Created:** [February 19, 2021, 8:20am UTC](https://community.homey.app/t/app-pro-device-capabilities-enhance-the-capabilities-of-devices/43287 "2021-02-19T08:20:51Z")\
**Posts on this page:** 1\
**Showing post:** 1035

<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 9, 2023, 1:37pm UTC](https://community.homey.app/t/app-pro-device-capabilities-enhance-the-capabilities-of-devices/43287/1035 "2023-01-09T13:37:24Z")

</div>

Sorry for the inconvenience.  
I just checked, and the updated version is different.  
Now I don’t understand how the 3 homeyscript cards and that script ended up with your flows after the import. When did you imported the TEF? Not recently?

I just [imported the TEF](https://community.homey.app/t/the-flow-exchange-r-exchange-your-flows-with-others/68981/13) twice, to make sure, and it is the one I expect; there’s one Homeyscript card in it, and this is te code in it:

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

const INVALIDATE_AFTER = (args[0]); // Example 86400sec./3600 = 24hrs

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 + "\n (zone: " + device.zoneName + ")" );
  }
}

// When there are matching sensors
if ( invalidatedDevices.length != 0 ) {
  // create / update HomeyScript variable
  await tag('InvalidatedDevices', invalidatedDevices.join('\n'));
  
  // Send Timeline notification
  Homey.flow.runFlowCardAction({
          uri: 'homey:manager:notifications',
          id: 'create_notification',
          args: {
            text: "\nDevices without updates for " + INVALIDATE_AFTER / 3600 + "hrs: \n" + invalidatedDevices.join('\n') + "\n\nflow Sensors Check"
          },
        });

  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'));
}
  
// When there's no matching sensor
if ( invalidatedDevices.length == 0 ) {
  // Just report "None"
  // create / update HomeyScript variable
  await tag('InvalidatedDevices', 'None');
// Send Timeline notification
  Homey.flow.runFlowCardAction({
          uri: 'homey:manager:notifications',
          id: 'create_notification',
          args: {
            text: "\nDevices without updates for " + INVALIDATE_AFTER / 3600 + "hrs: None\n\nflow Sensors Check"
          },
        });

  console.log("Devices without updates for " + INVALIDATE_AFTER / 3600 + "hrs: None" );
  return invalidatedDevices.length != 0;
}

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

```

---

_[View the full topic](https://community.homey.app/t/app-pro-device-capabilities-enhance-the-capabilities-of-devices/43287)._
