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


Energy consumption measurement - pulse counting


michal_pu

Recommended Posts

4 hours ago, Daniel_Gomes said:

Please login or register to see this link.

 

Please login or register to see this link.

 You got something out of this. I am trying to do the same, but I want to know if the values will appear in m3

Probably 1 ticks = 10 l

Edited by 10der
Link to comment
Share on other sites

  • 1 year later...

@michal_pu Did you somehow solve the QA for converting pulses to flow? I have the same problem, but I can't find a solution and I can't write a QA.

Link to comment
Share on other sites

  • 3 weeks later...
  • 2 months later...

Is this topic still alive? I have been playing with water meter that has a magnetis switch and with that i can make pulse that smart implant detects. Mine water meter has 1pulse = 1liter. So i made a little QA with it because i was learning to do LUA programing. i used variables to store the pulses and calculations. I used scenes for counting the pulses and reset them and i use QA to display values

 

With my QA i can see the calculated asumed watter flow per hour (it counts pulses every 30sec and multiplies with 120)

it will also display max calculated average flow per day and display hour when it happened.

then qa also displays liters counted in the curent hour, day, week and month and it also stores the value of previous hour, day, week and month.

I also made it to display the calculated aused flow on the dashboard.

 

now i dont think u will figure out what is what in the lua cose of the QA but that just makes sence to me ._.

 

Please login or register to see this image.

/monthly_2023_05/image.png.62bf516437e32447e3928507528e06d2.png" />

 

image.png.d9828da89714491754c02528b3c2be68.png

 

image.png.9b0bf81eb8ddd97dae12c6bc9bb4731b.png

 

    local maxFlow = "0"
    HighFlowTime = "0"
 
function QuickApp:onInit() -- aktivacija funkcij ob zagonu QA
    --self:timeLoop1()
    self:timeLoop2()
    self:updateLabels()
    self:updateValue()  
end
 
