Switching an ventilator with aqara humidity sensor Topic is solved

Moderator: leecollings

Post Reply
Fredom
Posts: 160
Joined: Saturday 19 September 2020 21:02
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Location: Krimpen aan den IJssel
Contact:

Switching an ventilator with aqara humidity sensor

Post 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
Yours sincerely,
Fred

Rasberry Pi 3B+ - Debian Trixie - Domoticz 2025.2
RFLink - RFXCom - Zigbee (CC2531)
P1 Smart Meter - KaKu
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Switching an ventilator with aqara humidity sensor

Post 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
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Fredom
Posts: 160
Joined: Saturday 19 September 2020 21:02
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Location: Krimpen aan den IJssel
Contact:

Re: Switching an ventilator with aqara humidity sensor

Post 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
Yours sincerely,
Fred

Rasberry Pi 3B+ - Debian Trixie - Domoticz 2025.2
RFLink - RFXCom - Zigbee (CC2531)
P1 Smart Meter - KaKu
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest