Welcome to Smart Home Forum by FIBARO
Dear Guest,
as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.
As a member you can:
- Start new topics and reply to others
- Follow topics and users to get email updates
- Get your own profile page and make new friends
- Send personal messages
- ... and learn a lot about our system!
Regards,
Smart Home Forum by FIBARO Team
Question
cwil 0
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:
Please login or register to see this image.
/monthly_2022_02/image.png.e8342b2d1cbfd892d908cfe5b6e9089f.png" />Link to comment
Share on other sites
1 answer to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.