Skip to content

Commit

Permalink
v3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
dbochicchio committed Dec 19, 2023
1 parent 0b9a825 commit d0b91f4
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 25 deletions.
2 changes: 1 addition & 1 deletion I_VirtualAlarmPartition1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
luup.log("VirtualAlarmPartition starting...")

VirtualAlarmPartition1 = require("L_VirtualAlarmPartition1")
alarmSensorWatch = VirtualAlarmPartition1.sensorWatch
alarmSensorWatch = VirtualAlarmPartition1.alarmSensorWatch

return VirtualAlarmPartition1.startPlugin(devNum)
end
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019-2022 Daniele Bochicchio
Copyright (c) 2019-2023 Daniele Bochicchio

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
30 changes: 16 additions & 14 deletions L_VirtualAlarmPartition1.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
------------------------------------------------------------------------
-- Copyright (c) 2019-2022 Daniele Bochicchio
-- Copyright (c) 2019-2023 Daniele Bochicchio
-- License: MIT License
-- Source Code: https://github.com/dbochicchio/Vera-VirtualDevices
------------------------------------------------------------------------
Expand Down Expand Up @@ -41,9 +41,22 @@ function actionRequestPanicMode(devNum, state)
end)
end

function updateStatus(devNum)
local vendorStatus = (lib.getVar(ALARMSID, "VendorStatus", "", devNum)) or ""
local lastUser = (lib.getVar(ALARMSID, "LastUser", "", devNum)) or ""
local state = (lib.getVar(ALARMSID, "DetailedArmMode", "", devNum)) or ""
local simpleState = state ~= "Disarmed" and "Armed" or "Disarmed"

lib.L(devNum, "updateStatus(%1) - (%2,%3,%4,%5)", devNum, vendorStatus, lastUser, state, simpleState)

setVerboseDisplay(devNum,
string.format('Status: %s%s', simpleState, simpleState == "Disarmed" and "" or (" (" .. state .. ")")),
string.format('%s - %s', vendorStatus, lastUser))
end

-- Watch callback
function sensorWatch(devNum, sid, var, oldVal, newVal)
lib.D(devNum, "sensorWatch(%1,%2,%3,%4,%5)", devNum, sid, var, oldVal, newVal)
function alarmSensorWatch(devNum, sid, var, oldVal, newVal)
lib.L(devNum, "alarmSensorWatch(%1,%2,%3,%4,%5)", devNum, sid, var, oldVal, newVal)

if oldVal == newVal then return end

Expand All @@ -56,17 +69,6 @@ function sensorWatch(devNum, sid, var, oldVal, newVal)
end
end

function updateStatus(devNum)
local vendorStatus = (lib.getVar(ALARMSID, "VendorStatus", "", devNum)) or ""
local lastUser = (lib.getVar(ALARMSID, "LastUser", "", devNum)) or ""
local state = (lib.getVar(ALARMSID, "DetailedArmMode", "", devNum)) or ""
local simpleState = state ~= "Disarmed" and "Armed" or "Disarmed"

setVerboseDisplay(devNum,
string.format('Status: %s%s', simpleState, simpleState == "Disarmed" and "" or (" (" .. state .. ")")),
string.format('%s - %s', vendorStatus, lastUser))
end

function startPlugin(devNum)
lib = require("L_VirtualLibrary")
lib.startup(devNum, MYSID)
Expand Down
2 changes: 1 addition & 1 deletion L_VirtualBinaryLight1.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
------------------------------------------------------------------------
-- Copyright (c) 2019-2022 Daniele Bochicchio
-- Copyright (c) 2019-2023 Daniele Bochicchio
-- License: MIT License
-- Source Code: https://github.com/dbochicchio/Vera-VirtualDevices
------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion L_VirtualDoorLock1.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
------------------------------------------------------------------------
-- Copyright (c) 2019-2022 Daniele Bochicchio
-- Copyright (c) 2019-2023 Daniele Bochicchio
-- License: MIT License
-- Source Code: https://github.com/dbochicchio/Vera-VirtualDevices
------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion L_VirtualGenericSensor1.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
------------------------------------------------------------------------
-- Copyright (c) 2019-2022 Daniele Bochicchio
-- Copyright (c) 2019-2023 Daniele Bochicchio
-- License: MIT License
-- Source Code: https://github.com/dbochicchio/Vera-VirtualDevices
------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion L_VirtualHeater1.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
------------------------------------------------------------------------
-- Copyright (c) 2019-2022 Daniele Bochicchio
-- Copyright (c) 2019-2023 Daniele Bochicchio
-- License: MIT License
-- Source Code: https://github.com/dbochicchio/Vera-VirtualDevices
------------------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions L_VirtualLibrary.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
------------------------------------------------------------------------
-- Copyright (c) 2019-2022 Daniele Bochicchio
-- Copyright (c) 2019-2023 Daniele Bochicchio
-- License: MIT License
-- Source Code: https://github.com/dbochicchio/Vera-VirtualDevices
------------------------------------------------------------------------

module("L_VirtualLibrary", package.seeall)

_PLUGIN_NAME = "VirtualDevices"
_PLUGIN_VERSION = "3.0-beta7"
_PLUGIN_VERSION = "3.1"

DEFAULT_ENDPOINT = "http://"
local MYSID = ""
Expand Down Expand Up @@ -423,7 +423,7 @@ function initializeMqtt(devNum, opts)
-- [COMMANDS_SETPOWER] = { Service = SWITCHSID, Variable = "Status" },
for name, item in next, opts do
local mqttCommand = initVar(item.Service, "MQTT_" .. name, '', devNum)
if mqttCommand ~= nil and mqttCommand ~= "" then
if mqttCommand ~= nil and mqttCommand ~= "" and mqttCommand ~= "skip" then
local topic, payload = mqttCommand:gsub("^mqtt://", "") :match "^(.-)/=/(.+)"
subscribeToMqtt(devNum, {opts = item, deviceID = devNum, topic = topic, payload = payload })
end
Expand Down
2 changes: 1 addition & 1 deletion L_VirtualRGBW1.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
------------------------------------------------------------------------
-- Copyright (c) 2019-2022 Daniele Bochicchio
-- Copyright (c) 2019-2023 Daniele Bochicchio
-- License: MIT License
-- Source Code: https://github.com/dbochicchio/Vera-VirtualDevices
------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion L_VirtualSceneController1.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
------------------------------------------------------------------------
-- Copyright (c) 2019-2022 Daniele Bochicchio
-- Copyright (c) 2019-2023 Daniele Bochicchio
-- License: MIT License
-- Source Code: https://github.com/dbochicchio/Vera-VirtualDevices
------------------------------------------------------------------------
Expand Down

0 comments on commit d0b91f4

Please sign in to comment.