dzVents 1.0 released

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

Moderator: leecollings

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 »

ah yes, must be this one, right?

Code: Select all

2016-06-16 13:45:09.426 LUA: =====================================================
2016-06-16 13:45:09.426 LUA: >>> Handler: virtualdevice_wiiu
2016-06-16 13:45:09.426 LUA: .....................................................
2016-06-16 13:45:10.374 Error: EventSystem: Warning!, lua script /home/daniel/domoticz/scripts/lua/script_time_main.lua has been running for more than 10 seconds
2016-06-16 13:45:12.434 LUA: .....................................................
2016-06-16 13:45:12.434 LUA: <<< Done
2016-06-16 13:45:12.434 LUA: -----------------------------------------------------
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 »

Well, that script takes 3 seconds. So there must be more. Btw, 3 seconds is enormous, time-wise. What are you doing in that script?
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 »

did a ping to check if a device was online, but did not have a timeout. added a 1s timeout and it seems to work.
is the 10 s limit for all scripts in total, or one separate script?
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 »

Well, there is a hardware plugin for this. Use that to set the state of a switch and link a script to that switch.
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 »

Really, which one? You learn something new every day :)
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 »

System Alive Checker. It creates switches for devices that you want to ping. What I would do is create a dzVents script using a persistent variable that counts consecutive ping timeouts and only when there have been a couple in a row perform some action.

System Alive Checker > $hiddenMyDevice > dzVents script > counter > myDevice.switchOn/Off

Something like that. Thing is that sometimes you get an occasional time-out while the device is still online. By counting consecutive timeouts you can prevent false negatives.
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:System Alive Checker. It creates switches for devices that you want to ping. What I would do is create a dzVents script using a persistent variable that counts consecutive ping timeouts and only when there have been a couple in a row perform some action.

System Alive Checker > $hiddenMyDevice > dzVents script > counter > myDevice.switchOn/Off

Something like that. Thing is that sometimes you get an occasional time-out while the device is still online. By counting consecutive timeouts you can prevent false negatives.
the ping device does not seem to end up in devices.lua (I deleted the file and checked in the recreated file, and it is not there)

Code: Select all

{
         "AddjMulti" : 1.0,
         "AddjMulti2" : 1.0,
         "AddjValue" : 0.0,
         "AddjValue2" : 0.0,
         "BatteryLevel" : 255,
         "CustomImage" : 0,
         "Data" : "On",
         "Description" : "",
         "Favorite" : 0,
         "HardwareID" : 6,
         "HardwareName" : "System Alive Checker",
         "HardwareType" : "System Alive Checker (Ping)",
         "HardwareTypeVal" : 51,
         "HaveDimmer" : true,
         "HaveGroupCmd" : true,
         "HaveTimeout" : false,
         "ID" : "0000003",
         "Image" : "Light",
         "IsSubDevice" : false,
         "LastUpdate" : "2016-06-16 15:21:37",
         "Level" : 0,
         "LevelInt" : 0,
         "MaxDimLevel" : 15,
         "Name" : "Vardagsrum, Sony TV Ping",
         "Notifications" : "false",
         "PlanID" : "0",
         "PlanIDs" : [ 0 ],
         "Protected" : false,
         "ShowNotifications" : true,
         "SignalLevel" : "-",
         "Status" : "On",
         "StrParam1" : "",
         "StrParam2" : "",
         "SubType" : "AC",
         "SwitchType" : "On/Off",
         "SwitchTypeVal" : 0,
         "Timers" : "false",
         "Type" : "Lighting 2",
         "TypeImg" : "lightbulb",
         "Unit" : 1,
         "Used" : 0,
         "UsedByCamera" : false,
         "XOffset" : "0",
         "YOffset" : "0",
         "idx" : "214"
      }
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 »

Are you sure? That file is the direct result of getting the device information from Domoticz. If you do a manual fetch you see the same data.
What do you see when you do: http://..../json.htm?type=devices&displayhidden=1&filter=all&used=true

But, what do you get when you do domoticz.devices['Vardagsrum, Sony TV Ping'] or [214]. Isn't that enough to be useful?
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
User avatar
blackdog65
Posts: 311
Joined: Tuesday 17 June 2014 18:25
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Norfolk, UK
Contact:

Re: dzVents 1.0 released

Post by blackdog65 »

Hi guys,
I'm new to dzVents and finding it easier than trying to learn "lua full fat" :D

I have a question Ref. sounds for example domoticz.SOUND_SIREN seems like a simple enough request/command but what siren? Where is it? :?

I have 4 Siemens mp3 doorbells in my house each with 10 sounds that can be triggered by Domoticz (including siren) these chimes work as a switch... pretty straight forward, but what are the dzVents sounds all about?

Many thanks
Sean

PS calling all 4 of my sirens with "Siren*" is so much easier than calling all 4 separately :D
CubieTruck Master
RasPi slaves
Aeon Labs Z-Stick, multi sensor
Fibaro Dimmers, relays, Universal sensors
EQ3 MAX!
TKB Sockets
RFXCOM
LightwaveRF sockets, switches, relays, doorbell
MySensors
ESPEasy ESP8266-12E
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 »

Good question, I really have no idea ;-)
These are notify() options. Someone added them.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
User avatar
blackdog65
Posts: 311
Joined: Tuesday 17 June 2014 18:25
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Norfolk, UK
Contact:

Re: dzVents 1.0 released

Post by blackdog65 »

:lol: I like your honesty :lol:

I'll dig a little deeper into the code as it may be possible to modify either the code or my sounders to meet in the middle :D

Thanks for the quick reply Danny

Sean
CubieTruck Master
RasPi slaves
Aeon Labs Z-Stick, multi sensor
Fibaro Dimmers, relays, Universal sensors
EQ3 MAX!
TKB Sockets
RFXCOM
LightwaveRF sockets, switches, relays, doorbell
MySensors
ESPEasy ESP8266-12E
jmleglise
Posts: 192
Joined: Monday 12 January 2015 23:27
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: FRANCE
Contact:

Re: dzVents 1.0 released

Post by jmleglise »

Hi,

I wonder if Dzvents can manage the execution of a lua script 30 seconds after an execution of a first script ? Here is my need :

Code: Select all

First script triggered by a PIR
- check some uservariables and conditions
- VocalSynthesis "Domoticz will sound the Alarm in 30 seconds. You have 30 seconds to disarm it."

2nd script: 30 seconds after
- check some uservariables and conditions 
- trigger some switchs
Regards ,
My script : https://github.com/jmleglise
RFXTRX433E: Blind Somfy RTS, Portal Somfy Evolvia, chacon IO, Oregon, PIR sensor PT2262
My Last project : Location de vacances a Ouistreham vue mer
KMTronic USB relay
Chinese Z-WAVE: Neo CoolCam
NetEye
Posts: 34
Joined: Friday 17 June 2016 7:57
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Spijkenisse
Contact:

Re: dzVents 1.0 released

Post by NetEye »

Dear Danny,
I' am impressed, maybe you can help cq coache me with my topic? ( 8e onder die van jou: Lua script for pressure sensor).
Groet
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 »

jmleglise wrote:Hi,

I wonder if Dzvents can manage the execution of a lua script 30 seconds after an execution of a first script ? Here is my need :

Code: Select all

First script triggered by a PIR
- check some uservariables and conditions
- VocalSynthesis "Domoticz will sound the Alarm in 30 seconds. You have 30 seconds to disarm it."

2nd script: 30 seconds after
- check some uservariables and conditions 
- trigger some switchs
Regards ,
Maybe something like this:

Code: Select all

return {
	active = true, -- set to true to activate this script
	on = {
		'pir',
		'disarmer', -- some switch that indicates the alarm is disarmed
		'alarmActivator' -- dummy switch
	},
	data = {
		triggerAlarm = { initial = false }
	},
	execute = function(domoticz, device)
		
		if (device.name == 'pir' and device.state == 'Motion') then

			domoticz.data.triggerAlarm = true
			domoticz.devices['alarmActivator'].switchOn().after_sec(30) -- will trigger this script after 30 seconds (hopefully)
			domoticz.sendCommand('') -- command for the vocal stuff

		elseif (device.name == 'disarmer') then

			domoticz.data.triggerAlarm = false
			domoticz.devices['alarmActivator'].switchOff()
			domoticz.devices['alarm'].switchOff()

		elseif (device.name == 'alarmActivor' and device.state == 'On' and domoticz.data.triggerAlarm) then

			domoticz.devices['alarm'].switchOn()
			domoticz.data.triggerAlarm = false
			-- do whatever 

		end
	end
}
I use the persistent variable triggerAlarm just to make sure that the after_sec() command isn't executed after all even if do you switchOff(). Maybe you don't need this extra check. I'm not sure. Of course the 'disarmer' switch represents whatever device reports that the alarm is turned off.

Update: fixed a typo in the script
Last edited by dannybloe on Monday 20 June 2016 8:50, edited 1 time in total.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
jmleglise
Posts: 192
Joined: Monday 12 January 2015 23:27
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: FRANCE
Contact:

Re: dzVents 1.0 released

Post by jmleglise »

But of course !!! The script activates a switch 30 sec After, and detects the change of it , all this in the same script !
It's brilliant !

Thank you danny,
My script : https://github.com/jmleglise
RFXTRX433E: Blind Somfy RTS, Portal Somfy Evolvia, chacon IO, Oregon, PIR sensor PT2262
My Last project : Location de vacances a Ouistreham vue mer
KMTronic USB relay
Chinese Z-WAVE: Neo CoolCam
Eduard
Posts: 139
Joined: Monday 19 January 2015 9:14
Target OS: -
Domoticz version:

