smoke alert

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

Moderator: leecollings

Post Reply
User avatar
raymond1972
Posts: 32
Joined: Wednesday 28 February 2018 13:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Contact:

smoke alert

Post by raymond1972 »

Hi all,

I'm trying to get this script to work, but I need a little help.

Code: Select all

return
{
    on =
    {
        devices =
        {
            'Rookmelder woonkamer hitte',
            'Rookmelder woonkamer rook',
            'Rookmelder speelkamer hitte',
            'Rookmelder speelkamer rook',
            'Rookmelder overloop rook',
            'Rookmelder overloop hitte',
            'Rookmelder zolder rook',
            'Rookmelder zolder hitte',
        },
    },
    execute = function(dz, item)
        local rmwh = dz.devices('Rookmelder woonkamer hitte')
        local rmwr = dz.devices('Rookmelder woonkamer rook')
        local rmsh = dz.devices('Rookmelder speelkamer hitte')
        local rmsr = dz.devices('Rookmelder overloop rook')
        local rmzh = dz.devices('Rookmelder zolder rook')
        local rmzr = dz.devices('Rookmelder zolder hitte')       

        if (rmwh.state == 'On' or rmwr.state == 'On' or rmsh.state == 'On' or rmsr.state == 'On' or rmzh.state == 'On' or rmzr.state == 'On') then
            commandArray['Overloop verlichting'] = 'Set Level: 20'
            commandArray['Hal verlichting'] = 'Set Level: 20'
            commandArray['Slaapkamer rolluik'] = 'Set Level: 0'
            commandArray['Group Woonkamer'] = 'Set Level: 100'
		    commandArray['Buitenlamp bijkeuken'] = 'On'
	    	commandArray['Buitenlamp voordeur'] = 'On'
        end

    end
}
But when I test it it does not work properly. I think it has something to do with the device.state but I don't know what else to use to detect the on status for my smoke detectors.

Any help would be appreciated.

Kind regards,
Raymond
HW:Raspberry Pi 3 B, Raspian stretch, Nano, Aeon Labs Aeotec Gen 5 Z-Wave USB
Raspberry Pi 4, Raspian buster, Nano, Aeon Labs Aeotec Gen 5 Z-Wave USB
User avatar
raymond1972
Posts: 32
Joined: Wednesday 28 February 2018 13:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Contact:

Re: smoke alert

Post by raymond1972 »

just modified my code to

Code: Select all

return
{
    on =
    {
        devices =
        {
            'Rookmelder woonkamer hitte',
            'Rookmelder woonkamer rook',
            'Rookmelder speelkamer hitte',
            'Rookmelder speelkamer rook',
            'Rookmelder overloop rook',
            'Rookmelder overloop hitte',
            'Rookmelder zolder rook',
            'Rookmelder zolder hitte',
        },
    },
    execute = function(dz, item)
        local rmwh = dz.devices('Rookmelder woonkamer hitte')
        local rmwr = dz.devices('Rookmelder woonkamer rook')
        local rmsh = dz.devices('Rookmelder speelkamer hitte')
        local rmsr = dz.devices('Rookmelder speelkamer rook')
        local rmor = dz.devices('Rookmelder overloop hitte')
        local rmor = dz.devices('Rookmelder overloop rook')
        local rmzh = dz.devices('Rookmelder zolder hitte')
        local rmzr = dz.devices('Rookmelder zolder rook')       

        if (rmwh.State == 'On') or (rmwr.State == 'On') or (rmsh.State == 'On') or (rmsr.State == 'On') or (rmor.State == 'On') or (rmoh.State == 'On') or (rmzh.State == 'On') or (rmzr.State == 'On') then
            commandArray['Overloop verlichting'] = 'Set Level: 20'
            commandArray['Hal verlichting'] = 'Set Level: 20'
            commandArray['Slaapkamer rolluik'] = 'Set Level: 0'
            commandArray['Group Woonkamer'] = 'Set Level: 100'
		    commandArray['Buitenlamp bijkeuken'] = 'On'
	    	commandArray['Buitenlamp voordeur'] = 'On'
        end

    end
}

but it is still not working
HW:Raspberry Pi 3 B, Raspian stretch, Nano, Aeon Labs Aeotec Gen 5 Z-Wave USB
Raspberry Pi 4, Raspian buster, Nano, Aeon Labs Aeotec Gen 5 Z-Wave USB
hoeby
Posts: 528
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

Re: smoke alert

Post by hoeby »

Commandarray is not used anymore in dzvents.

See the wiki for examples
https://www.domoticz.com/wiki/DzVents:_ ... _scripting
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
hoeby
Posts: 528
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

Re: smoke alert

Post by hoeby »

Try this,

Is "group woonkamer" a device or a group?
In the script it is a device. When it is a group, you have to modify this

Code: Select all

return
{
    on =
    {
        devices =
        {
            'Rookmelder woonkamer hitte',
            'Rookmelder woonkamer rook',
            'Rookmelder speelkamer hitte',
            'Rookmelder speelkamer rook',
            'Rookmelder overloop rook',
            'Rookmelder overloop hitte',
            'Rookmelder zolder rook',
            'Rookmelder zolder hitte',
        },
    },
    execute = function(dz, item)
	    if item.active then
	        dz.devices('Overloop verlichting').dimTo(20)
	        dz.devices('Hal verlichting').dimTo(20)
	        dz.devices('Slaapkamer rolluik').dimTo(0)
	        dz.devices('Group Woonkamer').dimTo(100)
                dz.devices('Buitenlamp bijkeuken').switchOn()
                dz.devices('Buitenlamp voordeur').switchOn()
	    end
	end
}
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest