Переустановил Node-Red заново. все заработало. СПАСИБО
Re: NUT Mini BATTERY SERVICE
Posted: Monday 21 January 2019 21:40
by pimseb
Please write in english !
Emme do you have a simple lua script that sends a notification when battery (user variable) goes < 10 ?
I'm trying to write it with no success...
I had the idea to send a notification when <10 and another one when <5
For both of us (2 tags in the house) in one single script. Is this possible or do I need to write a script for each person ?
Thanks
Re: NUT Mini BATTERY SERVICE
Posted: Tuesday 22 January 2019 8:50
by emme
mmh you can do that.... I had it once, but then I delete it
as soon as both thatteries has the same unique prefix (like BattNut_) you can have a script that checks every day and send a message
but I would also suggest you NOT to claim battery as it drawn it quickly
..at least create a device for battery and add a notification on it...
Re: NUT Mini BATTERY SERVICE
Posted: Tuesday 22 January 2019 10:37
by pimseb
Too bad you deleted it. I've spend last evening trying to make it work with no luck...
If I do a battery check one time a week will it drain the battery quickly ?
Re: NUT Mini BATTERY SERVICE
Posted: Tuesday 22 January 2019 10:52
by emme
what did'n work?... the battery check or the notification script?
if you provide me the device names I can write it back in few hours
Re: NUT Mini BATTERY SERVICE
Posted: Tuesday 22 January 2019 13:23
by pimseb
Here is the script I tried to make but it was only for testing purposes and only for one device. We have in fact 2 nuts : one with user variable batterie_pim and the other one with user variable batterie_ben
It doesn't work so don't use it...
commandArray = {}
if (uservariables_lastupdate['batterie_pim']) then
if (uservariables['batterie_pim']>"5") and (uservariables['batterie_pim']<"12") then
commandArray['SendNotification']='Le niveau de la batterie du tag de pim est faible '
elseif (uservariables['batterie_pim']<="5") then
commandArray['SendNotification']='Le niveau de la batterie du tag de pim est extrêmement bas ! Il faut changer la batterie'
end
end
return commandArray
local lowTrigger = 5
local highTrigger = 12
return {
on = {
variables = { 'batterie_*' },
logging = {
level = domoticz.LOG_FORCE,
marker = '[BLE Battery Service]'
}
},
execute = function(dz, devVar)
local actValue = tonumber(devVar.value)
if actValue > lowTrigger and actValue < highTrigger then
dz.notify('Battery Service','Le niveau de la batterie du tag de pim '..devVar.name..' est faible ')
elseif actValue <= lowTrigger then
dz.notify('Battery Service','Le niveau de la batterie du tag de pim '..devVar.name..' est extrêmement bas ! Il faut changer la batterie')
end
end
}
this should works for any variable whose name start with 'batterie_'
ciao
M
Re: NUT Mini BATTERY SERVICE
Posted: Tuesday 22 January 2019 15:05
by pimseb
Grazie mille
It works like a charm. I wish I would have to knowledge to write such scripts.
Where could I start ? Better to learn lua or dzVents ? Is there a tutorial somewhere ?
Re: NUT Mini BATTERY SERVICE
Posted: Tuesday 22 January 2019 15:37
by emme
I did not even know LUA!!!
I took 3 month to understand LUA for domoticz related issues.... you you would not take longer
at the end thay are just if.. then.. else... end statements...
start with this script and "unpack" it to understand what it is doing....
then I create a pushbutton named TEST that trigger a script for... well.. test purpose
dzVents is LUA program language in a json string... so it has few statements to well understand but after that it is quite easy!