Control Fan with Lua

Moderator: leecollings

Post Reply
Piacco
Posts: 70
Joined: Friday 14 November 2014 9:33
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Control Fan with Lua

Post by Piacco »

Hello i'am trying to control my fan with LUA.
I use this Lua script: https://www.domoticz.com/wiki/Humidity_control

Instead of of humidity i will control my fan with air quality, so i changed SENSOR_NAME = 'Co2 living room'
But then i get the error LUA: current is 0 or nil. Skipping this reading.
The C02 value comes from a Netatmo wheaterstation.

Tanks for your help.

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

Re: Control Fan with Lua

Post by tlpeter »

You could try this dzvets script:

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
}
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest