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
Momos 103
Hi ,
I have a problem with a piece of LUA code and i'd like to ask for help from the LUA gurus
Please login or register to see this image.
/emoticons/default_smile.png" alt=":)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" />Basically what i'm trying to achieve is store some values in an array like array = {January = 1, February = 2} . The number after the equal sign is taken from a global variable that changes as a water meter runs every 100 liters. I've got the code that reads the meter and increments the global variable by 0.1 sorted out.
The scene has as trigger the UBS value that reads the meter - every time the UBS is 1 it increments the global variable by 0.1
So far so good.
Storing the data is the problem: I'd like to store the data in an array like above. The problem is that every time the scene restarts the array will be empty again. I want it to be populated with each month and the value.
Also, the scene is started multiple times per day so the code should check if that month is already in the array and if it is just rewrite the value, otherwise insert the month and the value in the array.
I hope i was clear enough
Please login or register to see this image.
/emoticons/default_smile.png" alt=":)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" />My code which at this point sucks
Please login or register to see this image.
/emoticons/default_sad.png" alt=":(" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" />Please login or register to see this code.
Edited by Momos16 answers 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.