Page 17 of 17

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Saturday 10 December 2016 14:31
by gus
Doler wrote:
gus wrote:Hi!

Trying to switch on groups with dzvents but don't get it to work...

Shouldn't this work:
domoticz.groups['Innelampor Basement'].switchOn()


Please advice


/Rickard
You should use

Code: Select all

 domoticz.switchGroup('Innelampor Basement', 'On') 
(see Domoticz methods)

Well, I tried that as well

domoticz.switchGroup('Innelampor Basement', 'On')

but no changes...

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Saturday 10 December 2016 14:36
by Doler
gus wrote:
Doler wrote:
gus wrote:Hi!

Trying to switch on groups with dzvents but don't get it to work...

Shouldn't this work:
domoticz.groups['Innelampor Basement'].switchOn()


Please advice


/Rickard
You should use

Code: Select all

 domoticz.switchGroup('Innelampor Basement', 'On') 
(see Domoticz methods)

Well, I tried that as well

domoticz.switchGroup('Innelampor Basement', 'On')

but no changes...
It works for me. Do you have 'Enable http fetch' set to True in Settings? If so, did you create the group just shortly so the HTTP fetch didn't have time to run (dependent on your interval setting)?

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Saturday 10 December 2016 14:44
by gus
Doler wrote:
gus wrote:
Doler wrote: You should use

Code: Select all

 domoticz.switchGroup('Innelampor Basement', 'On') 
(see Domoticz methods)

Well, I tried that as well

domoticz.switchGroup('Innelampor Basement', 'On')

but no changes...
It works for me. Do you have 'Enable http fetch' set to True in Settings? If so, did you create the group just shortly so the HTTP fetch didn't have time to run (dependent on your interval setting)?

Guess, now it works! Dunno what I did?

Thanks for your help!

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Saturday 10 December 2016 14:47
by Doler
gus wrote:
Doler wrote:
gus wrote:

Well, I tried that as well

domoticz.switchGroup('Innelampor Basement', 'On')

but no changes...
It works for me. Do you have 'Enable http fetch' set to True in Settings? If so, did you create the group just shortly so the HTTP fetch didn't have time to run (dependent on your interval setting)?

Guess, now it works! Dunno what I did?

Thanks for your help!
Guess time did it (HTTP fetch), glad it works now.
Cheers, Mark

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Sunday 18 December 2016 13:45
by Clemen
Anyway to control/handle a media player device? The device is a Denon Heos speaker, added to domoticz with switch type "Media Player"

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Monday 02 January 2017 14:57
by Yustmenl
i have implemented DzVents but when i try to write to the log i get the folowing error

Script:

Code: Select all

   return {
        active = true,
        on = {['timer'] = 'every minute'},
        execute = function(domoticz)
			domoticz.log('test','domoticz.LOG_INFO')
        end
    }
error in log:

Code: Select all

2017-01-02 14:56:00.277 LUA: =====================================================
2017-01-02 14:56:00.277 LUA: >>> Handler: test
2017-01-02 14:56:00.277 LUA: .....................................................
2017-01-02 14:56:00.277 LUA: An error occured when calling event handler test
2017-01-02 14:56:00.277 LUA: /home/pi/domoticz/scripts/lua/dzVents/Utils.lua:107: attempt to compare string with number
2017-01-02 14:56:00.277 LUA: .....................................................
2017-01-02 14:56:00.277 LUA: <<< Done
2017-01-02 14:56:00.277 LUA: -----------------------------------------------------
any idea on what i am doing wrong?

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Monday 02 January 2017 15:30
by bloody2k
Try with following line :)

domoticz.log('test', domoticz.LOG_INFO)


Yustmenl wrote:i have implemented DzVents but when i try to write to the log i get the folowing error

Script:

Code: Select all

 return {
 active = true,
 on = {['timer'] = 'every minute'},
 execute = function(domoticz)
 domoticz.log('test','domoticz.LOG_INFO')
 end
 }
error in log:

Code: Select all

