Skip to content

Commit b1f35a3

Browse files
Add thing property methods
1 parent cfdb029 commit b1f35a3

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

lha/EngineThing.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ return class.create(Thing, function(engineThing, super)
5252
function engineThing:setPropertyValue(name, value)
5353
local property = self:getProperty(name)
5454
if property then
55-
if not property:isReadOnly() then
55+
if property:isWritable() then
5656
self:updatePropertyValue(name, value)
5757
else
58-
logger:warn('Cannot set read-only property "'..name..'"')
58+
logger:warn('Cannot set property "'..name..'"')
5959
end
6060
else
6161
logger:warn('Cannot set unknown property "'..name..'"')
@@ -68,7 +68,7 @@ return class.create(Thing, function(engineThing, super)
6868
if isValidValue(value) then
6969
local path = self.thingId..'/'..name
7070
local prev
71-
if not property:isWriteOnly() then
71+
if property:isReadable() then
7272
if self:isArchiveData() and not property:isConfiguration() then
7373
self.engine.dataHistory:aggregateValue(path, value)
7474
end

lha/ThingProperty.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ return require('jls.lang.class').create(function(thingProperty)
3838
return self.metadata.writeOnly == true
3939
end
4040

41+
function thingProperty:isReadable()
42+
return self.metadata.writeOnly ~= true
43+
end
44+
45+
function thingProperty:isWritable()
46+
return self.metadata.readOnly ~= true
47+
end
48+
4149
function thingProperty:isConfiguration()
4250
return self.metadata.configuration == true
4351
end

0 commit comments

Comments
 (0)