Page 1 of 1

Switching an ventilator with aqara humidity sensor

Posted: Friday 21 May 2021 17:24
by Fredom
Dear members

The script as it is now works fine,
but there is no check if all values are at a normal level

The 'Humidity sensor 'Garagekamer' is an aqara humidity sensor.
The 'Ventilator wasdroger' is an kaku switch (433.90Mhz)

The script should turn on the 'Ventilator wasdroger' when the temp is above 25 degrees or the humidity is above 55%.
Whichever comes first

Switch off again when the temp drops below 25 degrees or below 55% moisture.
Whichever comes first

Is this possible?

This is mij script now

Code: Select all

return 
{
    on = 
    {
        devices = 
        {
            'Humidity sensor Garagekamer'
        }
    },
    
    logging =
    {
        level  = domoticz.LOG_DEBUG, 
        marker = 'Ventilator wasdroger',
    },

    execute   = function(dz, device)
    local fan = dz.devices('Ventilator wasdroger')
        
       if  (device.name == 'Humidity sensor Garagekamer' and device.temperature >= 25) then
            fan.switchOn()
            fan.switchOff().afterMin(120) 
        end
    end
}
Thanks

Fredom

Re: Switching an ventilator with aqara humidity sensor

Posted: Friday 21 May 2021 19:51
by waaren
Fredom wrote: Friday 21 May 2021 17:24 The script should turn on the 'Ventilator wasdroger' when the temp is above 25 degrees or the humidity is above 55%.
Whichever comes first

Switch off again when the temp drops below 25 degrees or below 55% moisture.
Whichever comes first
Something like below?

Code: Select all

return
{
    on =
    {
        devices =
        {
            'Humidity sensor Garagekamer'
        }
    },

    logging =
    {
        level  = domoticz.LOG_DEBUG,
        marker = 'Ventilator wasdroger',
    },

    execute   = function(dz, device)
    local fan = dz.devices('Ventilator wasdroger')

        if ( device.temperature < 25 or device.humidity < 55 ) and fan.state == 'On' then
            fan.switchOff()
        elseif ( device.temperature >= 25 or device.humidity >= 55 )  and  fan.state == 'Off' then
            fan.switchOn()
        end
    end
}

Re: Switching an ventilator with aqara humidity sensor

Posted: Friday 21 May 2021 20:37
by Fredom
waaren wrote: Friday 21 May 2021 19:51
Fredom wrote: Friday 21 May 2021 17:24 The script should turn on the 'Ventilator wasdroger' when the temp is above 25 degrees or the humidity is above 55%.
Whichever comes first

Switch off again when the temp drops below 25 degrees or below 55% moisture.
Whichever comes first
Something like below?

Code: Select all

return
{
    on =
    {
        devices =
        {
            'Humidity sensor Garagekamer'
        }
    },

    logging =
    {
        level  = domoticz.LOG_DEBUG,
        marker = 'Ventilator wasdroger',
    },

    execute   = function(dz, device)
    local fan = dz.devices('Ventilator wasdroger')

        if ( device.temperature < 25 or device.humidity < 55 ) and fan.state == 'On' then
            fan.switchOff()
        elseif ( device.temperature >= 25 or device.humidity >= 55 )  and  fan.state == 'Off' then
            fan.switchOn()
        end
    end
}
Super it works perfectly.
Thanks again for your help
Fredom