2017-01-02 14:56:00.277 LUA: =====================================================
2017-01-02 14:56:00.277 LUA: >>> Handler: test
2017-01-02 14:56:00.277 LUA: .....................................................
2017-01-02 14:56:00.277 LUA: An error occured when calling event handler test
2017-01-02 14:56:00.277 LUA: /home/pi/domoticz/scripts/lua/dzVents/Utils.lua:107: attempt to compare string with number
2017-01-02 14:56:00.277 LUA: .....................................................
2017-01-02 14:56:00.277 LUA: <<< Done
2017-01-02 14:56:00.277 LUA: -----------------------------------------------------
any idea on what i am doing wrong?

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Monday 02 January 2017 20:20
by Yustmenl
Thanks that works

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Tuesday 03 January 2017 10:03
by dannybloe
bloody2k wrote:Try with following line :)

domoticz.log('test', domoticz.LOG_INFO)
Indeed, domotiz.LOG_INFO represents a value and that value is what you pass to the log method.

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Friday 06 January 2017 17:42
by Kalekulan
How can you get the state of a group or scene?
And how should you add a group to this:

on = {
'Lights inside'
},

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Friday 06 January 2017 21:57
by dannybloe
Kalekulan wrote:How can you get the state of a group or scene?
And how should you add a group to this:

on = {
'Lights inside'
},
Well, I'd expect that the device that is passed to the execute method is the actual group or scene. So if it has a state you could get to it:

Code: Select all

	execute = function(domoticz, myGroup) 
		if (myGroup.state == 'On') then
			...
		end
	end
A group or a scene can be triggered in the 'on' section by their ids.

See the documentation for more information and let me know if there are still problems.

Cheers,

Danny

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Saturday 07 January 2017 19:30
by gus
Hi All,

I having a hard time to update a text device ( "SubType" : "Text")

Command that I use:

Code: Select all

domoticz.devices['Text 1'].updateText(test_text)
Error messages:

Code: Select all

attempt to index field 'Text 1' (a nil value)

The JSON command that is working:

Code: Select all

http://192.168.17.82:8080/json.htm?type=command&param=udevice&idx=143&nvalue=0&svalue=test_text

List of the complete device thru JSON:

Code: Select all


{
         "AddjMulti" : 1.0,
         "AddjMulti2" : 1.0,
         "AddjValue" : 0.0,
         "AddjValue2" : 0.0,
         "BatteryLevel" : 255,
         "CustomImage" : 0,
         "Data" : "test text",
         "Description" : "",
         "Favorite" : 0,
         "HardwareID" : 2,
         "HardwareName" : "Domoticz Internal",
         "HardwareType" : "MySensors Gateway USB",
         "HardwareTypeVal" : 41,
         "HaveTimeout" : false,
         "ID" : "00000A08",
         "LastUpdate" : "2017-01-05 22:15:38",
         "Name" : "Text 1",
         "Notifications" : "false",
         "PlanID" : "0",
         "PlanIDs" : [ 0 ],
         "Protected" : false,
         "ShowNotifications" : false,
         "SignalLevel" : "-",
         "SubType" : "Text",
         "Timers" : "false",
         "Type" : "General",
         "TypeImg" : "text",
         "Unit" : 1,
         "Used" : 0,
         "XOffset" : "0",
         "YOffset" : "0",
         "idx" : "143"
      },


Where do I think wrong??


/Rikard

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Saturday 07 January 2017 19:35
by dannybloe
gus wrote:Hi All,

I having a hard time to update a text device ( "SubType" : "Text")

Command that I use:

Code: Select all

domoticz.devices['Text 1'].updateText(test_text)
Error messages:

Code: Select all

attempt to index field 'Text 1' (a nil value)

The JSON command that is working:

Code: Select all

http://192.168.17.82:8080/json.htm?type=command&param=udevice&idx=143&nvalue=0&svalue=test_text

List of the complete device thru JSON:

Code: Select all


{
         "AddjMulti" : 1.0,
         "AddjMulti2" : 1.0,
         "AddjValue" : 0.0,
         "AddjValue2" : 0.0,
         "BatteryLevel" : 255,
         "CustomImage" : 0,
         "Data" : "test text",
         "Description" : "",
         "Favorite" : 0,
         "HardwareID" : 2,
         "HardwareName" : "Domoticz Internal",
         "HardwareType" : "MySensors Gateway USB",
         "HardwareTypeVal" : 41,
         "HaveTimeout" : false,
         "ID" : "00000A08",
         "LastUpdate" : "2017-01-05 22:15:38",
         "Name" : "Text 1",
         "Notifications" : "false",
         "PlanID" : "0",
         "PlanIDs" : [ 0 ],
         "Protected" : false,
         "ShowNotifications" : false,
         "SignalLevel" : "-",
         "SubType" : "Text",
         "Timers" : "false",
         "Type" : "General",
         "TypeImg" : "text",
         "Unit" : 1,
         "Used" : 0,
         "XOffset" : "0",
         "YOffset" : "0",
         "idx" : "143"
      },


Where do I think wrong??


/Rikard
Interesting... can you try it by it's id? domoticz.devices[143].

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Saturday 07 January 2017 20:07
by gus
dannybloe wrote:
gus wrote:Hi All,

I having a hard time to update a text device ( "SubType" : "Text")

Command that I use:

Code: Select all

domoticz.devices['Text 1'].updateText(test_text)
Error messages:

Code: Select all

attempt to index field 'Text 1' (a nil value)

The JSON command that is working:

Code: Select all

http://192.168.17.82:8080/json.htm?type=command&param=udevice&idx=143&nvalue=0&svalue=test_text

List of the complete device thru JSON:

Code: Select all


{
         "AddjMulti" : 1.0,
         "AddjMulti2" : 1.0,
         "AddjValue" : 0.0,
         "AddjValue2" : 0.0,
         "BatteryLevel" : 255,
         "CustomImage" : 0,
         "Data" : "test text",
         "Description" : "",
         "Favorite" : 0,
         "HardwareID" : 2,
         "HardwareName" : "Domoticz Internal",
         "HardwareType" : "MySensors Gateway USB",
         "HardwareTypeVal" : 41,
         "HaveTimeout" : false,
         "ID" : "00000A08",
         "LastUpdate" : "2017-01-05 22:15:38",
         "Name" : "Text 1",
         "Notifications" : "false",
         "PlanID" : "0",
         "PlanIDs" : [ 0 ],
         "Protected" : false,
         "ShowNotifications" : false,
         "SignalLevel" : "-",
         "SubType" : "Text",
         "Timers" : "false",
         "Type" : "General",
         "TypeImg" : "text",
         "Unit" : 1,
         "Used" : 0,
         "XOffset" : "0",
         "YOffset" : "0",
         "idx" : "143"
      },


Where do I think wrong??


/Rikard
Interesting... can you try it by it's id? domoticz.devices[143].


Ok, tried that, still error but now with a "?"...

Code: Select all

 attempt to index field '?' (a nil value)

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Saturday 07 January 2017 22:29
by gus
gus wrote:
dannybloe wrote:
gus wrote:Hi All,

I having a hard time to update a text device ( "SubType" : "Text")

Command that I use:

Code: Select all

domoticz.devices['Text 1'].updateText(test_text)
Error messages:

Code: Select all

attempt to index field 'Text 1' (a nil value)

The JSON command that is working:

Code: Select all

http://192.168.17.82:8080/json.htm?type=command&param=udevice&idx=143&nvalue=0&svalue=test_text

List of the complete device thru JSON:

Code: Select all


{
         "AddjMulti" : 1.0,
         "AddjMulti2" : 1.0,
         "AddjValue" : 0.0,
         "AddjValue2" : 0.0,
         "BatteryLevel" : 255,
         "CustomImage" : 0,
         "Data" : "test text",
         "Description" : "",
         "Favorite" : 0,
         "HardwareID" : 2,
         "HardwareName" : "Domoticz Internal",
         "HardwareType" : "MySensors Gateway USB",
         "HardwareTypeVal" : 41,
         "HaveTimeout" : false,
         "ID" : "00000A08",
         "LastUpdate" : "2017-01-05 22:15:38",
         "Name" : "Text 1",
         "Notifications" : "false",
         "PlanID" : "0",
         "PlanIDs" : [ 0 ],
         "Protected" : false,
         "ShowNotifications" : false,
         "SignalLevel" : "-",
         "SubType" : "Text",
         "Timers" : "false",
         "Type" : "General",
         "TypeImg" : "text",
         "Unit" : 1,
         "Used" : 0,
         "XOffset" : "0",
         "YOffset" : "0",
         "idx" : "143"
      },


Where do I think wrong??


/Rikard
Interesting... can you try it by it's id? domoticz.devices[143].[/qdauote]



Ok, tried that, still error but now with a "?"...

Code: Select all

 attempt to index field '?' (a nil value)
Found the problem!
I couldn't find 'Text 1' device in devices.lua, so apparently you needed to add the device in "Device" menu for getting devices.lua to be update.

So now it works!

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Sunday 08 January 2017 14:30
by NietGiftig
I have a MiLight remote witch I want to use to regulate some own build light stripes with ESP8266 comm.
(Nice cheap remote with touch-control)
The remote connects with Domoticz via rfLink via USB.
Now I want to intercept the commands from the RFLink MiLight hardware/device
RFLink sends to Domoticz for example:

Code: Select all

20;29;MiLightv1;ID=DB48;SWITCH=04;RGBW=5390;CMD=COLOR;
I have checked this with RFLink readout in serial console
I can use RGBW=5390 to translate to #hexcolor. (53 = color 90=Brightness)
I use Fastled witch has a conversion function. ;-)
I created a Milight device in the RFlink hardware witch reacts to the remote.
in devices.lua I have the following info:

Code: Select all

       {
         ["AddjMulti"]= 1.0,
         ["AddjMulti2"]= 1.0,
         ["AddjValue"]= 0.0,
         ["AddjValue2"]= 0.0,
         ["BatteryLevel"]= 255,
         ["CustomImage"]= 0,
         ["Data"]= "Off",
         ["Description"]= "",
         ["Favorite"]= 0,
         ["HardwareID"]= 1,
         ["HardwareName"]= "RFLink",
         ["HardwareType"]= "RFLink Gateway USB",
         ["HardwareTypeVal"]= 46,
         ["HaveDimmer"]= true,
         ["HaveGroupCmd"]= false,
         ["HaveTimeout"]= false,
         ["ID"]= "0000DB48",
         ["Image"]= "Light",
         ["IsSubDevice"]= false,
         ["LastUpdate"]= "2017-01-08 11:57:02",
         ["Level"]= 47,
         ["LevelInt"]= 47,
         ["MaxDimLevel"]= 100,
         ["Name"]= "Mi-Light-m",
         ["Notifications"]= "false",
         ["PlanID"]= "0",
         ["PlanIDs"]= { 0 },
         ["Protected"]= false,
         ["ShowNotifications"]= true,
         ["SignalLevel"]= "-",
         ["Status"]= "Off",
         ["StrParam1"]= "",
         ["StrParam2"]= "",
         ["SubType"]= "RGBW",
         ["SwitchType"]= "Dimmer",
         ["SwitchTypeVal"]= 7,
         ["Timers"]= "false",
         ["Type"]= "Lighting Limitless/Applamp",
         ["TypeImg"]= "dimmer",
         ["Unit"]= 0,
         ["Used"]= 1,
         ["UsedByCamera"]= false,
         ["XOffset"]= "0",
         ["YOffset"]= "0",
         ["idx"]= "149"
      },
I have tried the most obvious attributes but i get no data at all
I use this script for trying, it only prints 'test

Code: Select all

   local idxn = 149
return {
	active = true,           -- set to true to activate this script
	on = {
		idxn,                 -- Mi-light remote
	},
	
	execute = function(domoticz) 
	  print('test')
	  print(domoticz.devices[idxn].Name)		
	  print(domoticz.devices[idxn].LevelInt)
	  print(domoticz.devices[idxn].rawData[0])		
	  print(domoticz.devices[idxn].rawData[1])	  
	end
}   
I'm not sure if this is the way to go.
Someone who can enlighten me?

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Monday 09 January 2017 7:44
by dannybloe
NietGiftig wrote:I have a MiLight remote witch I want to use to regulate some own build light stripes with ESP8266 comm.
(Nice cheap remote with touch-control)
The remote connects with Domoticz via rfLink via USB.
Now I want to intercept the commands from the RFLink MiLight hardware/device
RFLink sends to Domoticz for example:

Code: Select all

20;29;MiLightv1;ID=DB48;SWITCH=04;RGBW=5390;CMD=COLOR;
I have checked this with RFLink readout in serial console
I can use RGBW=5390 to translate to #hexcolor. (53 = color 90=Brightness)
I use Fastled witch has a conversion function. ;-)
I created a Milight device in the RFlink hardware witch reacts to the remote.
in devices.lua I have the following info:

Code: Select all

       {
         ["AddjMulti"]= 1.0,
         ["AddjMulti2"]= 1.0,
         ["AddjValue"]= 0.0,
         ["AddjValue2"]= 0.0,
         ["BatteryLevel"]= 255,
         ["CustomImage"]= 0,
         ["Data"]= "Off",
         ["Description"]= "",
         ["Favorite"]= 0,
         ["HardwareID"]= 1,
         ["HardwareName"]= "RFLink",
         ["HardwareType"]= "RFLink Gateway USB",
         ["HardwareTypeVal"]= 46,
         ["HaveDimmer"]= true,
         ["HaveGroupCmd"]= false,
         ["HaveTimeout"]= false,
         ["ID"]= "0000DB48",
         ["Image"]= "Light",
         ["IsSubDevice"]= false,
         ["LastUpdate"]= "2017-01-08 11:57:02",
         ["Level"]= 47,
         ["LevelInt"]= 47,
         ["MaxDimLevel"]= 100,
         ["Name"]= "Mi-Light-m",
         ["Notifications"]= "false",
         ["PlanID"]= "0",
         ["PlanIDs"]= { 0 },
         ["Protected"]= false,
         ["ShowNotifications"]= true,
         ["SignalLevel"]= "-",
         ["Status"]= "Off",
         ["StrParam1"]= "",
         ["StrParam2"]= "",
         ["SubType"]= "RGBW",
         ["SwitchType"]= "Dimmer",
         ["SwitchTypeVal"]= 7,
         ["Timers"]= "false",
         ["Type"]= "Lighting Limitless/Applamp",
         ["TypeImg"]= "dimmer",
         ["Unit"]= 0,
         ["Used"]= 1,
         ["UsedByCamera"]= false,
         ["XOffset"]= "0",
         ["YOffset"]= "0",
         ["idx"]= "149"
      },
I have tried the most obvious attributes but i get no data at all
I use this script for trying, it only prints 'test

Code: Select all

   local idxn = 149
return {
	active = true,           -- set to true to activate this script
	on = {
		idxn,                 -- Mi-light remote
	},
	
	execute = function(domoticz) 
	  print('test')
	  print(domoticz.devices[idxn].Name)		
	  print(domoticz.devices[idxn].LevelInt)
	  print(domoticz.devices[idxn].rawData[0])		
	  print(domoticz.devices[idxn].rawData[1])	  
	end
}   
I'm not sure if this is the way to go.
Someone who can enlighten me?
First of all, it is device[].name (lower-case). Second, dzVents does a mapping to sane naming when it processes the devices.lua file. It is not the case that all attributes in that file end up in the device object api (at least not one-on-one). So, that said, you can try to do domoticz.logDevice(domoticz.devices[idxn]). It should log all the device values to the domoticz log. (Note that domoticz sometimes swallows log messages so you may have to run it several times to see all the attributes in the log).

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Monday 09 January 2017 7:47
by dannybloe
Hi folks, I am closing this topic because it is almost becoming it's own internal forum. Please use the forum Software > dzVents Lua Framework for new topics. That makes it more manageable.

Thanks for using dzVents and happy new year. Let's hope some day gizmocus or someone else with c++ skills finally finds the time to help integrate it into Domoticz.