The manual from February doesn't seem to mention Lua - is there a (concise? complete?) description anywhere of what the Lua subsystem can do etc?
I can see some examples here but its a bit fragmented.
Use case: I'd like Domoticz to manage devices (I bought a Danfoss Z-Wave RS Room Sensor and it seems nice, I might replace my CF-MC/CF-RO based system with these), history, and so on - but I need to interface to some actors, most likely ethernet and/or USB relays.
I'm a little concerned about putting a lot of logic into Lua because:
- I rather prefer a strongly types language
- it seems clunks to run stateless scripts and have to store state in named variables
- I'm uneasy about having a 1-minute granularity on tick events
Anyway - it seems that my options are:
- to RPC against some sort of service
- dump the state to a shared environment (some sort of db, or just a file) and emit a datagram to trigger processing
- emit a datagram and use the JSON API from a helper process
I'm assuming the 'emit datagram' will be backed up with some sort of polled system too, in case of loss.
I see that Lua runs in its own thread - so maybe this whole thing can be executed synchronously from Lua. But what is the synchronisation between changes being actioned from Lua and from one r more JSON HTTP RPCs?
I guess I would have liked a means to start a subprocess that can stick around, and pass it a wakeup from Lua (whether a signal or a message to stdin). But I can't see a way to do such a thing nicely.
The helper/JSON system seems attractive - or it would be if user variables could be tracked and rendered on the dashboard so I can mirrow external actor state and visualise them - but that doesn't seem to be supported. Have I missed something?
Thanks
James
Is there a manual for Lua?
Moderator: leecollings
- bbqkees
- Posts: 407
- Joined: Sunday 17 August 2014 21:01
- Target OS: Linux
- Domoticz version: 4.1x
- Location: The Netherlands
- Contact:
Re: Is there a manual for Lua?
There is no complete manual for LUA in Domoticz. There is no full list of every option you can use.
My experience is you need to check many examples to get really going.
It's all bits and pieces here and there.
A lot is also 'hidden deep' into forum posts.
LUA scripts trigger either every minute or every device change.
So with the last option you can do a lot fast.
If you can interface your USB and ethernet relays as native hardware or virtual switches the Domoticz framework will work pretty well for standard on/off comparison etc in LUA.
You can read the switch and sensor status and act on change etc.
My experience is you need to check many examples to get really going.
It's all bits and pieces here and there.
A lot is also 'hidden deep' into forum posts.
LUA scripts trigger either every minute or every device change.
So with the last option you can do a lot fast.
If you can interface your USB and ethernet relays as native hardware or virtual switches the Domoticz framework will work pretty well for standard on/off comparison etc in LUA.
You can read the switch and sensor status and act on change etc.
Bosch / Nefit / Buderus / Junkers / Worcester / Sieger EMS bus Wi-Fi MQTT Gateway and interface boards: https://bbqkees-electronics.nl/
-
- Posts: 27
- Joined: Monday 13 April 2015 23:19
- Target OS: NAS (Synology & others)
- Domoticz version: 3.5033
- Location: Amsterdam, The Netherlands
- Contact:
Re: Is there a manual for Lua?
There is some more info on the wiki here:http://www.domoticz.com/wiki/Events. What I also find useful is the variable changed function next to the device and time scripts. So when a variable is changed I do some checks. Next to that check the examples on the wiki here: http://www.domoticz.com/wiki/Scripts#Lua_Scripts.bbqkees wrote:There is no complete manual for LUA in Domoticz. There is no full list of every option you can use.
My experience is you need to check many examples to get really going.
It's all bits and pieces here and there.
A lot is also 'hidden deep' into forum posts.
LUA scripts trigger either every minute or every device change.
So with the last option you can do a lot fast.
If you can interface your USB and ethernet relays as native hardware or virtual switches the Domoticz framework will work pretty well for standard on/off comparison etc in LUA.
You can read the switch and sensor status and act on change etc.
Who is online
Users browsing this forum: No registered users and 1 guest