I’m working up a design for a “better” central heating controller for Domoticz. (Please don’t flame because you think somebody has already been there).
Coming from an OO background, I am thinking in terms of objects for thermostats, boiler controls, timers, timer plans etc. However, the challenge is persisting their values over the event/timer-driven approach adopted by Domoticz/dzEvents et al.
Has anybody successfully used the global storage capabilities of dzEvents to persist complex table variables?
OO programming with dzEvents
Moderator: leecollings
-
- Posts: 115
- Joined: Tuesday 17 November 2015 21:19
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.9317
- Location: St Neots, UK
- Contact:
-
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: OO programming with dzEvents
You can persist table data with dzVents. Nothing is preventing you from doing this. The only thing is that functions are not persisted and removed from the table.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
-
- Posts: 115
- Joined: Tuesday 17 November 2015 21:19
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.9317
- Location: St Neots, UK
- Contact:
Re: OO programming with dzEvents
Thanks. Any suggestions on how to get around this?dannybloe wrote: The only thing is that functions are not persisted and removed from the table.
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: OO programming with dzEvents
Yes, load your functions from a file likegarethhowell wrote: ↑Saturday 01 December 2018 0:30Thanks. Any suggestions on how to get around this?dannybloe wrote: The only thing is that functions are not persisted and removed from the table.
Code: Select all
local function getFunctions()
fn = require("commonFunctions")
end
if pcall(getFunctions) then
dz.log("getFunctions loaded",dz.LOG_DEBUG)
end
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 115
- Joined: Tuesday 17 November 2015 21:19
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.9317
- Location: St Neots, UK
- Contact:
-
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: OO programming with dzEvents
Well, we are dealing with plain Lua and Lua offers way to create objects. What you should do is pass the persisted data to the constructor of you object and then initialise all the internal data of the object. All this is not dzVents related. I suggest to read the Lua documentation and how to require modules in your code.
Actually, dzVents object model does exactly that. I receives a Lua table from Domoticz and passes that along to the proper object constructors.
Actually, dzVents object model does exactly that. I receives a Lua table from Domoticz and passes that along to the proper object constructors.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
Who is online
Users browsing this forum: No registered users and 1 guest