Humidity Increase

Moderator: leecollings

Post Reply
hanskenpensken
Posts: 5
Joined: Saturday 02 February 2019 9:18
Target OS: -
Domoticz version:
Contact:

Humidity Increase

Post 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!
niki_lauda
Posts: 118
Joined: Saturday 31 August 2013 14:48
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Eindhoven (NL)
Contact:

Re: Humidity Increase

Post by niki_lauda »

return (in line 1)

And

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

And
end

in the last line!
hanskenpensken
Posts: 5
Joined: Saturday 02 February 2019 9:18
Target OS: -
Domoticz version:
Contact:

Re: Humidity Increase

Post 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 ')'
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Humidity Increase

Post 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
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest