Page 1 of 1

Humidity Increase

Posted: Monday 18 May 2020 21:39
by hanskenpensken
Hi,
I'm still in the learning phase.
But i can't figure out how i can get this wiki DzVents example to get to work.

The script

Code: Select all

{
    on =
    {
        timer = {'every 5 minutes'}
    },
    data =
    {
        previousHumidity = { initial = 100 }
    },
    execute = function(domoticz)
        local bathroomSensor = domoticz.devices('SensorBerging')
        if (bathroomSensor.humidity - domoticz.data.previousHumidity) >= 5) then
            -- there was a significant rise
            domoticz.devices('DampkapLicht').switchOn()
        end
        -- store current value for next cycle
        domoticz.data.previousHumidity = bathroomSensor.humidity
    nd
}
The error

Code: Select all

2020-05-18 21:36:11.480 Error: dzVents: Error: (3.0.2) error loading module 'Script #1' from file '/home/pi/domoticz/scripts/dzVents/generated_scripts/Script #1.lua':
2020-05-18 21:36:11.480 ...domoticz/scripts/dzVents/generated_scripts/Script #1.lua:1: unexpected symbol near '{'

Is here a setting i'm getting wrong?

Thanks!

Re: Humidity Increase

Posted: Monday 18 May 2020 22:07
by niki_lauda
return (in line 1)

And

if (bathroomSensor.humidity - domoticz.data.previousHumidity) >= 5 then

And
end

in the last line!

Re: Humidity Increase

Posted: Tuesday 19 May 2020 8:19
by hanskenpensken
Hi there,
apparently there is a typo in the wiki-example nd needs to be end.
:)

However, i'm still getting the error

Code: Select all


return
{
    on =
    {
        timer = {'every 5 minutes'}
    },
    data =
    {
        previousHumidity = { initial = 100 }
    },
    execute = function(domoticz)
        local bathroomSensor = domoticz.devices('SensorBerging')
        if (bathroomSensor.humidity - domoticz.data.previousHumidity) >= 2) then
            -- there was a significant rise
            domoticz.devices('DampkapLicht').switchOn()
        end
        -- store current value for next cycle
        domoticz.data.previousHumidity = bathroomSensor.humidity
    end
}
The error is still at line 13

Code: Select all

"if (bathroomSensor.humidity - domoticz.data.previousHumidity) >= 2) then"

Code: Select all

'then' expected near ')'

Re: Humidity Increase

Posted: Tuesday 19 May 2020 9:48
by waaren
hanskenpensken wrote: Tuesday 19 May 2020 8:19 I'm still getting the error

Code: Select all

'then' expected near ')'
If you remove the ) after >= 2
it should work