Page 1 of 1

LowBat warning for device with no battery

Posted: Wednesday 20 December 2017 10:59
by pgas37
from the dzvents examples in Domoticz I installed the "check battery levels.lua" The scripts reports the low batteries just fine.
Yesterday i added a new switch to the system. A 220V switch (klik-aan-klik-uit) without a battery, but the script reports a low battery condition for that switch. Delete the switch and add it again is no solution.

I tried a if..then script to filter out the specific switch, but my skills are insufficient.

Can anyone help?

Code: Select all

[local BATTERY_THRESHOLD = 10

return {
	active = true,
	on = {
		['timer'] = {
			'every hour'
		}
	},
	execute = function(domoticz)

		local message = ''

		-- first filter on low battery level
		local lowOnBat = domoticz.devices().filter(function(device)

			local level = device.batteryLevel -- level is 0-100
			return (level ~= nil and -- not all devices have this attribute
					level <= BATTERY_THRESHOLD)

		end)

		-- then loop over the results
		lowOnBat.forEach(function(lowDevice)

			message = message .. 'Device ' ..
				lowDevice.name .. ' is low on batteries (' .. tostring(lowDevice.batteryLevel) .. '), '

		end)

		if (message ~= '') then
			domoticz.notify('Low battery warning', message, domoticz.PRIORITY_NORMAL)
			domoticz.log('Low battery warning: ' .. message, domoticz.LOG_ERROR)
		end
	end
}

Re: LowBat warning for device with no battery

Posted: Wednesday 20 December 2017 11:36
by BakSeeDaa
pgas37 wrote: Wednesday 20 December 2017 10:59 Can anyone help?
Can you give us a device status listing for that device so that we have more to work with?

Re: LowBat warning for device with no battery

Posted: Wednesday 20 December 2017 14:08
by pgas37
Thanks,

i did a devicestatus for idx 110. I hope it wil help you.

Code: Select all

[{
   "ActTime" : 1513775010,
   "ServerTime" : "2017-12-20 14:03:30",
   "Sunrise" : "08:50",
   "Sunset" : "16:26",
   "result" : [
      {
         "AddjMulti" : 1.0,
         "AddjMulti2" : 1.0,
         "AddjValue" : 0.0,
         "AddjValue2" : 0.0,
         "BatteryLevel" : 255,
         "CustomImage" : 0,
         "Data" : "Off",
         "Description" : "",
         "Favorite" : 0,
         "HardwareID" : 2,
         "HardwareName" : "RFX433-pgas",
         "HardwareType" : "RFXCOM - RFXtrx433 USB 433.92MHz Transceiver",
         "HardwareTypeVal" : 1,
         "HaveDimmer" : true,
         "HaveGroupCmd" : true,
         "HaveTimeout" : false,
         "ID" : "0B51A46",
         "Image" : "Light",
         "IsSubDevice" : false,
         "LastUpdate" : "2017-12-20 12:30:01",
         "Level" : 100,
         "LevelInt" : 15,
         "MaxDimLevel" : 15,
         "Name" : "Boiler_4_1",
         "Notifications" : "false",
         "PlanID" : "0",
         "PlanIDs" : [ 0 ],
         "Protected" : false,
         "ShowNotifications" : true,
         "SignalLevel" : "-",
         "Status" : "Off",
         "StrParam1" : "",
         "StrParam2" : "",
         "SubType" : "AC",
         "SwitchType" : "On/Off",
         "SwitchTypeVal" : 0,
         "Timers" : "true",
         "Type" : "Lighting 2",
         "TypeImg" : "lightbulb",
         "Unit" : 8,
         "Used" : 1,
         "UsedByCamera" : false,
         "XOffset" : "0",
         "YOffset" : "0",
         "idx" : "110"
      }
   ],
   "status" : "OK",
   "title" : "Devices"
}]

Re: LowBat warning for device with no battery

Posted: Wednesday 20 December 2017 16:47
by BakSeeDaa
There is a [ sign at the beginning of the script.

Can't see that this device will be reported. It has a batterylevel of 255 which is normal for some non battery powered devices.

What is the exact message that you get?

Re: LowBat warning for device with no battery

Posted: Wednesday 20 December 2017 17:40
by pgas37
Email warning:
Subject: low battery warning
Device Boiler_4_1 is low on batteries (0),

Re: LowBat warning for device with no battery

Posted: Wednesday 20 December 2017 18:06
by BakSeeDaa
I think we need to wait and see if @dannybloe has an answer to this. I could be good to know what version of dzVents you are using.

Re: LowBat warning for device with no battery

Posted: Wednesday 20 December 2017 18:53
by pgas37
Version of dzventz; i do not know where to find my version. I use domoticz v 3,8153 and the dzvents that came with that version.

Re: LowBat warning for device with no battery

Posted: Friday 22 December 2017 8:38
by tlpeter
I have had the same in the past but i had t just a couple of times.