Re: dzVents 1.0 released

Post by Eduard »

Atmosphere wrote:
dannybloe wrote:
Did you find anything yet?
Hi Danny, It's still happening...

Code: Select all

 2016-06-06 03:40:03.465 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_main.lua: /home/pi/domoticz/scripts/lua/dzVents/Domoticz.lua:445: attempt to index local 'device' (a nil value)
2016-06-06 05:25:02.595 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_main.lua: /home/pi/domoticz/scripts/lua/dzVents/Domoticz.lua:445: attempt to index local 'device' (a nil value)
2016-06-06 10:55:03.267 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_main.lua: /home/pi/domoticz/scripts/lua/dzVents/Domoticz.lua:445: attempt to index local 'device' (a nil value)
2016-06-06 14:35:03.204 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_main.lua: /home/pi/domoticz/scripts/lua/dzVents/Domoticz.lua:445: attempt to index local 'device' (a nil value)
2016-06-06 17:25:03.270 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_main.lua: /home/pi/domoticz/scripts/lua/dzVents/Domoticz.lua:445: attempt to index local 'device' (a nil value) 
I have the same issues:

Code: Select all

2016-06-12 08:30:01.682  LUA: devices.lua cannot be loaded
2016-06-12 08:30:01.682  LUA: error loading module 'devices' from file '/home/pi/domoticz/scripts/lua/devices.lua':
	/home/pi/domoticz/scripts/lua/devices.lua:5604: unfinished string near <eof>
2016-06-12 08:30:01.732  Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_main.lua: /home/pi/domoticz/scripts/lua/dzVents/Domoticz.lua:446: attempt to index local 'device' (a nil value)
Looks like at some point that the http-fetch was not successful and created an empty devices.lua. Parsing the devices into the array will give an error then.
Maybe add a check to see if the devices.lua is empty before trying to parse the data...
elmortero
Posts: 247
Joined: Sunday 29 November 2015 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.9639
Location: Spain
Contact:

Re: dzVents 1.0 released

Post by elmortero »

Hi Danny,

I am loving dzvents, all my switches have already been migrated to it.
Now I started to try and migrate some other scripts but I am a bit lost.
In this one case I want to get the humidity value from a (physical) sensor named soil1 and write it to a virtual sensor, called humsoil 1 with id 340.

Until now I read it from the sensor and wrote it to the virtual sensor by updating it using json.
Have been trying for some hours to try to get it in dzvents but without luck.

This is the original (in non-magical LUA):

Code: Select all

	bodem = 'soil1'
	domoticzserver = 'http://192.168.1.6:8080'

	smoistsensorTemp, smoistsensorHumidity = otherdevices_svalues[bodem]:match("([^;]+);([^;]+);([^;]+)")
	smoistsensorHumidity = tonumber(smoistsensorHumidity);
	print("xt300: Humidity soil1  is " .. smoistsensorHumidity .. " ");

    commandArray['OpenURL'] = domoticzserver .. '/json.htm?type=command&param=udevice&idx=340&nvalue=' .. smoistsensorHumidity
Can you help me get started please?
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 »

elmortero wrote:Hi Danny,

I am loving dzvents, all my switches have already been migrated to it.
Now I started to try and migrate some other scripts but I am a bit lost.
In this one case I want to get the humidity value from a (physical) sensor named soil1 and write it to a virtual sensor, called humsoil 1 with id 340.

Until now I read it from the sensor and wrote it to the virtual sensor by updating it using json.
Have been trying for some hours to try to get it in dzvents but without luck.

This is the original (in non-magical LUA):

Code: Select all

	bodem = 'soil1'
	domoticzserver = 'http://192.168.1.6:8080'

	smoistsensorTemp, smoistsensorHumidity = otherdevices_svalues[bodem]:match("([^;]+);([^;]+);([^;]+)")
	smoistsensorHumidity = tonumber(smoistsensorHumidity);
	print("xt300: Humidity soil1  is " .. smoistsensorHumidity .. " ");

    commandArray['OpenURL'] = domoticzserver .. '/json.htm?type=command&param=udevice&idx=340&nvalue=' .. smoistsensorHumidity
Can you help me get started please?
Have you tried this:

Code: Select all


	domoticz.devices[340].updateHumidity(smoistsensorHumidity, domoticz.HUM_NORMAL)

It should work.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
elmortero
Posts: 247
Joined: Sunday 29 November 2015 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.9639
Location: Spain
Contact:

Re: dzVents 1.0 released

Post by elmortero »

dannybloe wrote:

Code: Select all


	domoticz.devices[340].updateHumidity(smoistsensorHumidity, domoticz.HUM_NORMAL)

It should work.

It did! Works like a charm.
Thanks a lot.
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 »

Nice.
Read the docs ;)
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest