Send a report with all battery levels
When you want an overview sent to you, with the battery levels of all battery powered Homey devices
Apps used:
- HomeyScript
- CallMeBot - You can replace it with your own messaging app
- Email sender - Optional - just an example messaging app you can use
HomeyScript code used (it’s included in the flow):
// 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:
[TEF:FLOWS:H4sIAAAAAAACA6VWW2/bNhT+KwSBwTYayrpQkqUu3dCtwIY9tGgeLcM4FClHgW6Q6LSB4f++Q0pG6sQB3O3Btnx4Lt/5eC46UEnTA41U4nmx5zIpVcx4EkYM4kSwOIiKSElfChBGr6EpvSt3DVTkY6vpDc1R0Op71dPj8YburS8RBAEEivmrFTDuJgkDtxCsCBI3gMgN85iffH1RWvXkH/gG1l4bed7WDuh7/MaPehryvuz0yeAvI7obRWigaigrZ1CNRASTyicjI5PMeAWarg+0xCNPyjCWCMiHImdc+ZwJNy+YG8ok5lLlURhhUsbLV9W1vSZQVUSARpRPpFKPqhrwXNFU93tlsz/QhBe8kEXCokhIxgtfMPCFy0BKGXtRosIoNHrfaere0Ceaei7+thjD5pfW0MBO9WlRtd/QucHZ9e2uh7oGXeZb3Zc7PN8O+NDsthp21DJFpwP8N2CGtECWcw84CwLPQxy5x0QiPCaFhCRchbLgAd0gHyHn3PeDhOWxh4Dd2EesQcCU8Nw4iJM4WMkJsMdHyL47hhw09PqnA16lOAbk/CJH0HXp5boYCev3zR+tVF+V3vfNcGeZmliCXJdtc8KsuIq46ym2KvIVFnoUMqEA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