Page 1 of 1

Blocky to DzVents Bathroom Fan

Posted: Friday 01 May 2020 22:11
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')

Re: Blocky to DzVents Bathroom Fan

Posted: Friday 01 May 2020 23:01
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
}

Re: Blocky to DzVents Bathroom Fan  [Solved]

Posted: Tuesday 05 May 2020 20:14
by wouterlet
Thanks, that works great like that!