Page 3 of 6

Re: NUT Mini BATTERY SERVICE

Posted: Thursday 27 December 2018 11:46
by Artursd

Re: NUT Mini BATTERY SERVICE

Posted: Thursday 03 January 2019 8:27
by emme
you do need to install the noBle node:

Settings/Manage Palettes/Install
then search for node-red-contrib-noble
and install it

Re: NUT Mini BATTERY SERVICE

Posted: Monday 21 January 2019 10:42
by Artursd
Welcome to Node-RED
===================

21 Jan 11:16:42 - [info] Node-RED version: v0.19.5
21 Jan 11:16:42 - [info] Node.js version: v10.15.0
21 Jan 11:16:42 - [info] Linux 4.14.92-v7+ arm LE
21 Jan 11:16:43 - [info] Loading palette nodes
21 Jan 11:16:49 - [warn] ------------------------------------------------------
21 Jan 11:16:49 - [warn] [node-red-contrib-noble/noble] Error: Cannot find module 'bluetooth-hci-socket'
21 Jan 11:16:49 - [warn] ------------------------------------------------------
21 Jan 11:16:49 - [info] Settings file : /root/.node-red/settings.js
21 Jan 11:16:49 - [info] Context store : 'default' [module=memory]
21 Jan 11:16:49 - [info] User directory : /root/.node-red
21 Jan 11:16:49 - [warn] Projects disabled : editorTheme.projects.enabled=false
21 Jan 11:16:49 - [info] Flows file : /root/.node-red/flows_raspberrypi.json
21 Jan 11:16:49 - [warn]
???????

Re: NUT Mini BATTERY SERVICE

Posted: Monday 21 January 2019 10:44
by Artursd

Re: NUT Mini BATTERY SERVICE

Posted: Monday 21 January 2019 10:49
by emme
try with

sudo npm install bluetooth-hci-socket
sudo reboot

and the reinstall noble node

Re: NUT Mini BATTERY SERVICE

Posted: Monday 21 January 2019 15:46
by Artursd

Re: NUT Mini BATTERY SERVICE

Posted: Monday 21 January 2019 15:51
by Artursd

Re: NUT Mini BATTERY SERVICE

Posted: Monday 21 January 2019 16:11
by Artursd

Re: NUT Mini BATTERY SERVICE

Posted: Monday 21 January 2019 18:24
by Artursd
Переустановил 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...

Code: Select all

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
If you can make it working with both tags.... Thx

Re: NUT Mini BATTERY SERVICE

Posted: Tuesday 22 January 2019 14:12
by emme
I'm more familiar with dzVents:

Code: Select all

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 :D :D

dzVents is LUA program language in a json string... so it has few statements to well understand but after that it is quite easy!

Danny made a great work even on the tutorial!!!

Re: NUT Mini BATTERY SERVICE

Posted: Tuesday 22 January 2019 21:19
by Artursd
https://yadi.sk/i/9Jt1hhnhuo-01g Yesterday everything worked. Today booted and everything again ......

Re: NUT Mini BATTERY SERVICE

Posted: Tuesday 22 January 2019 21:23
by Artursd

Re: NUT Mini BATTERY SERVICE

Posted: Tuesday 22 January 2019 21:25
by Artursd