Subversion Repositories rld.domoticz

Rev

Blame | Last modification | View Log | Download

-- local device id's, only used in this script
local cDevST630Alarm = 210 --ST630 hal
local cDevVirtAlert =  211


return {
  on = {
    devices = {cDevST630Alarm},
    system = {'start'},
    -- timer = { 'every 1 minutes' },
  },
  logging = {
    --level = domoticz.LOG_DEBUG + domoticz.LOG_INFO,
    level = domoticz.LOG_ERROR,
    marker = 'ST630-Bijkeuken',
  },
  execute = function(domoticz, triggeredItem)
      
      if (triggeredItem.isDevice) then
          domoticz.log('Device ' .. triggeredItem.name .. ' was changed', domoticz.LOG_INFO) --domoticz.LOG_FORCE
        end
        
        -- Mark defaulr alert level as normal
        AlertLevel = 1

    if (triggeredItem.isSystemEvent) then

        domoticz.log('System event handling', domoticz.LOG_DEBUG)
        
        if (triggeredItem.type == 'start')  then
        
            domoticz.devices(cDevVirtAlert).updateAlertSensor(0, 'not yet queried..')
        end
    end
        
        domoticz.log('Device ' .. domoticz.devices(cDevST630Alarm).name .. ' has value: ' .. tostring(domoticz.devices(cDevST630Alarm).nValue), domoticz.LOG_INFO) --domoticz.LOG_FORCE
        -- set the alarm level/text on the virtual device
        -- ALERTLEVEL_GREY, ALERTLEVEL_GREEN, ALERTLEVEL_YELLOW, ALERTLEVEL_ORANGE, ALERTLEVEL_RED
        if (domoticz.devices(cDevST630Alarm).nValue ~= 0) then
            AlertLevel = 4
        end
            
        domoticz.devices(cDevVirtAlert).updateAlertSensor(AlertLevel, domoticz.devices(cDevST630Alarm).state)
  end
}