Blocky to DzVents Bathroom Fan  [Solved]

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

Moderator: leecollings

Post Reply
wouterlet
Posts: 109
Joined: Tuesday 02 October 2018 20:52
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Blocky to DzVents Bathroom Fan

Post by wouterlet »

I have an Aeotec Multisensor 6, this gives a device Temp/Hum.
For this script I only need the humidity, but I can't see how to select this. See my code underneath, I also tried device.humidity, but it gives the same result. The subtype of the device is WTGR800.

Code: Select all

return {
	on = {
		devices = {'Temp/Hum Badkamer'}
	},
	execute = function(domoticz, device)
    if device.hum('Temp/Hum Badkamer') > 60 then
    dz.devices('Afzuiging Badkamer').switchOn()
    end
    if device.hum('Temp/Hum Badkamer') < 60 then
    dz.devices('Afzuiging Badkamer').switchOff().afterMin(15)
	end
end
}
This gives the following error in my log:

2020-05-01 21:18:38.175 Error: dzVents: Error: (3.0.2) An error occurred when calling event handler Afzuiging Badkamer DzVents
2020-05-01 21:18:38.175 Error: dzVents: Error: (3.0.2) ...dzVents/generated_scripts/Afzuiging Badkamer DzVents.lua:6: attempt to call a number value (field 'humidity')
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Blocky to DzVents Bathroom Fan

Post by waaren »

wouterlet wrote: Friday 01 May 2020 22:11 This gives the following error in my log:
2020-05-01 21:18:38.175 Error: dzVents: Error: (3.0.2) ...dzVents/generated_scripts/Afzuiging Badkamer DzVents.lua:6: attempt to call a number value (field 'humidity')
Can you try this

Code: Select all

return
{
    on = 
    {
        devices = 
        {
            'Temp/Hum Badkamer',
        },
    },
    
    logging =
    {
        level = domoticz.LOG_DEBUG, -- change to domoticz.LOG_ERROR when all OK
        marker = 'badkamer humidity',
    },
    
    execute = function(dz, item)
        local afzuiging = dz.devices('Afzuiging Badkamer')
        
        if item.humidity > 60 then
            afzuiging.switchOn().checkFirst()
        elseif afzuiging.state ~= 'Off' then 
            -- afzuiging.switchOff().afterMin(15) -- This will re-schedule the switchoff many times during the 15 minutes
            afzuiging.switchOff()
        end
    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
wouterlet
Posts: 109
Joined: Tuesday 02 October 2018 20:52
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blocky to DzVents Bathroom Fan  [Solved]

Post by wouterlet »

Thanks, that works great like that!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest