Re: dzVents 1.0 released
Posted: Sunday 05 June 2016 20:22
Peepz, please use the tracker on GitHub for bugs/problems/errors. That way I can better keep tracker of things.
Code: Select all
2016-06-06 14:25:19.037 Error: EventSystem: in Dishwasher_Monitor: [string "commandArray = {}..."]:6: bad argument #1 to 'pairs' (table expected, got nil)
Code: Select all
return {
active = false,
on = {
['timer'] = 'every minute'
},
data = {
readingHistory = {
history = true,
maxItems = 3
},
notificationSent = {
initial = false
}
},
execute = function(domoticz, switch, triggerInfo)
local consumption = domoticz.devices['Kök, Diskmaskin'].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)
elseif (average > 100)
then
domoticz.data.notificationSent = false
end
end
}
Working on itdhanjel wrote:Seriously, this should be merged with the main code and be the main engine for lua scripts.
So much simpler to work with in every way possible.
In the same log there should be a list of all the command array items that dzVents prepares and sends back to Domoticz. Can you post that list?dhanjel wrote: I am trying to get a notification sent when my dishwasher is done (consumption stays around 3.3w for a couple of minutes),
but it seems to through some errors.
Any ideas?Code: Select all
2016-06-06 14:25:19.037 Error: EventSystem: in Dishwasher_Monitor: [string "commandArray = {}..."]:6: bad argument #1 to 'pairs' (table expected, got nil)
Code: Select all
return { active = false, on = { ['timer'] = 'every minute' }, data = { readingHistory = { history = true, maxItems = 3 }, notificationSent = { initial = false } }, execute = function(domoticz, switch, triggerInfo) local consumption = domoticz.devices['Kök, Diskmaskin'].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) elseif (average > 100) then domoticz.data.notificationSent = false end end }
That line is not related to dzVents.dhanjel wrote:Thats all I got.
I do have a single entry of this as well,
2016-06-06 15:02:51.720 Error: Getting error 'Transport endpoint is not connected' while getting remote_endpoint in connection_manager::start
Hi Danny, It's still happening...dannybloe wrote:
Did you find anything yet?
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)
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'].WActual
if (consumption == nill)
then
domoticz.log("Consumption could not be read.", domoticz.LOG_INFO)
else
domoticz.data.readingHistory.add(consumption)
domoticz.log("Current consumption: " .. consumption, domoticz.LOG_INFO)
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
end
}
Code: Select all
2016-06-07 07:52:00.441 LUA: =====================================================
2016-06-07 07:52:00.441 LUA: >>> Handler: dishwasher
2016-06-07 07:52:00.441 LUA: .....................................................
2016-06-07 07:52:00.441 LUA: Consumption could not be read.
2016-06-07 07:52:00.441 LUA: .....................................................
2016-06-07 07:52:00.441 LUA: <<< Done
2016-06-07 07:52:00.441 LUA: -----------------------------------------------------
Ok, the best step next is to look into the file devices.lua. First of all, that file should exist and be recent (not older than the fetch interval as set in the setttings file). If that is the case you can open the file and find the Kök device and see if it has the proper wattage listed. Also check that the name is exactly the same as you use in your code. (Can you post the piece for your device here?)dhanjel wrote:One step in the right direction. It seemed I had to many parameters to the execute-function.
Next bump in the road, it seems that the power consumption always is null.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'].WActual if (consumption == nill) then domoticz.log("Consumption could not be read.", domoticz.LOG_INFO) else domoticz.data.readingHistory.add(consumption) domoticz.log("Current consumption: " .. consumption, domoticz.LOG_INFO) 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 end }
Code: Select all
2016-06-07 07:52:00.441 LUA: ===================================================== 2016-06-07 07:52:00.441 LUA: >>> Handler: dishwasher 2016-06-07 07:52:00.441 LUA: ..................................................... 2016-06-07 07:52:00.441 LUA: Consumption could not be read. 2016-06-07 07:52:00.441 LUA: ..................................................... 2016-06-07 07:52:00.441 LUA: <<< Done 2016-06-07 07:52:00.441 LUA: -----------------------------------------------------
HTTP Fetch is configured
Code: Select all
if (device.deviceType == 'General' and device.deviceSubType == 'kWh') then
device.addAttribute('WhTotal', tonumber(device.rawData[2]))
device.addAttribute('WActual', tonumber(device.rawData[1]))
local todayFormatted = httpDevice.CounterToday or ''
-- risky business, we assume no decimals, just thousands separators
-- there is no raw value available for today
local s = string.gsub(todayFormatted, '%.', '')
s = string.gsub(s, '%,', '')
s = string.gsub(s, ' kWh', '')
device.addAttribute('WhToday', tonumber(s))
end
Code: Select all
{
["AddjMulti"]= 1.0,
["AddjMulti2"]= 1.0,
["AddjValue"]= 0.0,
["AddjValue2"]= 0.0,
["BatteryLevel"]= 255,
["CustomImage"]= 0,
["Data"]= "3.4 Watt",
["Description"]= "",
["Favorite"]= 0,
["HardwareID"]= 2,
["HardwareName"]= "Z-Wave",
["HardwareType"]= "OpenZWave USB",
["HardwareTypeVal"]= 21,
["HaveTimeout"]= true,
["ID"]= "0001901",
["LastUpdate"]= "2016-06-07 07:40:22",
["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"]= "97"
}
Code: Select all
domoticz.logDevice(domoticz.devices)
Code: Select all
2016-06-07 09:03:00.261 LUA: =====================================================
2016-06-07 09:03:00.261 LUA: >>> Handler: dishwasher
2016-06-07 09:03:00.261 LUA: .....................................................
2016-06-07 09:03:00.261 LUA: ----------------------------
2016-06-07 09:03:00.261 LUA: An error occured when calling event handler dishwasher
2016-06-07 09:03:00.261 LUA: /home/daniel/domoticz/scripts/lua/dzVents/Domoticz.lua:269: attempt to concatenate field 'name' (a nil value)
2016-06-07 09:03:00.261 LUA: .....................................................
2016-06-07 09:03:00.261 LUA: <<< Done
2016-06-07 09:03:00.261 LUA: -----------------------------------------------------
Code: Select all
2016-06-07 09:38:00.233 LUA: =====================================================
2016-06-07 09:38:00.233 LUA: >>> Handler: dishwasher
2016-06-07 09:38:00.233 LUA: .....................................................
2016-06-07 09:38:00.233 LUA: Current consumption: 3.4
2016-06-07 09:38:00.233 LUA: .....................................................
2016-06-07 09:38:00.233 LUA: <<< Done
2016-06-07 09:38:00.233 LUA: -----------------------------------------------------
3.4 Watt when it's not running? I'd get a new onedhanjel wrote:Sweet, that part seems to work fine now.Just need to wait until I can run the dishwasher again to testCode: Select all
2016-06-07 09:38:00.233 LUA: ===================================================== 2016-06-07 09:38:00.233 LUA: >>> Handler: dishwasher 2016-06-07 09:38:00.233 LUA: ..................................................... 2016-06-07 09:38:00.233 LUA: Current consumption: 3.4 2016-06-07 09:38:00.233 LUA: ..................................................... 2016-06-07 09:38:00.233 LUA: <<< Done 2016-06-07 09:38:00.233 LUA: -----------------------------------------------------
Code: Select all
return {
active = true,
on = {
['timer'] = 'every 10 minutes',
},
execute = function(domoticz)
local function regulate(setpoint, temperature, boiler)
if (temperature < setpoint) and (boiler.state == 'Off') then boiler.switchOn()
else
if (boiler.state == 'On') then boiler.switchOff()
end
end
end
local spSalon = tonumber(domoticz.devices['Setpoint Salon'].state)
local tSalon = domoticz.devices['Salon'].temperature
local bSalon = domoticz.devices['FB 21 Heizkreis Salon']
local spBath = tonumber(domoticz.devices['Setpoint Bad'].state)
local tBath = domoticz.devices['Bad'].temperature
local bBath = domoticz.devices['FB 42 Heizkreis Bad']
local spBuero = tonumber(domoticz.devices['Setpoint Buero'].state)
local tBuero = domoticz.devices['Buero'].temperature
local bBuero = domoticz.devices['FB 23 Heizkreis Buero']
local spSchlafzimmer = tonumber(domoticz.devices['Setpoint Schlafzimmer'].state)
local tSchlafzimmer = domoticz.devices['Schlafzimmer'].temperature
local bSchlafzimmer = domoticz.devices['FB 32 Heizkreis Schlafzimmer']
local spGaestebad = tonumber(domoticz.devices['Setpoint Gaestebad'].state)
local tGaestebad = domoticz.devices['Gaestebad'].temperature
local bGaestebad = domoticz.devices['FB 41 Heizkreis Gaestebad']
regulate(spSalon, tSalon, bSalon)
regulate(spBath, tBath, bBath)
regulate(spBuero, tBuero, bBuero)
regulate(spSchlafzimmer, tSchlafzimmer, bSchlafzimmer)
regulate(spGaestebad, tGaestebad, bGaestebad)
end
}
Code: Select all
return {
active = true,
on = {
['timer'] = 'every 10 minutes',
},
execute = function(domoticz)
local Wp = domoticz.devices['FB 33 Wärmepumpe']
local bSalon = domoticz.devices['FB 21 Heizkreis Salon']
local bBath = domoticz.devices['FB 42 Heizkreis Bad']
local bBuero = domoticz.devices['FB 23 Heizkreis Buero']
local bSchlafzimmer = domoticz.devices['FB 32 Heizkreis Schlafzimmer']
local bGaestebad = domoticz.devices['FB 41 Heizkreis Gaestebad']
if (bSalon == 'On') or (bBath == 'On') or (bBuero == 'On') or (bSchlafzimmer == 'On') or (bGaestebad == 'On') and (Wp.state == 'Off')
then Wp.switchOn()
else if (Wp.state == 'On')
then Wp.switchOff()
end
end
end
}