Hi
I am investigating to port a lot of big lua scripts to dzevents...
As far as i can see dzeventis i basic lua in a different way formatted for optimum working with domoticz
Due to the amount of lines and complexity in my scripts i am looking for some hybrid solution.
My lua scripts are segmented in functions that are called from time and device scripts.
The way i would love to go is to port function by function. But for that i need to call dzevent functions from plain lua.
After some trial and error i have a couple of questions :
- Is it possible to call a dzevents routine from plain lua and if so how to do that the right way ?
- Would it be possible to get return values from dzevents into plain lua?
next : has anyone done the port to dzevents and are there some tips how to do this the right way ?
What i found is :
https://www.domoticz.com/wiki/DzVents:_ ... _functions
From those links i learned that it is possible to create a dz function (or a function file) from within dzevents, like i have now with require.
Will it be possible to call a dzevent script (like a function) from a plain lua script ?
Has anyone managed to do so and maybe some practical example to start from ?
(Of course i will try and error on a dummy instance, but during the port i will be forced to implement this to production env.)
ps. I am not a coder at all, and just learned lua over the years ... (I'll hope i am able to manage the transition)
Many thanks in advance.
Is to possible to mix plain lua and dzevents routines ?
Moderator: leecollings
-
- Posts: 272
- Joined: Sunday 11 May 2014 11:09
- Target OS: Windows
- Domoticz version: 2023.1+
- Location: NL
- Contact:
Is to possible to mix plain lua and dzevents routines ?
Rpi & Win x64. Using : cam's,RFXCom, LaCrosse, RFY, HuE, google, standard Lua, Tasker, Waze traveltime, NLAlert&grip2+,curtains, vacuum, audioreceiver, smart-heating&cooling + many more (= automate all repetitive simple tasks)
- waltervl
- Posts: 5843
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Is to possible to mix plain lua and dzevents routines ?
This section of the dzvents wiki explains the usage of lua helper functions, stored in the global_data.lua file:
https://wiki.domoticz.com/DzVents:_next ... _functions
https://wiki.domoticz.com/DzVents:_next ... _functions
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 272
- Joined: Sunday 11 May 2014 11:09
- Target OS: Windows
- Domoticz version: 2023.1+
- Location: NL
- Contact:
Re: Is to possible to mix plain lua and dzevents routines ?
Hi Walter
Found that one, but the way i read it this is used by dzevents only.
probably my lack of understandig ?
Will the routine be available from the "regular" lua interprenter in domoticz.
Bit confused as it would need to require or load the file somehow ? It writes not needed, but how does lua find it then ?
Also does this allow mixing dzevents and "regular" lua or do the function totaly separated (stand alone next to each other ?)
Maybe i am just overthinking and should start experimenting, i just dont get the mixing of the two....
Found that one, but the way i read it this is used by dzevents only.
probably my lack of understandig ?
Will the routine be available from the "regular" lua interprenter in domoticz.
Bit confused as it would need to require or load the file somehow ? It writes not needed, but how does lua find it then ?
Also does this allow mixing dzevents and "regular" lua or do the function totaly separated (stand alone next to each other ?)
Maybe i am just overthinking and should start experimenting, i just dont get the mixing of the two....
Rpi & Win x64. Using : cam's,RFXCom, LaCrosse, RFY, HuE, google, standard Lua, Tasker, Waze traveltime, NLAlert&grip2+,curtains, vacuum, audioreceiver, smart-heating&cooling + many more (= automate all repetitive simple tasks)
- waltervl
- Posts: 5843
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Is to possible to mix plain lua and dzevents routines ?
I have no clue, I do not use lua, only dzvents.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 612
- Joined: Sunday 01 November 2015 22:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Location: Twente
- Contact:
Re: Is to possible to mix plain lua and dzevents routines ?
I asked your question to CoPilot based on the this Domoticz WiKi page.
The page shows scripts in lua and in dzVents having the same functionality.
The script CoPilot produced is this one.
Check and compare and maybe try one of your own lua scripts.
CoPilot is built-in into the EDGE browser, is free to use, has some restrictions on script length and sometimes lets you wait a while.
The main and important disadvantage of CoPilot is that it reads your open tab in the browser. On the other hand you can use this by asking CoPilot to check the script in the underlying page.
The other choice for AI you can make is Claude, which is more privacy prone.
The free version of Claude is better in programming questions but limited to about 8 questions per day.
I'm using AI to assist my programming plans since the end of december and ever since debugging a script has become child's play.
PS
I asked CoPilot how to describe it's presence in the EDGE browser and it's answer was:
"Copilot is built into the Edge browser, providing seamless integration and enhanced user experience."
I asked CoPilot about privacy and this was it's answer.
Here are some of the main privacy concerns people have encountered with Microsoft Copilot:
Data Access: Copilot has access to a wide range of data within Microsoft products, such as emails, chats, documents, and calendar events. This extensive access raises concerns about how this data is used and who has access to it1.
Screen Snapshots: One feature called "Recall" takes snapshots of a user's screen every few seconds to help users find information they have seen before. This feature has raised significant privacy concerns, as it could potentially capture sensitive information2.
Data Sharing: By default, data sharing is turned on, which means that user data can be shared with Microsoft. Users need to manually change their data sharing settings to limit this access1.
Lack of Transparency: Some users have reported that it is not clear what data is being collected, how it is being used, and who has access to it. This lack of transparency can make users feel uneasy about using the tool.
Compliance Concerns: While Microsoft claims that Copilot complies with privacy regulations like GDPR, there are still concerns about how well these regulations are enforced and whether user data is truly protected.
Opt-Out Options: Some users have found it difficult to completely remove Copilot from their systems or to opt out of certain features. This lack of control over the tool can be frustrating for privacy-conscious users.
These concerns highlight the importance of being aware of how AI tools like Copilot handle user data and the need for robust privacy protections.
If you want to know more, just ask: Can you tell me the main differences between CoPilot and Claude
So you'd better be warned!
The page shows scripts in lua and in dzVents having the same functionality.
The script CoPilot produced is this one.
Code: Select all
return {
active = true,
on = {
timer = { 'every minute' } -- Dit script wordt elke minuut uitgevoerd
},
logging = {
level = domoticz.LOG_DEBUG,
marker = 'CheckHueLights Script'
},
execute = function(domoticz)
local hueBridgeIP = 'enter_HUE_ip_here'
local hueBridgeAPI = 'enter_HUE_username_here'
local function getHueLight(id)
local http = require('socket.http')
local ltn12 = require('ltn12')
local json = require('dkjson')
local t = {}
local url = string.format("http://%s/api/%s/lights/%s", hueBridgeIP, hueBridgeAPI, id)
local b, c, h = http.request{url=url, sink = ltn12.sink.table(t), method='GET'}
local huestring = tostring(table.concat(t))
local hue, pos, err = json.decode(huestring, 1, nil)
local hue_name, hue_state, stop
if (hue.name) then
hue_name = (hue.name)
hue_state = (hue.state.on)
stop = false
else
stop = true
end
return hue_name, hue_state, stop
end
local i = 1
local stop = false
while not stop do
local hue_name, hue_state, stop = getHueLight(i)
if hue_name then
local device = domoticz.devices(hue_name)
if hue_state == true and device.state == 'Off' then
device.switchOn()
domoticz.log(string.format("Status %s corrigeren", hue_name), domoticz.LOG_DEBUG)
elseif hue_state == false and device.state ~= 'Off' then
device.switchOff()
domoticz.log(string.format("Status %s corrigeren", hue_name), domoticz.LOG_DEBUG)
end
end
i = i + 1
end
end
}
CoPilot is built-in into the EDGE browser, is free to use, has some restrictions on script length and sometimes lets you wait a while.
The main and important disadvantage of CoPilot is that it reads your open tab in the browser. On the other hand you can use this by asking CoPilot to check the script in the underlying page.
The other choice for AI you can make is Claude, which is more privacy prone.
The free version of Claude is better in programming questions but limited to about 8 questions per day.
I'm using AI to assist my programming plans since the end of december and ever since debugging a script has become child's play.
PS
I asked CoPilot how to describe it's presence in the EDGE browser and it's answer was:
"Copilot is built into the Edge browser, providing seamless integration and enhanced user experience."
I asked CoPilot about privacy and this was it's answer.
Here are some of the main privacy concerns people have encountered with Microsoft Copilot:
Data Access: Copilot has access to a wide range of data within Microsoft products, such as emails, chats, documents, and calendar events. This extensive access raises concerns about how this data is used and who has access to it1.
Screen Snapshots: One feature called "Recall" takes snapshots of a user's screen every few seconds to help users find information they have seen before. This feature has raised significant privacy concerns, as it could potentially capture sensitive information2.
Data Sharing: By default, data sharing is turned on, which means that user data can be shared with Microsoft. Users need to manually change their data sharing settings to limit this access1.
Lack of Transparency: Some users have reported that it is not clear what data is being collected, how it is being used, and who has access to it. This lack of transparency can make users feel uneasy about using the tool.
Compliance Concerns: While Microsoft claims that Copilot complies with privacy regulations like GDPR, there are still concerns about how well these regulations are enforced and whether user data is truly protected.
Opt-Out Options: Some users have found it difficult to completely remove Copilot from their systems or to opt out of certain features. This lack of control over the tool can be frustrating for privacy-conscious users.
These concerns highlight the importance of being aware of how AI tools like Copilot handle user data and the need for robust privacy protections.
If you want to know more, just ask: Can you tell me the main differences between CoPilot and Claude
So you'd better be warned!
Bugs bug me.
Who is online
Users browsing this forum: Bing [Bot] and 1 guest