function QuickApp:timeLoop1() -- Funkcija za nastavitev delaya 10000ms
    fibaro.setTimeout(10000function()  -- časovni zamik v ms
        self:timeLoop1()
    end--po delay izvedi naslednje funkcije:
    --self:updateLabels() 
    --self:maxFlow()  
end
 
function QuickApp:timeLoop2() -- Funkcija za nastavitev delaya 30000ms
    fibaro.setTimeout(30000function()  -- časovni zamik v ms
        self:timeLoop2()
    end--po delay izvedi naslednje funkcije:
    self:averageCalc()
    self:updateValue()
    self:updateLabels() 
    self:maxFlow()  
end
 
function QuickApp:updateLabels()    --posodobitev vrednosti v label
                                    --Velikost besedila: <font size = \"1\"> TEXT </font>
                                    --Barva besedila: <font color=\"#FF0000\"> TEXT </font>
                                    --velikost + barva: <font size = \"2\" color=\"#FF0000\"> TEXT </font>
    local labelText = ""
    labelText = labelText .."<font size = \"2\"> Trenutna poraba na uro: </font>" .."<font color=\"#7ECC49\">" ..fibaro.getGlobalVariable("RacunanjePorabeNaUro") .."</font>" .." L/h" .."\n"
    labelText = labelText .."Najvišja poraba na dan: " .."<font color=\"#7ECC49\">" ..maxFlow .."</font>" .." L/h" .." Ob uri: " .."<font color=\"#7ECC49\">"  ..HighFlowTime .."</font>".."\n"
    labelText = labelText .."\n"
 
    labelText = labelText .."<font size = \"2\"> Trenutna poraba vode </font> (v litrih)" .."\n" 
    labelText = labelText .." Ura: " .."<font color=\"#7ECC49\">" ..fibaro.getGlobalVariable("PulsePerHour") .."</font>" .." - "                                .." Dan: " .."<font color=\"#7ECC49\">" ..fibaro.getGlobalVariable("PulsePerDay") .."</font>"  .." - "                                                          .." Teden: " .."<font color=\"#7ECC49\">" ..fibaro.getGlobalVariable("PulsePerWeek") .."</font>" .." - "                                                        .." Mesec: " .."<font color=\"#7ECC49\">" ..fibaro.getGlobalVariable("PulsePerMonth") .."</font>" .."\n"
    labelText = labelText .."\n"
 
    labelText = labelText .."<font size = \"2\"> Poraba vode prejšnjega obdobja </font> (v litrih)" .."\n"
    labelText = labelText .." Ura: " .."<font color=\"#7ECC49\">" ..fibaro.getGlobalVariable("PulseLastHour") .."</font>" .." - "                               .." Dan: " .."<font color=\"#7ECC49\">" ..fibaro.getGlobalVariable("PulseLastDay") .."</font>" .." - "                                                          .." Teden: " .."<font color=\"#7ECC49\">" ..fibaro.getGlobalVariable("PulseLastWeek") .."</font>" .." - "                                                       .." Mesec: " .."<font color=\"#7ECC49\">" ..fibaro.getGlobalVariable("PulseLastMonth") .."</font>" .."\n"
 
    self:updateView("label""text", labelText)
end
 
function QuickApp:averageCalc() --kalkulacija porabe na uro
    X = fibaro.getGlobalVariable("PulsePerHourCalc")
    Calc=X*120 --pomnoži X (št pulsov) s 120 (120 zaradi meritve usakih 30sec)
    --self:debug(Calc)
    
    fibaro.setGlobalVariable("RacunanjePorabeNaUro", tostring(Calc)) --set variable RacunanjePorabeNaUro (izracunana vrednost porabe v eni uri)
    fibaro.setGlobalVariable("PulsePerHourCalc""0"--set variable PulsePerHourCalc na 0
end
     
function QuickApp:maxFlow()  -- funkcija za prikaz največjega pretoka v dnevu
    Flow = fibaro.getGlobalVariable("RacunanjePorabeNaUro")
        --print("Flow " ..Flow)
        --print("maxFlow " ..maxFlow)
    if (Flow >= maxFlow) and (Flow > "0"then
        maxFlow = Flow 
        HighFlowTime = os.date("%H:%M")
        --self:debug("currentTime ", HighFlowTime)
        self:updateProperty("log""Max " ..maxFlow .." L/h " ..HighFlowTime)
    end
    if (os.date("%H:%M") == "00:00"and (maxFlow > "0"then  --vsakodnevna reset funkcija Časa ter Vrednosti Najvišje porabe na dan
        maxFlow = "0"
        HighFlowTime = "00:00"
        --print("Time Reset")
    end
end 
 
function QuickApp:updateValue() -- izpis vrednosti izracunane porabe v eni uri na dashobard quickapp-a
    temp = fibaro.getGlobalVariable("RacunanjePorabeNaUro") + 0.0 --pretvorba variable v pravilni data tip
    self:updateProperty("value", temp)
    self:updateProperty("unit"" L/h")
end

 

Link to comment
Share on other sites

  • 1 month later...

Hi JureZ,
your interesting solution of the QA water meter would be useful to me. It would be possible to post the scene you use to load the impulse and connect to the QA.

Link to comment
Share on other sites

Sure. Here is the lua scene that counts the values every time the sensor sends pulse. I did it so lua scenes stores values into variables. and then those variables are used in QA.

Please login or register to see this attachment.

 

And this is lua scene for reseting the count and also setting previous values so i can see howmany liters were used last hour,day,week,month

 

Day reset:

Please login or register to see this attachment.

 

Hour reset:

Please login or register to see this attachment.

Week reset:

Please login or register to see this attachment.

Month reset:

Please login or register to see this attachment.

Link to comment
Share on other sites

Hi 

Please login or register to see this link.

 

Please login or register to see this link.

thank you so much for posting your lua scenes.

  • Thanks 1
Link to comment
Share on other sites

Join the conversation

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

Guest
Reply to this topic...

×   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...