# The Flow Exchange(r) - Exchange Your Flows with Others!

**URL:** <https://community.homey.app/t/the-flow-exchange-r-exchange-your-flows-with-others/68981>\
**Category:** Flows\
**Tags:** app, tools, advancedflow, device-capabilities, avd\
**Created:** [September 16, 2022, 7:36pm UTC](https://community.homey.app/t/the-flow-exchange-r-exchange-your-flows-with-others/68981 "2022-09-16T19:36:49Z")\
**Posts on this page:** 1\
**Showing post:** 36

<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:** [November 1, 2022, 1:36am UTC](https://community.homey.app/t/the-flow-exchange-r-exchange-your-flows-with-others/68981/36 "2022-11-01T01:36:13Z")

</div>

# Send a report with all battery levels

When you’d like to receive an overview, with the battery levels of all battery powered Homey devices

 ![Screenshot from 2022-11-01 02-24-12](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/5/b/5bce8e26a32169a2aa96ac4fcda03c2ef9b33c03.png)

### Apps used:

- [HomeyScript](https://homey.app/nl-nl/app/com.athom.homeyscript)
- [CallMeBot](https://homey.app/a/com.gruijter.callmebot/) - You can replace it with your own messaging app
- [Email sender](https://homey.app/nl-nl/app/email.sender) - Optional - just an example messaging app you can use

### HomeyScript code used (it’s included in the flow):

(Updated @ March 2nd 2025)

```auto
const devicesObject = await Homey.devices.getDevices({ filter: { class: 'sensor' } });
const deviceKeys = Object.keys(devicesObject);
const batteryLevels = [];

for (const deviceKey of deviceKeys) {
  const device = devicesObject[deviceKey];
    const batteryCapability = device.capabilitiesObj?.measure_battery;
      if (batteryCapability) {
          const batteryLevel = batteryCapability.value;
              const deviceName = device.name;
                  batteryLevels.push({ name: deviceName, battery: batteryLevel });
                    }
                    }
                    batteryLevels.sort(function(a, b) {
                        return a.battery - b.battery;
                        });
                  
                    const batteryInfoText = batteryLevels.map((device) => `${device.name}: ${device.battery}%`).join('\n');

console.log('Battery levels:\n' + batteryInfoText);

return 'Battery levels:\n' + batteryInfoText;

```

> **click for OLD script**
>
> ```auto
> // battery-report
> let array = [];
> 
> const devices = await Homey.devices.getDevices({ filter: {capabilities: 'measure_battery'} });
> _.forEach(devices, device => {
> array.push( device.name + ': \n' + device.capabilitiesObj?.measure_battery.value + '%' );
> });
> 
> //oldest date on top sort array = ["time_stamp device", "time_stamp device", "time_stamp device"]
> const array_sorted = array.slice().sort(function(time_stamp, device) { 
> const firsttime_stamp = time_stamp.split(" ")[0];
> const secondtime_stamp = device.split(" ")[0];
> if(firsttime_stamp < secondtime_stamp) return -1;
> if(firsttime_stamp > secondtime_stamp) return 1;
> return 0;
> });
> 
> return("Battery levels:\n" + array_sorted.join('\n') + "\n");
> 
> ```

TEF:

```auto
[TEF:FLOWS:H4sIAAAAAAACA6VWW2/bNhT+KwSBwTYayrpQkqUu3dCtwIY9tGgeLcM4FClHgW6Q6LSB4f++Q0pG6sQB3O3Btnx4Lt/5eC46UEnTA41U4nmx5zIpVcx4EkYM4kSwOIiKSElfChBGr6EpvSt3DVTkY6vpDc1R0Op71dPj8YburS8RBAEEivmrFTDuJgkDtxCsCBI3gMgN85iffH1RWvXkH/gG1l4bed7WDuh7/MaPehryvuz0yeAvI7obRWigaigrZ1CNRASTyicjI5PMeAWarg+0xCNPyjCWCMiHImdc+ZwJNy+YG8ok5lLlURhhUsbLV9W1vSZQVUSARpRPpFKPqhrwXNFU93tlsz/QhBe8kEXCokhIxgtfMPCFy0BKGXtRosIoNHrfaere0Ceaei7+thjD5pfW0MBO9WlRtd/QucHZ9e2uh7oGXeZb3Zc7PN8O+NDsthp21DJFpwP8N2CGtECWcw84CwLPQxy5x0QiPCaFhCRchbLgAd0gHyHn3PeDhOWxh4Dd2EesQcCU8Nw4iJM4WMkJsMdHyL47hhw09PqnA16lOAbk/CJH0HXp5boYCev3zR+tVF+V3vfNcGeZmliCXJdtc8KsuIq46ym2KvIVFnoUMqEAWMxXiCIOAgEu6iZFEvq5D0zwCBHLGFgiuGQyTJIoEK4MVIBqrpsIEQYhi5THkUkXEwM/Zytk0JP5CiIBdGMr0NS1xMKhy+WpoFhva8x5GEjWVAqLre/hidyS9eZ91mRN3jaDJlI9lrkaUIxdUmpiO8CZpM5O6T/Hx/mBFGWFflNyyKEDUValLtWQklmtYNj3ajvFnR3JcYERtk7R9p8gv59P3m6mYOT2AzlkjYXjdPvhfj4dOA3UipB3ZJYSkmXNDB+nkx9DfhYPvzkvgjqPUO2VMf1lRkx0CyFrlsu2ksrkCVqRtiG67chgW+/ERkZ1WSusf6i7KVxGb8jPiMnmRKf1ujUBlDSc2hyHCrXmC8eI58W+sSUzf/ZzImZBDnhVZPRUlP2gf4h1S57/OEOHVMwxcEYXa9fc52Q1KPyVZ2YTgxdMymL+MsqvrzwsSG/LnjDvDZsPb9tYk+nZfb6VUYJgPp7NvhTvHAG+O2PReWjLZj4z5bDAo4xapcV7O3uv6rex9RN3an3/rPVHdtKrNtQ4DMzof9n8tgPrYYey9XqUpuk1cylNx7m72eDNr82MJm+uho1N+arZcZ6y71/cCHWLHaVOOwH7cKvVd30xtf0wLUBs0PO9itY4za/byqhbY2QDROtuSJdL6Mpp6OL4XZooKHsEXAMmsjn423g3u9hi++/0Wu6uGqjn3AWvN8XZW8FzTcCQl+XlwkB9bXxM9/n7eJ8mZ7M49uJB5fr09mFeLbDyX78WiFY+/T8CjsfN8V+C9g3vkgkAAA==]

```

---

_[View the full topic](https://community.homey.app/t/the-flow-exchange-r-exchange-your-flows-with-others/68981)._
