dzVents, i don't get it at all

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
tlpeter
Posts: 191
Joined: Wednesday 26 November 2014 18:43
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

dzVents, i don't get it at all

Post by tlpeter »

I find it hard to convert my lua script and really i do not get it.
For me it is way harder but that is probably because i am not a coder.
I probably need to learn this but it is not easy to do this.

I converted two easy scripts like turning on light 2 when light 1 is turned on and otherwise so that part worked.
I also succeeded to turn off a light after a couple of minutes (kids leave it on all the time)
But now i want to try to convert my ugliest and biggest script to dzVents but i am stuck in the beginning.

I create a very dirty but working script to control my mechanical ventilation by humdity or manual by a switch.
I also use a variable for that.
Now i am trying to get the humidity from the hum/temp sensor but all i get is an error.
I am able to show the readings of the sensor but there is also the temp in it ofcourse.

How do i build this?
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: dzVents, i don't get it at all

Post by dannybloe »

Well, as a start you could post the dzVents script that you tried and the error you get.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
tlpeter
Posts: 191
Joined: Wednesday 26 November 2014 18:43
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: dzVents, i don't get it at all

Post by tlpeter »

Well i found this:

Code: Select all

return {
    active = true,
    on = {
        timer = {'every 5 minutes'}
    },
    data = {
        previousHumidity = { initial = 100 }
    },
    execute = function(domoticz)
        local bathroomSensor = domoticz.devices('BathroomSensor')
        if (bathroomSensor.humidity - domoticz.data.previousHumidity) >= 5) then
            -- there was a significant rise
            domoticz.devices('Ventilator').switchOn()
        end
        -- store current value for next cycle
        domoticz.data.previousHumidity = bathroomSensor.humidity
    end
}
I edited the 'Bathroomsensor' and 'Ventilator' but that doesn't do anything at all.
I found a little error where the ) after the >=5 is causing an error so i removed that.

Nothing happens with this script, no error and no turning on the ventilator.

I have a DHT22 whih measures temp and hum.
I tried setting values for the humidity and then it switches the Ventilator but that is ugly like i have now with the default lua script.
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: dzVents, i don't get it at all

Post by dannybloe »

Well, you could start by printing the current humidity and the previousHumidity at the beginning of the script and see what their values are.

Code: Select all

print(tostring(domoticz.devices('BathroomSensor').humidity))
print(tostring(domoticz.data.previousHumidity))
Neither of those should be nil at any time.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
tlpeter
Posts: 191
Joined: Wednesday 26 November 2014 18:43
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: dzVents, i don't get it at all

Post by tlpeter »

I do get values now and i managed to get something switched so it is looking good.
I must say that i have a learning curve but i think i am starting to get it.
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: dzVents, i don't get it at all

Post by dannybloe »

I'm curious what you find difficult and what you are missing in the documentation.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
tlpeter
Posts: 191
Joined: Wednesday 26 November 2014 18:43
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: dzVents, i don't get it at all

Post by tlpeter »

What i am missing is when you need to use which command.
For code programmers this is probably very easy and very logical.
I just sometimes need a little start and then i do not see the logic all the time.
tlpeter
Posts: 191
Joined: Wednesday 26 November 2014 18:43
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: dzVents, i don't get it at all

Post by tlpeter »

Here i have an example:

level: Number. For dimmers and other 'Set Level..%' devices this holds the level like selector switches.

What do i use for setting a level for a selector switch?
Now i use:

domoticz.devices('Ventilatie schakelaar stand 2').switchOn()

I want to select a level for a selector switch like 20%
I also want it to go back to 10% after a minute or 2 minutes.
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: dzVents, i don't get it at all

Post by dannybloe »

Well yeah. But you could start with blockly. But in the end that's programming as well. So. Programming is fun. Learn it :)
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
tlpeter
Posts: 191
Joined: Wednesday 26 November 2014 18:43
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: dzVents, i don't get it at all

Post by tlpeter »

I don't like blockly although i use for very simple timed stuff but i am going to convert them too.
Can you tell me the selector switch part i asked? i cannot get that working and i do not understand the wiki for that part.
Thanks in advance.
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: dzVents, i don't get it at all

Post by dannybloe »

If you have a selector switch you have to use the switchSelector() method.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest