NUT Mini BATTERY SERVICE

All kinds of 'OS' scripts

Moderator: leecollings

Artursd
Posts: 86
Joined: Sunday 16 December 2018 17:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: NUT Mini BATTERY SERVICE

Post by Artursd »

User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: NUT Mini BATTERY SERVICE

Post by emme »

you do need to install the noBle node:

Settings/Manage Palettes/Install
then search for node-red-contrib-noble
and install it
The most dangerous phrase in any language is:
"We always done this way"
Artursd
Posts: 86
Joined: Sunday 16 December 2018 17:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: NUT Mini BATTERY SERVICE

Post 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]
???????
Artursd
Posts: 86
Joined: Sunday 16 December 2018 17:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: NUT Mini BATTERY SERVICE

Post by Artursd »

User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: NUT Mini BATTERY SERVICE

Post by emme »

try with

sudo npm install bluetooth-hci-socket
sudo reboot

and the reinstall noble node
The most dangerous phrase in any language is:
"We always done this way"
Artursd
Posts: 86
Joined: Sunday 16 December 2018 17:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: NUT Mini BATTERY SERVICE

Post by Artursd »

Artursd
Posts: 86
Joined: Sunday 16 December 2018 17:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: NUT Mini BATTERY SERVICE

Post by Artursd »

Artursd
Posts: 86
Joined: Sunday 16 December 2018 17:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: NUT Mini BATTERY SERVICE

Post by Artursd »

Artursd
Posts: 86
Joined: Sunday 16 December 2018 17:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: NUT Mini BATTERY SERVICE

Post by Artursd »

Переустановил Node-Red заново. все заработало. СПАСИБО
pimseb
Posts: 42
Joined: Wednesday 13 September 2017 13:51
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: France
Contact:

Re: NUT Mini BATTERY SERVICE

Post 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
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: NUT Mini BATTERY SERVICE

Post 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...
The most dangerous phrase in any language is:
"We always done this way"
pimseb
Posts: 42
Joined: Wednesday 13 September 2017 13:51
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: France
Contact:

Re: NUT Mini BATTERY SERVICE

Post 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 ?
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: NUT Mini BATTERY SERVICE

Post 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
The most dangerous phrase in any language is:
"We always done this way"
pimseb
Posts: 42
Joined: Wednesday 13 September 2017 13:51
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: France
Contact:

Re: NUT Mini BATTERY SERVICE

Post 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
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: NUT Mini BATTERY SERVICE

Post 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
The most dangerous phrase in any language is:
"We always done this way"
pimseb
Posts: 42
Joined: Wednesday 13 September 2017 13:51
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: France
Contact:

Re: NUT Mini BATTERY SERVICE

Post 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 ?
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: NUT Mini BATTERY SERVICE

Post 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!!!
The most dangerous phrase in any language is:
"We always done this way"
Artursd
Posts: 86
Joined: Sunday 16 December 2018 17:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: NUT Mini BATTERY SERVICE

Post by Artursd »

https://yadi.sk/i/9Jt1hhnhuo-01g Yesterday everything worked. Today booted and everything again ......
Artursd
Posts: 86
Joined: Sunday 16 December 2018 17:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: NUT Mini BATTERY SERVICE

Post by Artursd »

Artursd
Posts: 86
Joined: Sunday 16 December 2018 17:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: NUT Mini BATTERY SERVICE

Post by Artursd »

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests