Page 2 of 7

Re: dzVents 1.0 released

Posted: Tuesday 31 May 2016 12:48
by dannybloe
dhanjel wrote:Looks really nice! Have to try it out tonight.

You can access historical data to? (Have not had time to read the entire documentation yet).

For monitoring when the dishwasher is done, I need to check if the power consumption has dropped to 3.3W and stayed there for at least 3 min.
Doable in an easy way?
Yep. That should be fairly easy. You can scan for (local)minimum/maximum historical consumption. Simply add the consumption to the historical variable and you are good to go and do all kinds of analysis. Let me know when you encounter probs or just how you did it. There are always many ways to approach this.

You can even do data-smoothing to filter out peaks(noise). Just read the section in the docs.

Re: dzVents 1.0 released

Posted: Tuesday 31 May 2016 20:44
by dannybloe
Atmosphere wrote:
dannybloe wrote: Could you show me the actual json command? It shouldn't be too hard to add support for it.
Sure, here is the command: json.htm?type=command&param=udevice&idx=69&nvalue=0&svalue=$newpoint
(http://domoticz_ip_address:8080/json.htm?type=command&param=udevice&idx=69&nvalue=0&svalue=$newpoint)
Where IDX is the well known, and svalue (now $newpoint) the new setpoint (type, nvalue and udevice don't change)
Can you tell me the device information for this device? (find the device entry in in this results: http://<domoticz url>:<port>/json.htm?type=devices&displayhidden=1&filter=all&used=true).

In the mean time you can do domoticz.devices[69].update(0, <setpointvalue>). That should work. Could you try that?

Re: dzVents 1.0 released

Posted: Tuesday 31 May 2016 21:30
by dannybloe
woody4165 wrote:
dannybloe wrote:Ah, ok, I'll look into it. Seems like reset() isn't working as expected ;-)
Thanks!!
Well, indeed I completely f.d up the reset() implementation. Totally didn't work and my test was a false positive. But.. it is fixed now. You can try it with v1.0.1

Re: dzVents 1.0 released

Posted: Wednesday 01 June 2016 5:21
by jkimmel
Tx dannybloe for dealing with my problem.
this is my code now:

Code: Select all

-- create a simple lookup table that links
-- a master device (on your remote) to a slave device (a true light switch)
-- note that the prefix 'zza' is arbitrary.


local masterSlave =  {
zza_FB_11_Stehlampen_Salon = 'FB 11 Stehlampen Salon',
zza_FB_12_Downlight_Kamin = 'FB 12 Downlight Kamin',
zza_FB_13_Downlight_Terrasse = 'FB 13 Downlight Terrasse',
zza_FB_14_Lampe_Esstisch = 'FB 14 Lampe Esstisch',
zza_FB_21_Heizkreis_Salon = 'FB 21 Heizkreis Salon',
zza_FB_23_Heizkreis_Buero = 'FB 23 Heizkreis Buero',
zza_FB_31_Infrarot = 'FB 31 Infrarot',
zza_FB_32_Heizkreis_Schlafzimmer = 'FB 32 Heizkreis Schlafzimmer',
zza_FB_33_Waermepumpe = 'FB 33 Waermepumpe',
zza_FB_41_Heizkreis_Gaestebad = 'FB 41 Heizkreis Gaestebad',
zza_FB_42_Heizkreis_Bad = 'FB 42 Heizkreis Bad',
zza_FB_43_Downlight_Tresen = 'FB 43 Downlight Tresen'


}
return {
   active = true,
   on = {
'zza FB 11 Stehlampen Salon',
'zza FB 12 Downlight Kamin',
'zza FB 13 Downlight Terrasse',
'zza FB 14 Lampe Esstisch',
'zza FB 21 Heizkreis Salon',
'zza FB 23 Heizkreis Buero',
'zza FB 31 Infrarot',
'zza FB 32 Heizkreis Schlafzimmer',
'zza FB 33 Waermepumpe',
'zza FB 41 Heizkreis Gaestebad',
'zza FB 42 Heizkreis Bad',
'zza FB 43 Downlight Tresen'


   },
   execute = function(domoticz, masterSwitch)
   
      -- get the slave device using the lookup table above
      local slaveSwitch = domoticz.devices[masterSlave[masterSwitch.name]]
      domoticz.notify('Hey!', 'I am here!', domoticz.PRIORITY_NORMAL)
      print('test')          

      if (masterSwitch.state == 'On') then
         slaveSwitch.switchOn()
      else
         slaveSwitch.switchOff()
      end
   end
}
which results following error:

Code: Select all

2016-06-01 05:13:23.188 LUA: Handling events for: "zza FB 11 Stehlampen Salon", value: "On"
2016-06-01 05:13:23.188 LUA: =====================================================
2016-06-01 05:13:23.188 LUA: >>> Handler: remote_test
2016-06-01 05:13:23.189 LUA: >>> Device: "zza FB 11 Stehlampen Salon" Index: 423
2016-06-01 05:13:23.189 LUA: .....................................................
2016-06-01 05:13:23.189 LUA: test
2016-06-01 05:13:23.190 LUA: An error occured when calling event handler remote_test
2016-06-01 05:13:23.190 LUA: /home/pi/domoticz/scripts/lua/scripts/remote_test.lua:49: attempt to index local 'slaveSwitch' (a nil value)
2016-06-01 05:13:23.190 LUA: .....................................................
2016-06-01 05:13:23.191 LUA: <<< Done
2016-06-01 05:13:23.191 LUA: -----------------------------------------------------
2016-06-01 05:13:23.191 LUA: [1] = SendNotification: Hey!#I am here!#0#pushover
2016-06-01 05:13:23.192 LUA: =====================================================
I'm asking myself where is the "masterSwitch" found?

Re: dzVents 1.0 released

Posted: Wednesday 01 June 2016 8:19
by dannybloe
jkimmel wrote:Tx dannybloe for dealing with my problem.
this is my code now:

Code: Select all

-- create a simple lookup table that links
-- a master device (on your remote) to a slave device (a true light switch)
-- note that the prefix 'zza' is arbitrary.


local masterSlave =  {
zza_FB_11_Stehlampen_Salo = 'FB 11 Stehlampen Salon',
zza_FB_12_Downlight_Kami = 'FB 12 Downlight Kamin',
zza_FB_13_Downlight_Terrass = 'FB 13 Downlight Terrasse',
zza_FB_14_Lampe_Esstisc = 'FB 14 Lampe Esstisch',
zza_FB_21_Heizkreis_Salo = 'FB 21 Heizkreis Salon',
zza_FB_23_Heizkreis_Buer = 'FB 23 Heizkreis Buero',
zza_FB_31_Infraro = 'FB 31 Infrarot',
zza_FB_32_Heizkreis_Schlafzimme = 'FB 32 Heizkreis Schlafzimmer',
zza_FB_33_Waermepump = 'FB 33 Waermepumpe',
zza_FB_41_Heizkreis_Gaesteba = 'FB 41 Heizkreis Gaestebad',
zza_FB_42_Heizkreis_Bad = 'FB 42 Heizkreis Bad',
zza_FB_43_Downlight_Tresen = 'FB 43 Downlight Tresen'


}
return {
   active = true,
   on = {
'zza FB 11 Stehlampen Salon',
'zza FB 12 Downlight Kamin',
'zza FB 13 Downlight Terrasse',
'zza FB 14 Lampe Esstisch',
'zza FB 21 Heizkreis Salon',
'zza FB 23 Heizkreis Buero',
'zza FB 31 Infrarot',
'zza FB 32 Heizkreis Schlafzimmer',
'zza FB 33 Waermepumpe',
'zza FB 41 Heizkreis Gaestebad',
'zza FB 42 Heizkreis Bad',
'zza FB 43 Downlight Tresen'


   },
   execute = function(domoticz, masterSwitch)
   
      -- get the slave device using the lookup table above
      local slaveSwitch = domoticz.devices[masterSlave[masterSwitch.name]]
      domoticz.notify('Hey!', 'I am here!', domoticz.PRIORITY_NORMAL)
      print('test')          

      if (masterSwitch.state == 'On') then
         slaveSwitch.switchOn()
      else
         slaveSwitch.switchOff()
      end
   end
}
which results following error:

Code: Select all

2016-06-01 05:13:23.188 LUA: Handling events for: "zza FB 11 Stehlampen Salon", value: "On"
2016-06-01 05:13:23.188 LUA: =====================================================
2016-06-01 05:13:23.188 LUA: >>> Handler: remote_test
2016-06-01 05:13:23.189 LUA: >>> Device: "zza FB 11 Stehlampen Salon" Index: 423
2016-06-01 05:13:23.189 LUA: .....................................................
2016-06-01 05:13:23.189 LUA: test
2016-06-01 05:13:23.190 LUA: An error occured when calling event handler remote_test
2016-06-01 05:13:23.190 LUA: /home/pi/domoticz/scripts/lua/scripts/remote_test.lua:49: attempt to index local 'slaveSwitch' (a nil value)
2016-06-01 05:13:23.190 LUA: .....................................................
2016-06-01 05:13:23.191 LUA: <<< Done
2016-06-01 05:13:23.191 LUA: -----------------------------------------------------
2016-06-01 05:13:23.191 LUA: [1] = SendNotification: Hey!#I am here!#0#pushover
2016-06-01 05:13:23.192 LUA: =====================================================
I'm asking myself where is the "masterSwitch" found?
Ah, yeah. Actually, the log has all the information you need to nail this bugger. The thing is that you use the name of the device in the lookup table. In this example above you got an event for "zza FB 11 Stehlampen Salon" (see the first line in the log paste). However, your lookup table doesn't have this name in the lookup. It only has a "zza_FB _11_Stehlampen_Salon" which is a different name (underscores instead of spaces). So I guess the fix is easy:

Code: Select all


local masterSlave = {
	['zza FB 11 Stehlampen Salon'] = 'FB 11 Stehlampen Salon',
	['zza FB 12 Downlight Kamin'] = 'FB 12 Downlight Kamin',
	['zza FB 13 Downlight Terrasse'] = 'FB 13 Downlight Terrasse',
	['zza FB 14 Lampe Esstisch'] = 'FB 14 Lampe Esstisch',
	['zza FB 21 Heizkreis Salon'] = 'FB 21 Heizkreis Salon',
	['zza FB 23 Heizkreis Buero'] = 'FB 23 Heizkreis Buero',
	['zza FB 31 Infrarot'] = 'FB 31 Infrarot',
	['zza FB 32 Heizkreis Schlafzimmer'] = 'FB 32 Heizkreis Schlafzimmer',
	['zza FB 33 Waermepumpe'] = 'FB 33 Waermepumpe',
	['zza FB 41 Heizkreis Gaestebad'] = 'FB 41 Heizkreis Gaestebad',
	['zza FB 42 Heizkreis Bad'] = 'FB 42 Heizkreis Bad',
	['zza FB 43 Downlight Tresen'] = 'FB 43 Downlight Tresen'
}

return {
	active = true,
	on = {
		'zza FB *' -- you use prefix method here so no need to list them all individually, use the wildcard.
	},
	execute = function(domoticz, masterSwitch)

		-- get the slave device using the lookup table above
		-- but do some checking first to catch misstakes

		if (masterSlave[masterSwitch.name] == nil) then
			-- oops
			domoticz.log(masterSwitch.name .. ' cannot be found in the lookup table. Check the names.', domoticz.LOG_ERROR)
		end
		
		-- now get the slave device and check if it exists
		local slaveSwitch = domoticz.devices[masterSlave[masterSwitch.name]]
		
		if (slaveSwitch == nil) then
			-- oops again
			domoticz.log('There is no slave device by the name ' .. masterSlave[masterSwitch.name] .. '. Check the names', domoticz.LOG_ERROR)
		else
		
			-- we're good to go.. we have a slave device 
			if (masterSwitch.state == 'On') then
				slaveSwitch.switchOn()
			else
				slaveSwitch.switchOff()
			end
		end
	end 
}

Re: dzVents 1.0 released

Posted: Wednesday 01 June 2016 13:03
by woody4165
dannybloe wrote: Well, indeed I completely f.d up the reset() implementation. Totally didn't work and my test was a false positive. But.. it is fixed now. You can try it with v1.0.1
Hi danny

just tried the same script with v.1.0.1 and it's working like a charm!

Lua script are easy and powerful now in Domoticz

Thanks

Re: dzVents 1.0 released

Posted: Wednesday 01 June 2016 13:05
by dannybloe
woody4165 wrote:
dannybloe wrote: Well, indeed I completely f.d up the reset() implementation. Totally didn't work and my test was a false positive. But.. it is fixed now. You can try it with v1.0.1
Hi danny

just tried the same script with v.1.0.1 and it's working like a charm!

Lua script are easy and powerful now in Domoticz

Thanks
Great!

Re: dzVents 1.0 released

Posted: Wednesday 01 June 2016 20:11
by Neutrino
Thank you very much for all your work !
This is amazing how LUA can be very simple now :)

Re: dzVents 1.0 released

Posted: Wednesday 01 June 2016 21:54
by Atmosphere
dannybloe wrote:
Atmosphere wrote:
dannybloe wrote: Could you show me the actual json command? It shouldn't be too hard to add support for it.
Sure, here is the command: json.htm?type=command&param=udevice&idx=69&nvalue=0&svalue=$newpoint
(http://domoticz_ip_address:8080/json.htm?type=command&param=udevice&idx=69&nvalue=0&svalue=$newpoint)
Where IDX is the well known, and svalue (now $newpoint) the new setpoint (type, nvalue and udevice don't change)
Can you tell me the device information for this device? (find the device entry in in this results: http://<domoticz url>:<port>/json.htm?type=devices&displayhidden=1&filter=all&used=true).

Code: Select all

{
         "AddjMulti" : 1.0,
         "AddjMulti2" : 1.0,
         "AddjValue" : 0.0,
         "AddjValue2" : 0.0,
         "BatteryLevel" : 255,
         "CustomImage" : 0,
         "Data" : "15.0",
         "Description" : "",
         "Favorite" : 1,
         "HardwareID" : 7,
         "HardwareName" : "OpenThermGW",
         "HardwareType" : "OpenTherm Gateway with LAN interface",
         "HardwareTypeVal" : 20,
         "HaveTimeout" : false,
         "ID" : "0000005",
         "LastUpdate" : "2016-06-01 21:30:27",
         "Name" : "CV - Thermostaat",
         "Notifications" : "false",
         "PlanID" : "2",
         "PlanIDs" : [ 2 ],
         "Protected" : false,
         "SetPoint" : "15.0",
         "ShowNotifications" : true,
         "SignalLevel" : "-",
         "SubType" : "SetPoint",
         "Timers" : "true",
         "Type" : "Thermostat",
         "TypeImg" : "override_mini",
         "Unit" : 0,
         "Used" : 1,
         "XOffset" : "0",
         "YOffset" : "0",
         "idx" : "43"
      },
dannybloe wrote: In the mean time you can do domoticz.devices[69].update(0, <setpointvalue>). That should work. Could you try that?
domoticz.devices[43].update(0, 20.5) works! Thank you! That solved it....

On the issue with the hardware timing out i've found the following:

Code: Select all

{
         "AddjMulti" : 1.0,
         "AddjMulti2" : 1.0,
         "AddjValue" : 0.0,
         "AddjValue2" : 0.0,
         "BatteryLevel" : 255,
         "CustomImage" : 0,
         "Data" : "Off",
         "Description" : "",
         "Favorite" : 1,
         "HardwareID" : 4,
         "HardwareName" : "AeonLabs Z-stick",
         "HardwareType" : "OpenZWave USB",
         "HardwareTypeVal" : 21,
         "HaveDimmer" : true,
         "HaveGroupCmd" : true,
         "HaveTimeout" : true,
         "ID" : "00000F01",
         "Image" : "Light",
         "IsSubDevice" : false,
         "LastUpdate" : "2016-06-01 14:11:39",
         "Level" : 100,
         "LevelInt" : 100,
         "MaxDimLevel" : 100,
         "Name" : "Dimmer Gang",
         "Notifications" : "false",
         "PlanID" : "0",
         "PlanIDs" : [ 0 ],
         "Protected" : false,
         "ShowNotifications" : true,
         "SignalLevel" : "-",
         "Status" : "Off",
         "StrParam1" : "",
         "StrParam2" : "",
         "SubType" : "Switch",
         "SwitchType" : "Dimmer",
         "SwitchTypeVal" : 7,
         "Timers" : "false",
         "Type" : "Light/Switch",
         "TypeImg" : "dimmer",
         "Unit" : 1,
         "Used" : 1,
         "UsedByCamera" : false,
         "XOffset" : "0",
         "YOffset" : "0",
         "idx" : "150"
      },

As you can see the HaveTimeout value is True.... can we use that within dzVents?

Thank you for your help

Re: dzVents 1.0 released

Posted: Wednesday 01 June 2016 23:01
by dannybloe
Sure but what does it mean?

Re: dzVents 1.0 released

Posted: Wednesday 01 June 2016 23:57
by Atmosphere
dannybloe wrote:Sure but what does it mean?
It means that the device can't be reached because it is out of power. (Hardware powered off)
Do you know the lua command to read the value of HaveTimeout ?

I've managed to use your .updateSetPoint(setPoint, mode, until) in my scripts by changing Device.lua in th dzVents folder.
I've altered the code by adding hardwareTypeVal == 20 (OpenthermGW), see below:

Code: Select all

function self.updateSetPoint(setPoint, mode, untilDate)
		if ((self.hardwareTypeVal == 15 or self.hardwareTypeVal == 20) and self.deviceSubType == 'SetPoint') then -- dummy hardware
			-- send the command using openURL otherwise, due to a bug in Domoticz, you will get a timeout on the script
			local url = 'http://' .. domoticz.settings['Domoticz ip'] .. ':' .. domoticz.settings['Domoticz port'] ..
					'/json.htm?type=command&param=udevice&idx=' .. self.id .. '&nvalue=0&svalue=' .. setPoint
			utils.log('Setting setpoint using openURL ' .. url, utils.LOG_DEBUG)
			domoticz.openURL(url)

		elseif (self.hardwareTypeVal == 39 and self.deviceSubType == 'Zone') then --evohome
			local url = 'http://' .. domoticz.settings['Domoticz ip'] .. ':' .. domoticz.settings['Domoticz port'] ..
					'/json.htm?type=setused&idx=' .. self.id .. '&setpoint=' .. setPoint .. '&mode=' .. tostring(mode) .. '&used=true'

			if (untilDate) then
				url = url .. '&until=' .. tostring(untilDate)
			end

			utils.log('Setting setpoint using openURL ' .. url, utils.LOG_DEBUG)
			domoticz.openURL(url)
		else
			utils.log('Setting setpoint not supported for this device.', utils.LOG_ERROR)
		end
	end

Re: dzVents 1.0 released

Posted: Thursday 02 June 2016 8:33
by dannybloe
If you switch to the dev branch then you can check it out:
  • Added support for setting the setpoint for opentherm gateway.
  • Added timedOut boolean attribute to devices. Requires http data fetching to be anabled.
Let me know if it works then I'll make a release.

Re: dzVents 1.0 released

Posted: Thursday 02 June 2016 14:40
by Atmosphere
dannybloe wrote:If you switch to the dev branch then you can check it out:
  • Added support for setting the setpoint for opentherm gateway.
  • Added timedOut boolean attribute to devices. Requires http data fetching to be enabled.
Let me know if it works then I'll make a release.
Danny... I checked both
You're the best.... FIXED! Ready for release....


Now people can check if their devices are online and set their Temperature on the OpenTherm GW using .updateSetpoint too!

Examples I use them for:
Max Temperature for Thermostat

Code: Select all

-- My Family tends to set the Thermostat to 21 degrees and higher 
-- To limit Gas usage i've asked them to keep it under 21.
-- This script enforces it! :)


return {
	active = true,
	on = {
		['timer'] = 'every 5 minutes',
	},
	execute = function(domoticz)

		local Thermostaat = domoticz.devices['CV - Thermostaat']
		local thermos = Thermostaat.setPoint
		domoticz.log('Actueel thermostaat: ' .. thermos, domoticz.LOG_INFO)
				

		if thermos >= 21 then
			 
			domoticz.log('Te hoog gezet!', domoticz.LOG_ERROR)
			Thermostaat.updateSetPoint(20.0).after_min(2)
					
		else   domoticz.log('Thermostaat staat goed!', domoticz.LOG_INFO)
		end
	end
}
Automatic Lights off

Code: Select all

-- In my hall and on the stairs i've installed Domitech Z-wave bulbs.
-- I want to make sure they go off after 15 min to save energy.
-- This script first checks if the device is not powerless and if it's reachable it will switch off the light after 15 mins.

return {
	active = true,
	on = {
		['timer'] = 'every minute',
	},
	execute = function(domoticz)

		local trapgat = domoticz.devices['Dimmer Trapgat']
		local gang = domoticz.devices['Dimmer Gang']

		if not trapgat.timedOut then
			domoticz.log('Dimmer Trapgat bereikbaar!', domoticz.LOG_INFO)
			if (trapgat.state == 'On' and trapgat.lastUpdate.minutesAgo > 15) then
				trapgat.switchOff()
			end 
		else domoticz.log('Dimmer Trapgat onbereikbaar!', domoticz.LOG_ERROR)
		end
		if not gang.timedOut then 
			domoticz.log('Dimmer Gang bereikbaar!', domoticz.LOG_INFO)
			if (gang.state == 'On' and gang.lastUpdate.minutesAgo > 15) then
				gang.switchOff()
			end
		else domoticz.log('Dimmer Gang onbereikbaar!', domoticz.LOG_ERROR)
		end
	end
}
Thank you Danny (and all contributors) for simplifying the LUA code!

Re: dzVents 1.0 released

Posted: Thursday 02 June 2016 14:53
by dannybloe
It's almost readable like a story. That was my whole point of making this stuff.

Be aware though that the timedOut value is as recent as the http update interval as set in the dzVents_settings file.
Hopefully in the near future we can have Domoticz provide that information directly to dzVents.

Re: dzVents 1.0 released

Posted: Friday 03 June 2016 11:59
by Atmosphere
dannybloe wrote:Be aware though that the timedOut value is as recent as the http update interval as set in the dzVents_settings file.
I've set mine to 5 mins as i found that the updating of the default 30 mins caused to big a delay.
dannybloe wrote:Hopefully in the near future we can have Domoticz provide that information directly to dzVents.
That would be really great!

Scripting is now easy! ;) 8-) :D

Re: dzVents 1.0 released

Posted: Friday 03 June 2016 12:10
by Atmosphere
Danny, I get some error logs since the change to the dev version:

Code: Select all

 2016-06-02 22:55:02.040 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_main.lua: /home/pi/domoticz/scripts/lua/dzVents/Domoticz.lua:444: attempt to index local 'device' (a nil value)
2016-06-03 03:20:01.251 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_main.lua: /home/pi/domoticz/scripts/lua/dzVents/Domoticz.lua:444: attempt to index local 'device' (a nil value)
2016-06-03 05:55:03.449 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_main.lua: /home/pi/domoticz/scripts/lua/dzVents/Domoticz.lua:444: attempt to index local 'device' (a nil value)
2016-06-03 06:55:00.774 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_main.lua: /home/pi/domoticz/scripts/lua/dzVents/Domoticz.lua:444: attempt to index local 'device' (a nil value) 
Tried to see what happened, but could find the solution.

Re: dzVents 1.0 released

Posted: Friday 03 June 2016 12:18
by dannybloe
Atmosphere wrote:Danny, I get some error logs since the change to the dev version:

Code: Select all

 2016-06-02 22:55:02.040 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_main.lua: /home/pi/domoticz/scripts/lua/dzVents/Domoticz.lua:444: attempt to index local 'device' (a nil value)
2016-06-03 03:20:01.251 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_main.lua: /home/pi/domoticz/scripts/lua/dzVents/Domoticz.lua:444: attempt to index local 'device' (a nil value)
2016-06-03 05:55:03.449 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_main.lua: /home/pi/domoticz/scripts/lua/dzVents/Domoticz.lua:444: attempt to index local 'device' (a nil value)
2016-06-03 06:55:00.774 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_main.lua: /home/pi/domoticz/scripts/lua/dzVents/Domoticz.lua:444: attempt to index local 'device' (a nil value) 
Tried to see what happened, but could find the solution.
Interesting.. it seems that it cannot find the device. Could you add this just before 444 in the code:

Code: Select all

if device==nil then print(httpDevice.Type, httpDevice.idx) end
And see if you can find a device/group/scene with that idx in the devices.lua file (results from the http request).

Re: dzVents 1.0 released

Posted: Sunday 05 June 2016 11:55
by jkimmel
@dannybloe

first of all thank you for resolving my first problem.
Because I struggle with following the logics of dzVents (it's because of my age I think) I ask you for help once more.
I'm sure you will deal with it like others flip fingers.
Here it is, it is about controlling my heating which is done at the moment using blockly.
I'd like to change to lua because it will be easier to expand the logic in the future if needed, I think.
P. E. setting setpoints using selector switch to changing between night , comfort, absent or so.

My devices:
a 0= setpoint(salon) b0 = Temperature(salon) c0 = Heating (salon)
a1 = setpoint(bath) b1 = Temperature(bath) c1 = Heating (bath)
and some more

Logic:
if b(0,1) < a(0,1) then c(0,1) = on
else c(0,1) = off

Hopefully I expressed the task clear enough.

Re: dzVents 1.0 released

Posted: Sunday 05 June 2016 20:19
by dannybloe
jkimmel wrote:@dannybloe

first of all thank you for resolving my first problem.
Because I struggle with following the logics of dzVents (it's because of my age I think) I ask you for help once more.
I'm sure you will deal with it like others flip fingers.
Here it is, it is about controlling my heating which is done at the moment using blockly.
I'd like to change to lua because it will be easier to expand the logic in the future if needed, I think.
P. E. setting setpoints using selector switch to changing between night , comfort, absent or so.

My devices:
a 0= setpoint(salon) b0 = Temperature(salon) c0 = Heating (salon)
a1 = setpoint(bath) b1 = Temperature(bath) c1 = Heating (bath)
and some more

Logic:
if b(0,1) < a(0,1) then c(0,1) = on
else c(0,1) = off

Hopefully I expressed the task clear enough.
Well, this script you propose is indeed quite simple. Assuming that your selector switch values are numbers it will probably look something like this:

Code: Select all

return {
	active = true, 
	on = {
		['timer'] = 'every minute', 
	},
	execute = function(domoticz)
		
		local function regulate(setpoint, temperature, boiler)
			if (temperature < setpoint) then
				boiler.switchOn()
			else
				boiler.switchOff()
			end
		end
		
		local spSalon = tonumber(domoticz.devices['Setpoint Salon'].state)
		local tSalon = domoticz.devices['Temperature Salon'].temperature
		local bSalon = domoticz.devices['Boiler Salon']

		local spBath = tonumber(domoticz.devices['Setpoint Bath'].state)
		local tBath = domoticz.devices['Temperature Bath'].temperature
		local bBath = domoticz.devices['Boiler Bath']
		
		regulate(spSalon, tSalon, bSalon)
		regulate(spBath, tBath, bBath)
	end
}
There is however a problem with this kind of heating control and that is called hysteresis. Your heater will start to go on and off way to often here. You need to have some kind of hysteresis control. That more or less means that, after the boiler was turned off and the temperature is starting to decline, you wait with turning the boiler back on again until after the temperature is below a certain threshold lower than the setpoint temperature. So there is a difference between rising temperatures and lowering temperatures and how you deal with it.

I have a script that does something like that which needs a bit of dzVents-adapting but I could do that and put that in the examples folder of dzVents. It uses hysteresis settings and data smoothing to filter out noises and peaks etc.

Let me know if you are interested.

Re: dzVents 1.0 released

Posted: Sunday 05 June 2016 20:20
by dannybloe
Atmosphere wrote:Danny, I get some error logs since the change to the dev version:

Code: Select all

 2016-06-02 22:55:02.040 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_main.lua: /home/pi/domoticz/scripts/lua/dzVents/Domoticz.lua:444: attempt to index local 'device' (a nil value)
2016-06-03 03:20:01.251 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_main.lua: /home/pi/domoticz/scripts/lua/dzVents/Domoticz.lua:444: attempt to index local 'device' (a nil value)
2016-06-03 05:55:03.449 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_main.lua: /home/pi/domoticz/scripts/lua/dzVents/Domoticz.lua:444: attempt to index local 'device' (a nil value)
2016-06-03 06:55:00.774 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_main.lua: /home/pi/domoticz/scripts/lua/dzVents/Domoticz.lua:444: attempt to index local 'device' (a nil value) 
Tried to see what happened, but could find the solution.
Did you find anything yet?