dzVents 1.0 released

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

HenFre
Posts: 6
Joined: Thursday 12 May 2016 15:48
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8771
Location: Sweden
Contact:

Re: dzVents 1.0 released

Post by HenFre »

Hi.

Magnificent works with dzVents. I love it. :)

But dzVents seems to be too fast to the log. Timer event needs to be more spread out in seconds or something? I have about 25 scripts that starts every minutes.
Only the last 9 to 12 will be notified in the log. The rest is overflow or something.
2016-06-23 Logg 01.JPG
2016-06-23 Logg 01.JPG (386.44 KiB) Viewed 2992 times
Last edited by HenFre on Friday 24 June 2016 0:32, edited 2 times in total.
Domoticz on Raspberry PI 3 since 2016.
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: dzVents 1.0 released

Post by dannybloe »

Yeah, I gotta make it more controllable. But you can change the logging to only errors in dzVents_settings.lua.

But indeed Domoticz cannot handle a flood of log additions.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
HenFre
Posts: 6
Joined: Thursday 12 May 2016 15:48
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8771
Location: Sweden
Contact:

Re: dzVents 1.0 released

Post by HenFre »

Thanks Danny.

I have now solved it by longer scripts. But I have to close down too big part of the system when I develops new code.
I hope you will found a simple solution. (Y)
Domoticz on Raspberry PI 3 since 2016.
woody4165
Posts: 476
Joined: Monday 14 March 2016 13:55
Target OS: Linux
Domoticz version: beta
Location: Rome, Italy
Contact:

Re: dzVents 1.0 released

Post by woody4165 »

Hi

I'm moving from RPi to Cubieboard 3 with armbian
I've installed domoticz and all the other addons that I used to have on RPi lie izsynth, presence beacon and others.
I did also with dzVents, but I'm getting a strange error that I don't understand

Code: Select all

Error: EventSystem: in /home/linaro/domoticz/scripts/lua/script_device_main.lua: /home/linaro/domoticz/scripts/lua/dzVents/Domoticz.lua:350: bad argument #1 to 'pairs' (table expected, got nil)
tried to search on the 3d, but found nothing.

Any suggestion?

Thanks
Cubietruck - Linux cubietruck 4.13.16 (Debian GNU/Linux 8 (jessie)) + Domoticz + RFLink, Xiaomi Gateway, Owl USB, Yeelight Color and B/W, ESP8266, Broadlink RM2, Netatmo Thermostat
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: dzVents 1.0 released

Post by dannybloe »

woody4165 wrote:Hi

I'm moving from RPi to Cubieboard 3 with armbian
I've installed domoticz and all the other addons that I used to have on RPi lie izsynth, presence beacon and others.
I did also with dzVents, but I'm getting a strange error that I don't understand

Code: Select all

Error: EventSystem: in /home/linaro/domoticz/scripts/lua/script_device_main.lua: /home/linaro/domoticz/scripts/lua/dzVents/Domoticz.lua:350: bad argument #1 to 'pairs' (table expected, got nil)
tried to search on the 3d, but found nothing.

Any suggestion?

Thanks
Mmm, it looks like the http data didn't come through. Can you check the file devices.lua? It should have this structure:

Code: Select all

return
{
	["result"]= {
	....
	}
}
I suspect that the bash command 'sed' or 'curl' gives a problem or doesn't exist.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
woody4165
Posts: 476
Joined: Monday 14 March 2016 13:55
Target OS: Linux
Domoticz version: beta
Location: Rome, Italy
Contact:

Re: dzVents 1.0 released

Post by woody4165 »

It seems that sed and curl are available commands.


linaro@cubietruck:~$ curl
curl: try 'curl --help' or 'curl --manual' for more information


linaro@cubietruck:~$ sed
Usage: sed [OPTION]... {script-only-if-no-other-script} [input-file]...

-n, --quiet, --silent
suppress automatic printing of pattern space
-e script, --expression=script
add the script to the commands to be executed
-f script-file, --file=script-file
add the contents of script-file to the commands to be executed
--follow-symlinks
follow symlinks when processing in place
-i[SUFFIX], --in-place[=SUFFIX]
edit files in place (makes backup if SUFFIX supplied)
-l N, --line-length=N
specify the desired line-wrap length for the `l' command
--posix
disable all GNU extensions.
-r, --regexp-extended
use extended regular expressions in the script.
-s, --separate
consider files as separate rather than as a single continuous
long stream.
-u, --unbuffered
load minimal amounts of data from the input files and flush
the output buffers more often -z, --null-data
separate lines by NUL characters
--help display this help and exit
--version output version information and exit

If no -e, --expression, -f, or --file option is given, then the first
non-option argument is taken as the sed script to interpret. All
remaining arguments are names of input files; if no input files are
specified, then the standard input is read.

GNU sed home page: <http://www.gnu.org/software/sed/>.
General help using GNU software: <http://www.gnu.org/gethelp/>.
linaro@cubietruck:~$

???????? [FLUSHED FACE]

May I try some curl or sed command manually to verify if they works?
Thanks
Cubietruck - Linux cubietruck 4.13.16 (Debian GNU/Linux 8 (jessie)) + Domoticz + RFLink, Xiaomi Gateway, Owl USB, Yeelight Color and B/W, ESP8266, Broadlink RM2, Netatmo Thermostat
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: dzVents 1.0 released

Post by dannybloe »

woody4165 wrote: May I try some curl or sed command manually to verify if they works?
Thanks
Weird. If you enable debug messages in the dzVents_settings, then the actual command will be printed in the log. You could try to the command on the command-line.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
woody4165
Posts: 476
Joined: Monday 14 March 2016 13:55
Target OS: Linux
Domoticz version: beta
Location: Rome, Italy
Contact:

Re: dzVents 1.0 released

Post by woody4165 »

Can it be this?

LUA: Found otherdevices_humidity adding this as a possible attribute

LUA: Found otherdevices_dewpoint adding this as a possible attribute

LUA: Found otherdevices_temperature adding this as a possible attribute

LUA: Found otherdevices_lastupdate adding this as a possible attribute

LUA: Found otherdevices_utility adding this as a possible attribute

LUA: Found otherdevices_uv adding this as a possible attribute

Error: EventSystem: in /home/linaro/domoticz/scripts/lua/script_device_main.lua: /home/linaro/domoticz/scripts/lua/dzVents/Domoticz.lua:350: bad argument #1 to 'pairs' (table expected, got nil)
Cubietruck - Linux cubietruck 4.13.16 (Debian GNU/Linux 8 (jessie)) + Domoticz + RFLink, Xiaomi Gateway, Owl USB, Yeelight Color and B/W, ESP8266, Broadlink RM2, Netatmo Thermostat
woody4165
Posts: 476
Joined: Monday 14 March 2016 13:55
Target OS: Linux
Domoticz version: beta
Location: Rome, Italy
Contact:

Re: dzVents 1.0 released

Post by woody4165 »

Anyone using dzVents with Armbian on Cubieboard?
I'm getting some issue and don't understand the reason...

Some more info in previous posts in this 3d.

Thanks
Cubietruck - Linux cubietruck 4.13.16 (Debian GNU/Linux 8 (jessie)) + Domoticz + RFLink, Xiaomi Gateway, Owl USB, Yeelight Color and B/W, ESP8266, Broadlink RM2, Netatmo Thermostat
woody4165
Posts: 476
Joined: Monday 14 March 2016 13:55
Target OS: Linux
Domoticz version: beta
Location: Rome, Italy
Contact:

Re: dzVents 1.0 released

Post by woody4165 »

Found the issue, but don't know the reason.
Looking to some dzVents lua files, I concentrate to the readHttpDomoticzData function in Domoticz.lua
One of the first line code is

Code: Select all

			ok, module = pcall(require, 'devices')

so I tried to look what was the devices and found it is a file named devices.lua in scripts/lua
Opening that file I found this

Code: Select all

return 
{
   ["ActTime"]= 1467203400,
   ["ServerTime"]= "2016-06-29 14:30:00",
   ["Sunrise"]= "05:40",
   ["Sunset"]= "20:47",
   ["status"]= "OK",
   ["title"]= "Devices"
}
it seemed strange the date, older than today, so I renamed the files and now all is ok.
The devices.lua has beed regenrated and contain a lot of other info.
Now all is going well, maybe I copied the dzVents structure from the RPi instead from the github and probably that file was dirty...
So now all is ok and I'm glad for this.. :D
Cubietruck - Linux cubietruck 4.13.16 (Debian GNU/Linux 8 (jessie)) + Domoticz + RFLink, Xiaomi Gateway, Owl USB, Yeelight Color and B/W, ESP8266, Broadlink RM2, Netatmo Thermostat
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: dzVents 1.0 released

Post by dannybloe »

Great! Hopefully we can get rid of this http-need to get additional device information.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
dhanjel
Posts: 102
Joined: Tuesday 05 August 2014 22:16
Target OS: Linux
Domoticz version: 3.5146
Location: Sweden
Contact:

Re: dzVents 1.0 released

Post by dhanjel »

Does anyone see what I do wrong?

Code: Select all

return  {
  active = true,
  on = { ['timer'] = 'every minute' },
  data = {
    readingHistory = { history = true, maxItems = 3 },
    notificationSent = { initial = false }
  },
  execute = function(domoticz)            
    
    local consumption = domoticz.devices['Kök, Diskmaskin Förbrukning'].WActual
  
    domoticz.data.readingHistory.add(consumption)
    local average = domoticz.data.readingHistory.avg()
    
    if (average == 3.3 and not domoticz.data.notificationSent)
    then
      domoticz.data.notificationSent = true
      domoticz.notify('Diskmaskinen klar!', 
                      'Diskmaskinen har precis kört klart aktuellt program.', 
                       domoticz.PRIORITY_LOW)
      domoticz.log("Dishwasher done", domoticz.LOG_INFO)
    elseif (average > 100)
    then
      domoticz.data.notificationSent = false
    end
    
  end
}
2016-07-06 13:21:00.199 LUA: Item data is not a number type. Type is nil
2016-07-06 13:21:00.199 LUA: An error occured when calling event handler notification_dishwasher
2016-07-06 13:21:00.199 LUA: ...aniel/domoticz/scripts/lua/dzVents/HistoricalStorage.lua:288: attempt to perform arithmetic on local 'sum' (a nil value)
I don´t have any sums (at least that I see)
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: dzVents 1.0 released

Post by dannybloe »

dhanjel wrote:Does anyone see what I do wrong?

Code: Select all

return  {
  active = true,
  on = { ['timer'] = 'every minute' },
  data = {
    readingHistory = { history = true, maxItems = 3 },
    notificationSent = { initial = false }
  },
  execute = function(domoticz)            
    
    local consumption = domoticz.devices['Kök, Diskmaskin Förbrukning'].WActual
  
    domoticz.data.readingHistory.add(consumption)
    local average = domoticz.data.readingHistory.avg()
    
    if (average == 3.3 and not domoticz.data.notificationSent)
    then
      domoticz.data.notificationSent = true
      domoticz.notify('Diskmaskinen klar!', 
                      'Diskmaskinen har precis kört klart aktuellt program.', 
                       domoticz.PRIORITY_LOW)
      domoticz.log("Dishwasher done", domoticz.LOG_INFO)
    elseif (average > 100)
    then
      domoticz.data.notificationSent = false
    end
    
  end
}
2016-07-06 13:21:00.199 LUA: Item data is not a number type. Type is nil
2016-07-06 13:21:00.199 LUA: An error occured when calling event handler notification_dishwasher
2016-07-06 13:21:00.199 LUA: ...aniel/domoticz/scripts/lua/dzVents/HistoricalStorage.lua:288: attempt to perform arithmetic on local 'sum' (a nil value)
I don´t have any sums (at least that I see)
No, sum is an internal. Looks like at some point a nil value has been put in the historical storage. You can check this (and perhaps fix) if you open the data file for this script (it is in scripts/storag/__data_<scriptname>.lua). In there you can inspect what is inside te data variables.

I guess I have to build in some checks for this situation. In the meantime you can remove these nil values or remove the __data file. Best is at least to check before doing the .add().
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
dhanjel
Posts: 102
Joined: Tuesday 05 August 2014 22:16
Target OS: Linux
Domoticz version: 3.5146
Location: Sweden
Contact:

Re: dzVents 1.0 released

Post by dhanjel »

No storage file exists, could it be that I just renamed my script-file?
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: dzVents 1.0 released

Post by dannybloe »

dhanjel wrote:No storage file exists, could it be that I just renamed my script-file?
Mm, that should not matter. At the start of the script it checks if the data file exist and either creates it or loads it with the previous state.

However, looking at your code, after you do the add() and you add a nil value, then the avg() will do a sum() over all the values (in this case the nil) and will fail. So it seems that WActual is nil even before it creates the data files. Can you check that?
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
dhanjel
Posts: 102
Joined: Tuesday 05 August 2014 22:16
Target OS: Linux
Domoticz version: 3.5146
Location: Sweden
Contact:

Re: dzVents 1.0 released

Post by dhanjel »

yes, it seems WActual is nil. and it seems that it does not have that property at all from Domoticz.

Code: Select all

 {
         "AddjMulti" : 1.0,
         "AddjMulti2" : 1.0,
         "AddjValue" : 0.0,
         "AddjValue2" : 0.0,
         "BatteryLevel" : 255,
         "CustomImage" : 0,
         "Data" : "42.5 Watt",
         "Description" : "",
         "Favorite" : 0,
         "HardwareID" : 2,
         "HardwareName" : "Z-Wave",
         "HardwareType" : "OpenZWave USB",
         "HardwareTypeVal" : 21,
         "HaveTimeout" : false,
         "ID" : "0002404",
         "LastUpdate" : "2016-07-06 13:45:52",
         "Name" : "Kök, Diskmaskin Förbrukning",
         "Notifications" : "false",
         "PlanID" : "0",
         "PlanIDs" : [ 0 ],
         "Protected" : false,
         "ShowNotifications" : true,
         "SignalLevel" : "-",
         "SubType" : "Electric",
         "Timers" : "false",
         "Type" : "Usage",
         "TypeImg" : "current",
         "Unit" : 2,
         "Used" : 1,
         "XOffset" : "0",
         "YOffset" : "0",
         "idx" : "140"
      }
maybe I need to parse it from Data.
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: dzVents 1.0 released

Post by dannybloe »

Aha, ok. If you dump the device (domoticz.logDevice(domoticz.devices['Kök, Diskmaskin Förbrukning'])) you can inspect whatever is in there. it could be that the utils or the rawData attribute holds the current usage.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
dhanjel
Posts: 102
Joined: Tuesday 05 August 2014 22:16
Target OS: Linux
Domoticz version: 3.5146
Location: Sweden
Contact:

Re: dzVents 1.0 released

Post by dhanjel »

dannybloe wrote:Aha, ok. If you dump the device (domoticz.logDevice(domoticz.devices['Kök, Diskmaskin Förbrukning'])) you can inspect whatever is in there. it could be that the utils or the rawData attribute holds the current usage.
this?

Code: Select all

2016-07-06 13:54:00.545 LUA: > all off:
2016-07-06 13:54:00.545 LUA: > inv: All On
2016-07-06 13:54:00.545 LUA: > b: false
2016-07-06 13:54:00.545 LUA: > all on:
2016-07-06 13:54:00.545 LUA: > inv: All Off
2016-07-06 13:54:00.545 LUA: > b: true
2016-07-06 13:54:00.545 LUA: > paused:
2016-07-06 13:54:00.545 LUA: > inv: Play
2016-07-06 13:54:00.545 LUA: > b: false
2016-07-06 13:54:00.545 LUA: > open:
2016-07-06 13:54:00.545 LUA: > inv: Closed
2016-07-06 13:54:00.545 LUA: > b: true
2016-07-06 13:54:00.545 LUA: > off:
2016-07-06 13:54:00.545 LUA: > inv: On
2016-07-06 13:54:00.545 LUA: > b: false
2016-07-06 13:54:00.545 LUA: > closed:
2016-07-06 13:54:00.545 LUA: > inv: Open
2016-07-06 13:54:00.545 LUA: > b: false
2016-07-06 13:54:00.546 LUA: > photo:
2016-07-06 13:54:00.546 LUA: > b: true
2016-07-06 13:54:00.546 LUA: > motion:
2016-07-06 13:54:00.546 LUA: > b: true
2016-07-06 13:54:00.546 LUA: > normal:
2016-07-06 13:54:00.546 LUA: > inv: Alarm
2016-07-06 13:54:00.546 LUA: > b: true
2016-07-06 13:54:00.546 LUA: > chime:
2016-07-06 13:54:00.546 LUA: > b: true
2016-07-06 13:54:00.546 LUA: > panic end:
2016-07-06 13:54:00.546 LUA: > b: false
2016-07-06 13:54:00.546 LUA: > stopped:
2016-07-06 13:54:00.546 LUA: > b: false
2016-07-06 13:54:00.546 LUA: > stop:
2016-07-06 13:54:00.546 LUA: > inv: Open
2016-07-06 13:54:00.546 LUA: > b: false
2016-07-06 13:54:00.546 LUA: > no motion:
2016-07-06 13:54:00.546 LUA: > inv: Off
2016-07-06 13:54:00.546 LUA: > b: false
2016-07-06 13:54:00.546 LUA: > group off:
2016-07-06 13:54:00.546 LUA: > b: false
2016-07-06 13:54:00.546 LUA: > panic:
2016-07-06 13:54:00.546 LUA: > inv: Off
2016-07-06 13:54:00.546 LUA: > b: true
2016-07-06 13:54:00.546 LUA: > playing:
2016-07-06 13:54:00.546 LUA: > inv: Pause
2016-07-06 13:54:00.546 LUA: > b: true
2016-07-06 13:54:00.546 LUA: > audio:
2016-07-06 13:54:00.546 LUA: > b: true
2016-07-06 13:54:00.546 LUA: > alarm:
2016-07-06 13:54:00.546 LUA: > inv: Normal
2016-07-06 13:54:00.546 LUA: > b: true
2016-07-06 13:54:00.546 LUA: > video:
2016-07-06 13:54:00.546 LUA: > b: true
2016-07-06 13:54:00.546 LUA: > group on:
2016-07-06 13:54:00.546 LUA: > b: true
2016-07-06 13:54:00.546 LUA: > signalLevel: -
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: dzVents 1.0 released

Post by dannybloe »

First of all: switch to version 1.1.1
Second... Domoticz tends to swallow log messages if there are too many. 1.1.1 has less to dump so you likely see all the device attributes.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
dhanjel
Posts: 102
Joined: Tuesday 05 August 2014 22:16
Target OS: Linux
Domoticz version: 3.5146
Location: Sweden
Contact:

Re: dzVents 1.0 released

Post by dhanjel »

Code: Select all

2016-07-06 14:23:00.219 LUA: Device: Kök, Diskmaskin Förbrukning
2016-07-06 14:23:00.219 LUA: ----------------------------
2016-07-06 14:23:00.219 LUA: > deviceSubType: Electric
2016-07-06 14:23:00.219 LUA: > batteryLevel: 255
2016-07-06 14:23:00.219 LUA: > rawData:
2016-07-06 14:23:00.219 LUA: > 1: 45.7
2016-07-06 14:23:00.219 LUA: > hardwareName: Z-Wave
2016-07-06 14:23:00.219 LUA: > hardwareId: 2
2016-07-06 14:23:00.219 LUA: > WActual: 45.7
2016-07-06 14:23:00.219 LUA: > bState: false
2016-07-06 14:23:00.219 LUA: > hardwareTypeValue: 21
2016-07-06 14:23:00.219 LUA: > id: 140
2016-07-06 14:23:00.219 LUA: > state: 45.7
2016-07-06 14:23:00.219 LUA: > changed: false
2016-07-06 14:23:00.219 LUA: > lastUpdate:
2016-07-06 14:23:00.219 LUA: > rawTime: 14:21:4
2016-07-06 14:23:00.219 LUA: > sec: 4
2016-07-06 14:23:00.219 LUA: > wday: 4
2016-07-06 14:23:00.219 LUA: > yday: 188
2016-07-06 14:23:00.219 LUA: > hour: 14
2016-07-06 14:23:00.219 LUA: > isToday: true
2016-07-06 14:23:00.219 LUA: > raw: 2016-07-06 14:21:04
2016-07-06 14:23:00.219 LUA: > month: 7
2016-07-06 14:23:00.219 LUA: > year: 2016
2016-07-06 14:23:00.219 LUA: > day: 6
2016-07-06 14:23:00.219 LUA: > isdst: true
2016-07-06 14:23:00.219 LUA: > minutesAgo: 1
2016-07-06 14:23:00.219 LUA: > secondsAgo: 116
2016-07-06 14:23:00.219 LUA: > rawDate: 2016-7-6
2016-07-06 14:23:00.219 LUA: > current:
2016-07-06 14:23:00.219 LUA: > month: 7
2016-07-06 14:23:00.219 LUA: > min: 23
2016-07-06 14:23:00.219 LUA: > sec: 0
2016-07-06 14:23:00.219 LUA: > wday: 4
2016-07-06 14:23:00.219 LUA: > isdst: true
2016-07-06 14:23:00.219 LUA: > yday: 188
2016-07-06 14:23:00.219 LUA: > hour: 14
2016-07-06 14:23:00.219 LUA: > year: 2016
2016-07-06 14:23:00.219 LUA: > day: 6
2016-07-06 14:23:00.219 LUA: > hoursAgo: 0
2016-07-06 14:23:00.219 LUA: > min: 21
2016-07-06 14:23:00.219 LUA: > hardwareTypeVal: 21
2016-07-06 14:23:00.219 LUA: > description:
2016-07-06 14:23:00.219 LUA: > signalLevel: -
2016-07-06 14:23:00.219 LUA: > counterTotal:
2016-07-06 14:23:00.219 LUA: > counterToday:
2016-07-06 14:23:00.219 LUA: > timedOut: false
2016-07-06 14:23:00.219 LUA: > hardwareType: OpenZWave USB
2016-07-06 14:23:00.219 LUA: > deviceType: Usage
2016-07-06 14:23:00.219 LUA: > utility: 45.700000762939
2016-07-06 14:23:00.219 LUA: > name: Kök, Diskmaskin Förbrukning
2016-07-06 14:23:00.219 LUA: > _sValues: 45.7
now WActual does seem to contain a value, so updating dzVents seems to have helped (thought I already was on 1.1.1 :))
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests