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


Recommended Posts

Hello. I have been using the new features of ER4 for several days now, namely working with the climate panel and very flexible scenes. Thank you very much again.

 

Now came the idea of whether it is possible to do something similar with the energy panel. namely:
through the API to extract, for example, the number of kilowatts for a certain period of time.

 

It would be very cool for example:
1) at the end of the week or at the end of the month to send a report \ log \ telegrams on the number of kilowatts used
2) or set up a scene that if the number of kilowatts used is already more than 3,000 kilowatts, then give a warning (in different countries there is a limit on the number of kilowatts per month) ...

 

it is physically impossible to do anything like this in Fibaro's native scenes, and the energy panel is good, but not informative..it is better to generate reports for yourself, the ones you need ...

Link to comment
Share on other sites

  • Topic Author
  • I think we can do some of it with existing code.

    If we define

    Please login or register to see this code.

    This run a rule every morning at 07:00 to check the production and consumption values for the house and last 30 days.

    We set some rule variables like eConsumption to the values, and we have the variables declared as trigger variables.

    This means that they can be used to trigger rules when they change value.

    Like

    Please login or register to see this code.

     

    We could run the rule every hour too if we want

    Please login or register to see this code.

     

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

    reached the computer and ER4 ...
    I copied the new function to the header, no errors were issued ...
    then in the rule
    rule ([[@ {00: 07, catch} =>
    error ...

    we want to extract data at 7 am, and here at 7 minutes after midnight ... then a grammatical error))

     

    but this rule I did not understand ... what should be the ending here?

    We could run the rule every hour too if we want

    rule ("@@ 01:00 => local e = energyConsumption (....

    • Thanks 1
    Link to comment
    Share on other sites

    I made the rule work at 10.00 ...
    it worked and even counted some 152 kW(according to ideas) ...
    but here it is a little inconvenient, because the rule counts for the last 30 days ... but we are interested in exactly what we had this month ... an idea, as it were: I don’t need to know what happened from 10/26/21 to 11/26/26 .21 .... it is more correct and logical to count from the beginning of the month ...
    ideally, to make a local variable, bind it to the native fibaro scene, which we can run from the native application on the mobile phone ...

    and then, for example, let's say I 12/18/21 wanted to check how much electricity I used -> the scene changed the variable - > ER4 calculated kW -> ER4 sent us data in telegram ...

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

  • Topic Author
  • To get from the first day  of the month.

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    7 hours ago, jgab said:

    To get from the first day  of the month.

    Please login or register to see this code.

     

    and so ... again for non-programmers ...

     

    in the ER4 header I left the function
    1) which extracts through the API in general some data
    2) a function that counts from the 1st number

     

    --3) Energy panel function
       function energyConsumption (time)
        return api.get ("/ energy / consumption / summary? period =" .. os.date ("% Y-% m-% d", time))
      end

      Util.defTriggerVar ('eProduction')
      Util.defTriggerVar ('eConsumption')
      Util.defTriggerVar ('eProductionCost')
      Util.defTriggerVar ('eConsumptionCost')

      --4) Function that counts from the 1st number
      function firstOfMonth ()
        local t = os.date ("* t")
        t.day, t.wday, t.hour, t.min, t.sec = 1, nil, 0,0,0
        return os.time (t)
    end

     

    Please login or register to see this attachment.

     

    and in the rules:
    1) Counts energy from the 1st number

    rule ([[@ {20: 02, catch} =>
       local e = energyConsumption (firstOfMonth ()); - Calculate values since the beginning of the month.
      eProduction = e.production;
      eConsumption = e.consumption;
      eProductionCost = e.productionCost;
      eConsumptionCost = e.consumptionCost
    ]])


    2) --3.3) If more than 10 kWfrom the 1st, then give a log
       rule ("eConsumption> 10 => log) ('Consumption last 30 days exceed 1000 (% s)', eConsumption)")

    Please login or register to see this attachment.

    with such a confiscation in the console, I see that the function shows that from the 1st number was 0 kW..respectively, the last rule does not work ...
    PS: When I leave the function for the last 30 days, it shows some kilowatts

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

    and I've tried several times to understand the new cute energy panel, and so I never understood where it draws those numbers ...
    for much closer figures to those that are in life and on which I get bills from the energy company are just from the device of the electric meter (I have a 3-phase Aeotec at 63 amps).
    And as far as I understand, the data that is displayed in the web interface of the device, it is stored somewhere physically on the device ... and here is this data, again - closer to real. So maybe it doesn't make sense to play with the energy panel yet, but just extract data directly from the device that was created for this ...?

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

  • Topic Author
  • You could go to the swagger API and play  with the energy apis and see if you can get any reasonable value

    You open it with the {...} button in the lower left corner of the web GUI.

    You choose "energy" from the pop-up in the upper right corner.

    In the code I gave you I used

    /api/energy/consumption/summary

    but maybe there is a better api.

    The date format always seems to  be in yyyy-mm-dd format.

     

    I don't use the energy panel  myself so all my values are zero...

     

    Link to comment
    Share on other sites

  • Topic Author
  • It seems like one needs to set a billing period and then use the /energy/billing/summary api to return a value

    Link to comment
    Share on other sites

    ok. I'll see, but I'm not a programmer ...
    how to be calculated from the 1st day of the month?

    Link to comment
    Share on other sites

  • Topic Author
  • 2 hours ago, fastvd said:

    ok. I'll see, but I'm not a programmer ...
    how to be calculated from the 1st day of the month?

    Well, one can set billing period (start date and ex. 1 month) with the API or the Web UI Energy panel.

    However, there is no way to delete a billing period if one happens to set date wrong.

    Seems to be half-baked at the moment...

    Link to comment
    Share on other sites

  • Topic Author
  • Try this version of energyConsumption

     

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    I'm already confused ...
    what and what functions / rules should I leave and what should I delete?
    can you give an order?

    Link to comment
    Share on other sites

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

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    I did not issue any errors ... but with the "last 30 days" function when saving the config in ER4 (roughly speaking, restarting ER4), I immediately saw in the console that the rule is true and it immediately logged how many kW .... now the rule is not becomes true ... accordingly I do not see anything (((

    Link to comment
    Share on other sites

    maybe I will seem banal, but if complex logic / rules do not work, then maybe it makes sense to use simple..something like:
    1) if today is 15.03.21 then the starting period is March 1 ....
    2) if today is September then the starting period is September 1 ...
    etc...
    there will be only 12 rules that are actually written by native functions and ER4 rules ...
    PS: I'm not a programmer, but I'm a practitioner ...

    Link to comment
    Share on other sites

  • Topic Author
  • 3 hours ago, fastvd said:

    maybe I will seem banal, but if complex logic / rules do not work, then maybe it makes sense to use simple..something like:
    1) if today is 15.03.21 then the starting period is March 1 ....
    2) if today is September then the starting period is September 1 ...
    etc...
    there will be only 12 rules that are actually written by native functions and ER4 rules ...
    PS: I'm not a programmer, but I'm a practitioner ...

    It's not the first of month that is the problem - that works. The issue is with the energy panel as we don't understand how it works...

    Link to comment
    Share on other sites

    well the energy panel I see in general is VERY bad and works crookedly ...
    plus I lost the data from my energy meter after updating to 5.090.17 .. more precisely, the system does not see it as a device that counts energy (((
    maybe then just read from the device itself, how much it counted consumption ...
    by the way, I once found a lua scene on the forum, which just counts the consumption of all devices, then sums them up, etc .... maybe something from that code can be useful in the ER4 code

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

    On 9/25/2020 at 1:27 PM, jgab said:

    Example of alarm handling on the HC3 and ER4

    Please login or register to see this code.

    Of course these events could be used to start other rules like simulating presence, turning off stuff etc.

    The cool thing here is that we get a notification when the user turns on the alarm and we have the "delay time" to check if partition is safe. If not we abort the arming.

    One could also setup a rule that watches if something is breached during the arm delay timespan and also cancel the arming.

    Hello. reached for the alarm.
    I found these basic examples. but it was still in September 2020 ... and I understand that something has changed ... and at least in the fibaro ...
    and possibly in ER4 ... so the question:
    1) how relevant these examples are

    2) in the example, the first rule is interesting: sends a message indicating how many seconds it will be placed under protection and then check the "integrity of the system" ... but it does not work now ...
    at least I do not see in the console that fibaro transfers parameter: property = 'willArm'
    Accordingly, we do not see that the system wants to be protected ...
    Maybe there are some other options at the moment?

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