Re: dzVents 1.0 released
Posted: Wednesday 08 June 2016 18:47
Is it possible to set a RGB/RGBW device (Fibaro) colors?
Nice.jkimmel wrote:Because there s no other place where scripts can showed, here my contribution based on the help of @dannybloe.
It is about heating control:
1. control heat circuits by setpoints:2. control heatpump: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 }
I'm sure dannybloe will have a look at this and will comment if there is a need.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 }
Code: Select all
function self.updateLux(lux)
self.update(0,lux)
end
Thanks! Fixed this in the dev branch. Keep them comingNeutrino wrote:Hi dannybloe,
Device method updateLux(Lux) doesn't work.
The nValue is updated instead of sValue.
I corrected the function in Device.luaThanks for allCode: Select all
function self.updateLux(lux) self.update(0,lux) end
Code: Select all
local pulse_counter = 'WattCountRaw'
local pulses = tonumber(otherdevices_svalues[pulse_counter])
Code: Select all
local inWatt = domoticz.devices['WattCountRaw'].WActual
print ('Watt Pulses = ' .. inWatt)
Code: Select all
LUA: An error occured when calling event handler try
LUA: /home/pi/domoticz/scripts/lua/scripts/wattcount.lua:14: attempt to concatenate local 'inWatt' (a nil value)
Could you send me the json output for that device (it should be in devices.lua if you have http fetching enabled). It is very well possible that that devicetype is not yet recognized by dzVents.NietGiftig wrote:I am rebuilding my lua scripts to dzVents style.
I have an simple energiemeter with one LED (1000pulse/kw) via espeasy (counted pulses/minute) to an incremental counter in Domoticz named 'WattCountRaw'
In Domoticz LUA I split the pulses in high and low (cost) incremental counting depending on day/time
In my working existing script I read the recieved pulses with:In dzVents lua I cannot find the received pulses, so to say, I do not find an Device attribute which has the counted pulsesCode: Select all
local pulse_counter = 'WattCountRaw' local pulses = tonumber(otherdevices_svalues[pulse_counter])
I tried :But then I get:Code: Select all
local inWatt = domoticz.devices['WattCountRaw'].WActual print ('Watt Pulses = ' .. inWatt)
Some help would be nice, I am using dzVents [1.0.2]Code: Select all
LUA: An error occured when calling event handler try LUA: /home/pi/domoticz/scripts/lua/scripts/wattcount.lua:14: attempt to concatenate local 'inWatt' (a nil value)
Code: Select all
{
["AddjMulti"]= 1.0,
["AddjMulti2"]= 1.0,
["AddjValue"]= 0.0,
["AddjValue2"]= 0.0,
["BatteryLevel"]= 255,
["Counter"]= "751.338 kWh",
["CounterToday"]= "3.551 kWh",
["CustomImage"]= 0,
["Data"]= "751.338 kWh",
["Description"]= "",
["Favorite"]= 0,
["HardwareID"]= 2,
["HardwareName"]= "ESPNetwork",
["HardwareType"]= "Dummy (Does nothing, use for virtual switches only)",
["HardwareTypeVal"]= 15,
["HaveTimeout"]= false,
["ID"]= "82064",
["LastUpdate"]= "2016-06-10 11:59:11",
["Name"]= "WattCountRaw",
["Notifications"]= "false",
["PlanID"]= "0",
["PlanIDs"]= { 0 },
["Protected"]= false,
["ShowNotifications"]= true,
["SignalLevel"]= "-",
["SubType"]= "Counter Incremental",
["SwitchTypeVal"]= 0,
["Timers"]= "false",
["Type"]= "General",
["TypeImg"]= "counter",
["Unit"]= 1,
["Used"]= 1,
["ValueQuantity"]= "",
["ValueUnits"]= "",
["XOffset"]= "0",
["YOffset"]= "0",
["idx"]= "65"
},
Code: Select all
-- hidden attribute which will show the rawData:
print(domoticz.devices['WattCountRaw']._sValues)
-- get the index from _sValues using the rawData attribute:
domoticz.devices['WattCountRaw'].rawData[1] -- or 2
Thanks, I will do that.dannybloe wrote:Ah, I see. I will have a look to see if I can make a specific property for this device. For now you can use the rawData attribute I think:
Code: Select all
-- hidden attribute which will show the rawData: print(domoticz.devices['WattCountRaw']._sValues) -- get the index from _sValues using the rawData attribute: domoticz.devices['WattCountRaw'].rawData[1] -- or 2
I assume that I must get the counted pulses/per minute with still with rawdata as you describeddannybloe wrote:Note that the values are as accurate as the latest http fetch.
Then there is script that is taking a lot of time. Or doesn't end. Check the logs. It should show you when a script starts and ends (if you have info messages enabled in dzVents_settings.lua).dhanjel wrote:I have a lot of log entries in the error tab of this type:
2016-06-16 13:22:10.470 Error: EventSystem: Warning!, lua script /home/daniel/domoticz/scripts/lua/script_time_main.lua has been running for more than 10 seconds
is that normal?