@Home LUA Scripting

  • RFXtrx433XL USB-controller
    for sending and receiving signals wireless over the 433Mhz band.
  • Raspberry PI 4B, 4GB
local key    = 'Nyckelknippa'
local alarm  = 'AlarmRunning'

commandArray = {}

--- Larma av med Fjärrkontroll nyckelknippa (1 klick)
if( devicechanged [key] == 'On' ) then
    print("\n\n*** Unlock with key\n")
    commandArray[alarm]                     = 'Off'
    commandArray['Domoticz Security Panel'] = 'Disarm'
    commandArray['Scene:Grönt ljus']        = "On"
    commandArray['Scene:Varmt ljus']        = "On AFTER 5"

--- Larma på med Fjärrkontroll nyckelknippa (2 klick)
elseif( devicechanged [key] == 'Off' ) then
    print("\n\n*** Lock with key\n")
    commandArray['Scene:Mysbelysning']      = "On"
    commandArray['Scene:Blombelysning']     = "On AFTER 20"
    commandArray['Domoticz Security Panel'] = 'Arm Away'
    commandArray[alarm]                     = 'On AFTER 30'
end

return commandArray
local motion = 'Fibaro Home Security'
local magnet = 'Magnet 1'
local alarm  = 'AlarmRunning'

commandArray = {}

--- Sensorer larmar
if( devicechanged [magnet] == 'On' or devicechanged [motion] == 'On' ) then

    --- Larmet är aktiverat
    if( globalvariables['Security'] == 'Armed Away') then
        print("\n*** Alarm triggered on Armed Away")

        if( otherdevices[alarm] == "On") then
            commandArray ['SendNotification'] = 'Alarm: Motion detected !!'
            commandArray[alarm] = 'Off'
            commandArray['Scene:Mysbelysning'] = "On"
        end
   end

    --- Larmat i hemma-läge
    if( globalvariables['Security'] == 'Armed Home' ) then
        print("\n*** Alarm triggered on Armed Home")
       ---commandArray ['SendEmail'] = 'Alarm' ..tostring (mydevice)
   end

end

return commandArray