Battery checker

Meggi
Tue, 02 Sep 2025 16:51:02 +0000
Devices

Here is a homey script that automatically goes in and finds the devices that are using battery and will give you a push notification on your mobile, with the name(s) of the device and how many % are left on the battery.

You can choose in the script how many % the battery must be below before you get a notification. Line 9 - (battery <= 20; // Here you can change %) It is set to 20%.

Remember to run the script before you create a flow, as then ”tags” will be created

Remember to install ”HOMEY SCRIPT”

Flow: My check once a day: AT 6:00 PM

If I don't answer any questions, it's because I'm sick.
But I hope you can figure it out.

It was me and AI who made this script. 😁

Here is the script:



// Get all devices and filter for those with a battery
let batteryDevices = Object.values(await Homey.devices.getDevices()).filter(device =>
  device.capabilities.includes('measure_battery')
);

// Find all devices with a battery level of 10% or less
let lowBatteryDevices = batteryDevices.filter(device => {
  let battery = device.capabilitiesObj.measure_battery.value;
  return battery !== null && battery <= 20; // Here you can change %
});

// Prepare the notification message
let message;
if (lowBatteryDevices.length === 0) {
  // If all devices are OK, the message is an empty string
  message = '';
} else {
  // Otherwise, create a clear list of devices with low battery
  message = 'Low Battery Alert:';
  lowBatteryDevices.forEach(device => {
    let battery = device.capabilitiesObj.measure_battery.value;
    message += `\n${device.name}: ${battery}%`;
  });
}

// Create a flow tag for the message
await tag('low_battery', message);

// This return value is for confirmation and is not used in the flow
return 'Script executed successfully and created the "low_battery" tag.';

12 posts - 4 participants