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


hysteresis code. for example for thermostat


hater

Recommended Posts

subj

(c) 

Please login or register to see this link.

 

Please login or register to see this code.

 

Edited by hater
Link to comment
Share on other sites

  • hater changed the title to hysteresis code. for example for thermostat
  • Topic Author
  • Please login or register to see this code.

     

    Please login or register to see this attachment.

    Edited by hater
    Link to comment
    Share on other sites

  • Topic Author
  • Please login or register to see this code.

     

     

    Please login or register to see this attachment.

    Edited by hater
    Link to comment
    Share on other sites

  • Topic Author
  •         -- don't use the current reading but average it out over
            -- the past <SMOOTH_FACTOR> readings (data smoothing) to get rid of noise, wrong readings etc
     

    add some useful functions

    Please login or register to see this code.

     

    and add code improvements

     

    Please login or register to see this code.

     

    • Like 2
    Link to comment
    Share on other sites

    Thanks, this is very useful code and nice to have in the library.

     

    Another similar piece is to calculate a sliding average, i.e . give me the average of the last 10 values. It gives a smoothed value instead of a jumpy value , like power measurements usually are.

    Normally we do this by saving the n last values and return the average of this - the problem is that we need a buffer and recalculate the sum.

    There is a neat trick without a buffer of values that is not exactly a sliding average but a good approximation.

    What we do is that we deduce the average from the current sum before adding the new value. (we only need to keep track of n and sum)

     

    Please login or register to see this code.

     

    Edited by jgab
    • Thanks 1
    Link to comment
    Share on other sites

  • Topic Author
  • 10 hours ago, jgab said:

    Thanks, this is very useful code and nice to have in the library.

    Jan, and thank you, as well, it's your school :) 

    Link to comment
    Share on other sites

  • Topic Author
  • Jan, btw. another minor problem.

    smoothFilter like your or my monster ? smoothFilter do not guaranty with satiation below

     

    10:20:00 15*C

    [no data from sensor]

    11:00:00 11*C

     

    in this case we should ignore to use smoothFilter cuz accumulating data with different time is tricky, IMHO 

    Link to comment
    Share on other sites

    2 hours ago, hater said:

    Please login or register to see this code.

    able to reset, @jgab

     

    Alternatively

    Please login or register to see this code.

     

    • Like 1
    • Thanks 1
    Link to comment
    Share on other sites

    2 hours ago, jgab said:

     

    Alternatively

    Please login or register to see this code.

     

    Nice function

    It could be perfect to have similiar function for moving average (where is also time how long values inluence final number)

    Link to comment
    Share on other sites

  • Topic Author
  • 2 hours ago, petrkl12 said:

    moving average

    Please login or register to see this code.

    Please login or register to see this attachment.

    • Like 1
    Link to comment
    Share on other sites

    On 10/24/2021 at 2:22 PM, petrkl12 said:

    Nice function

    It could be perfect to have similiar function for moving average (where is also time how long values inluence final number)

    Yes, but to use the same trick (approximation without buffer) it would be easiest if the value was sampled at regular intervals.

    Like this:

    Please login or register to see this code.

    Otherwise a buffer is needed and re-summing for every average calculation...

    Edited by jgab
    • Thanks 1
    Link to comment
    Share on other sites

  • Topic Author
  • 10 hours ago, jgab said:

    Please login or register to see this code.

     

    10 hours ago, jgab said:

    Please login or register to see this code.

    warning.

    setInterval in ms NOT min.

    so pay attention mul on 1000

    • Thanks 1
    Link to comment
    Share on other sites

  • Topic Author
  • and then some.

    IMHO

    1) do not need to push the same value to function. only if value a new one according to stamp from device

    2) we should use stamp from function fibaro.get 

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