aboutsummaryrefslogtreecommitdiff
path: root/diller
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2015-10-15 19:44:08 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2015-10-15 19:44:08 +0200
commit446931c5f5d09a62e167c1754fbe17773eaae6a4 (patch)
tree2e08d6045a83a9957d721c3b3bcdf04bfee9a030 /diller
parent81a276ab7840d6f9c64da80fe5d3bad88fb99b83 (diff)
downloadesp-playground-446931c5f5d09a62e167c1754fbe17773eaae6a4.tar.gz
esp-playground-446931c5f5d09a62e167c1754fbe17773eaae6a4.tar.bz2
esp-playground-446931c5f5d09a62e167c1754fbe17773eaae6a4.tar.xz
esp-playground-446931c5f5d09a62e167c1754fbe17773eaae6a4.zip
wip
Diffstat (limited to 'diller')
-rw-r--r--diller/main.lua23
1 files changed, 18 insertions, 5 deletions
diff --git a/diller/main.lua b/diller/main.lua
index f982f8c..234a84b 100644
--- a/diller/main.lua
+++ b/diller/main.lua
@@ -9,6 +9,8 @@ local P = {}
local inter = require('inter')
local mq = require('mq')
+local properties = {}
+
local function on_cmd(cmd, args)
if not cmd then
return
@@ -44,21 +46,32 @@ local function on_cmd(cmd, args)
if not id then
print("fail status=missing-id")
else
- local name_path = id.."/name"
- mq.subscribe(name_path, function() print('message on '..path) end)
+ property = properties[id]
+ local name_path = id.."/name"
local description_path = id.."/description"
- mq.subscribe(description_path, function() print('message on '..path) end)
+
+ if not property then
+ print("new property: "..id)
+ property = {}
+ properties[id] = property
+ mq.subscribe(name_path, function() print('message on '..path) end)
+ mq.subscribe(description_path, function() print('message on '..path) end)
+ end
if args.value then
local path = id.."/value"
mq.publish(path, args.value)
end
- if args.name then
+ if args.name and property.name ~= args.name then
+ print("publishing name")
mq.publish(name_path, args.name)
+ property.name = args.name
end
- if args.description then
+ if args.description and property.description ~= args.description then
+ print("publishing description")
mq.publish(description_path, args.description)
+ property.description = args.description
end
end
elseif cmd == "publish" then