My problem: I want to change the "modified" of a global variable to trigger scenes as well, because if you assign global variable the same value it had before, Fibaro does not change the modified entry.
Here is my global variable used to document if I this person is at home or somewhere else.
{ "name": "Christian", "value": "Office", "readOnly": false, "isEnum": true, "enumValues": [ "Office", "Sport", "Home", "ontheway" ], "created": 1644958957, "modified": 1645209384 }
We all know the geofencing works only properly if app is active on the smartphone. So it might happen variable still reports "Home" although the Person is not at home. Now the person get's home and geofence switch the Variable to "Home" again.
This will not trigger the "modified" because it's still the same value. This means. the globals Person I am using in scenes as trigger does not trigger, beause vaue remains the same.
So my intention was to change the "modified". I receive a result 200 (means works), but the "modified" does not change, although I am able to change the "value" for debugging test.
Here is the LUA, and my question is, why does it work for Persondata.value (value change) and does not work for Persondata.modified (value remains the original one)
local value, modified = fibaro:getGlobal("Christian")
print(os.date("%c", modified))
local Person = "Christian"
local Persondata = api.get('/globalVariables/'..Person)
Persondata.value = "Golf"
print(os.date("%c", Persondata.modified))
Persondata.modified = tonumber(os.time() - 1)
print(os.date("%c", Persondata.modified))
PersonJSON = json.encode(Persondata)
local http = net.HTTPClient()
http:request("http://127.0.0.1:11111/api/globalVariables/"..Person, {
options = {
method = 'PUT',
headers = {},
data = PersonJSON,
timeout = 10000
},
success = function(response)
local result = response.data;
if response.status == 200 or response.status == 201 then
fibaro:debug(response.status)
-- Display('lightgreen', Text, 999)
else
fibaro:debug(response.status)
-- Display('red','Error: ' ..response.status.. ' - Zugriff verweigert',0)
end
end,
error = function(err)
fibaro:debug(err)
--Display('red','[ERROR] ' .. err, 0)
end
})
fibaro:sleep(6000)
value, modified = fibaro:getGlobal("Christian")
print(os.date("%c", modified))
print(value)
and the debug is: