Jump to content

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

Posted

H, Can somebody to help me?

 

I want to create QA for obtaining consumption from DAIKIN air conditioning. I can read the data, but I can't organize them into a table and get data -  Total consumption for this year and last year and for individual months.

 

response is data from DAIKIN - consumption for each month for this and last year for heating and cooling. 

How I can calculate the total consumption for this year and the consumption for the last year and the consumption for each month this year?

 

response from daikin is string:

 "ret=OK,curr_year_heat=0/0/0/0/2/0/0/0/0/0/0/0,prev_year_heat=0/0/6/21/0/7/0/0/0/0/0/0,curr_year_cool=37/34/38/38/59/57/0/0/0/0/0/0,prev_year_cool=37/34/31/14/37/61/105/117/37/37/36/36"

Individual numbers in the string represent consumption values for a month

I create this but I can't sort it and count it at the end. Somebody to help me with that.

 

function QuickApp:org()
response =  "ret=OK,curr_year_heat=0/0/0/0/2/0/0/0/0/0/0/0,prev_year_heat=0/0/6/21/0/7/0/0/0/0/0/0,curr_year_cool=37/34/38/38/59/57/0/0/0/0/0/0,prev_year_cool=37/34/31/14/37/61/105/117/37/37/36/36"
print(response)
self:organize_answer(response)
end
 
function QuickApp:organize_answer(answer)
    local Table = {}
             for v in answer:gmatch('([^,]+)'do
                table.insert(Table, v)
               print(Table,v)
               self:sum(v)
              end
end
 
 function QuickApp:sum(line)
  local total = 0
  local myTable = {}
  for str in line:gmatch("/(%d+)" ) do 
  table.insert(myTable, str)
   total = total + tonumber(str)
  end
   print(total)
  end
 
This is result for LUA: Sum of  Number 2 and 226 is This Year consuption so 2+226 , and sum of Number 34 and 545 is last Year Consuption. 
 

Please login or register to see this attachment.

 

2 answers to this question

Recommended Posts

  • 0
Posted

Please login or register to see this code.

 

  • Like 1
  • 0
  • Inquirer
  • Posted
    13 hours ago, jgab said:

    Please login or register to see this code.

     

    Thanks

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...