I look around a long time, but can't find a Manual or Tutorial describing the whole language/commands/variables... Something rudimentär I found in the wiki and Excamples. But isn't there I whole description?? I don't like to ask simle things
My simpified problem:
I have a script getting my energy production of my photovoltaik and my energy consumption. If I have to much production I switch on a heater. In other case I switch it of. So far so good.
I now want to use the timer of the switch to always heat my room from time xx to yy, regardless of power production. But it doesn't work, because my algorithm will switch it off, when there is too less PV power.
My solution will be to ask for the last user who switched it on. And if it was the timer, than I didn't switch it off. But how to get the last user?
Or is there any other idea to handle it?
PVuser wrote: ↑Thursday 08 October 2020 17:21
I look around a long time, but can't find a Manual or Tutorial describing the whole language/commands/variables... Something rudimentär I found in the wiki and Excamples. But isn't there I whole description?? I don't like to ask simle things
The Lua language manual can be found here
For domoticz specific Lua commands you can look in the wiki and in the templates you see when you use the event editor.
Rest of the information can be found on this forum by using the search window. If you cannot find it just ask here and other members will try to help and some will even update the wiki when needed.
My simpified problem:
I have a script getting my energy production of my photovoltaik and my energy consumption. If I have to much production I switch on a heater. In other case I switch it of. So far so good.
I now want to use the timer of the switch to always heat my room from time xx to yy, regardless of power production. But it doesn't work, because my algorithm will switch it off, when there is too less PV power.
If you share the script you use, someone might be able to help with this.
My solution will be to ask for the last user who switched it on. And if it was the timer, than I didn't switch it off. But how to get the last user?
This will be difficult to implement. I would not know how to do that with classic Lua or dzVents other then by introducing a dummy switch which is operated by a user to control the heater
So there is really no way to get the user/source of the event, which is shown in the table using the protocol button of a switch (admin, timer, nameOfScript)??
As a workaround I can't use the comfortable timer button at a switch. I have to implement than the times in my skript
(As a workaround I till tried to play with a userVariable. Establish under Settings-Options-Uservariables a variable 'UserForSwitchHeater'. I set it in my luaScript to 'prog'. Than I made a dzVent script where I wanted to set it to 'external'. But I can't find a way to get this uservarable?? Also I didn't know, if the dzVent script is called, when the switch-timer is the event.)
Your idea @EddyG seems well, but how can I call e.g. a dzVent script in all cases (user=admin | timer | script)? My current simplified flow is as following:
- A normal script with eventType "All" looks for the userVariable nGrid, which is set in a python script. This variable store the current production of my photovoltaic. It's called around every 30 sec.
- Than this script looks, if production-consumption > 0. In this case set heater on. Otherwise set heater off.
- But beside this, I want to manual switch the heater on with domoticz. I have than another switch "manual'. If this is set, the program will not switch off.
Till here it works.
But now I also set in the heater switch times to switch on and off. And this doesn't work, because, when I have low production the script will switch it off immediately. (I don't know how to put a screenshot here, but I think it's clear).
I have seen than, that if I press the button 'protocol' at this switch, there is a column with user and there I can see where switched the button. And this was my question: How to get this? But @waaren told me, that it's not possible. (btw, I found now more questions about this, so is it possible to implement??)
-----------------------------------
Next I can try is to remove the normal script and port everything (without python) to dzVents. But the main question is than always - or especially there - how can I call another dzVent script, so I can handle the variable setting. My thought will be than:
- dzVent with event device (user switched in domoticz) --> call setHeaterUserTo('user')
- dzVent with event all check for overproduction --> call setHeaterUserTo('prog')
setHeaterUserTo(user) will set a global variable, which than I can use to decide, if program is allowed to change state of heater switch
Questions:
1) where to implement setHeaterUserTo(user) and how to call it? General question: How can I implement and use functions/subroutines ?
2) is event type device called, when the timer of the switch starts and stops? How can I differentiate between start and stop (on/off)?
PVuser wrote: ↑Saturday 10 October 2020 14:46
Questions:
1) where to implement setHeaterUserTo(user) and how to call it? General question: How can I implement and use functions/subroutines ?
2) is event type device called, when the timer of the switch starts and stops? How can I differentiate between start and stop (on/off)?
I'm working on a native dzVents implementation to get the username (or script) that updated a switch. PR will probably ready early next week. If @gizmocuz accepts the PR it will then be in one of the next Beta's
btw. You can attach screenshots to a post by clicking the Attachments button below your edit window and choose 'add files'