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


  • 3

SCENE. How to write to InfluxDb


10der
 Share

Question

Please login or register to see this code.

 

a special thanks @tinman ?

 

 

Please login or register to see this attachment.

 

Please login or register to see this attachment.

 

 

 

 

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

Recommended Posts

  • 0
25 minutes ago, jgab said:

The solution seems to be in the url that @10der posted. Remove the 10^6 multiplication and add the precision field to the url in sendDataToInflux. - or better, make it a parameter.

That is what I did. My database is now filled with the following values:

Please login or register to see this code.

 

By example, time 1640238310 converted from Unix EPOCH to human readable format is: Your time zone: Thursday, December 23, 2021 6:45:10 AM GMT+01:00

 

That is correct. But then Grafana reads the database and it will convert the string to Januari 1, 1970 12:00:01. As Grafana expects the value to be in nanoseconds. As far as I can see the multiplier used in the code of this scene is added to convert the timestamp from seconds to nanoseconds.

 

Example of the scene code to see what happens:

Please login or register to see this code.

Output:

Please login or register to see this code.

 

I do see 2 options:

1) Fix the issue with the multiplication and make sure data is send to Influx in nanoseconds

2) Fix the issue in Grafana somehow

 

I think the first option is the best, I always learned "trash in = trash out".

 

Update: I found some sort of workaround. If I change this line of code:

Please login or register to see this code.

to:

Please login or register to see this code.

InfluxDB takes care of the timestamp. Which is in the correct format. But then I will loose the flexibility that the device property date is used (less data in database).

Edited by B_b_B
Link to comment
Share on other sites

  • 0
  • Inquirer
  • 51 minutes ago, jgab said:

    You shouldn't say that - his schizophrenia will get worse

    Jan thank you! :)

    • Like 3
    Link to comment
    Share on other sites

    • 0
    1 hour ago, 10der said:

    Jan thank you! :)

    But the big question is, any idea how to fix my issue ;)

     

    Or maybe change the question, does your script run on HC3 with the multiplier?

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • On 12/23/2021 at 12:17 PM, B_b_B said:

    But the big question is, any idea how to fix my issue ;)

     

    Or maybe change the question, does your script run on HC3 with the multiplier?

    what issue we are talk about?

     

    this script working about 2y since my HC3 start working.

     

    this code works like a charm

    Please login or register to see this code.

     

    here is proofs

    Please login or register to see this attachment.

     

     

     

    Please login or register to see this attachment.

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

    • 0

    @B_b_B it's good to have your HC model in the signature. It seems like you have an HCL?

     

    In that case they have compiled the Lua engine with only 32bits integers so you get an overflow when multiplying the epoch with 1000000000.... @10der don't have that problem as he runs on a HC3 (event though it tturns into a funky scientific representation (float + exp) that influx seems to be able to handle...)

    Link to comment
    Share on other sites

    • 0

    @10der Hi! It looks from your screenshots youre using influxdb v2, but the posted script is for influx v1. If you have a working script for v2 could you please post the complete script? I would love for this to work. 

    Thank you 

    • Thanks 1
    Link to comment
    Share on other sites

    • 0
    On 12/11/2021 at 11:37 PM, Digital_T said:

    Anyone successfully ported this script to support influxdb v2? 

    yes :)

    and also solved issue with *1000000 in timestamp

     

     

    Link to comment
    Share on other sites

    • 0

    I’m currently working on QA that will send data to InfluxDB2. It will work on different principle than this script. It will send data based on events from HC3. It will generate data to Influx with minimum delay. Also there will be data about HC3 system (cpu,ram), info about scenes (start, stop) and a lot of details about devices. In QA variables there will possibility to define include/exclude measurements/IDs/… (default all data are sent to Influx). It’s almost done and working 😀

    Now I’m thinking that could be interesting to add the export all data from all devices in regular interval (ie. every 15 minutes) to get info from all dev on same level….

    • Like 1
    Link to comment
    Share on other sites

    • 0

    QA for InluxDB2 is ready for testing.

    Let me know if somebody wants to test it. (only advanced user that knows how to install / work with InfluxDB2)

     

    Edited by petrkl12
    Link to comment
    Share on other sites

    • 0
    41 minutes ago, petrkl12 said:

    QA for InluxDB2 is ready for testing.

    Let me know if somebody wants to test it. (only advanced user that knows how to install / work with InfluxDB2)

     

     

    I am currently migrating influxdb 1.7 from the rpi to docker on my nas.

    Or at least, thats the plan. Also running something alike for databasing events from the hc3.

     

    But i am not a advanced user :)  But hell how hard can it be.

    Link to comment
    Share on other sites

    • 0
    1 hour ago, ppeterr said:

     

    But i am not a advanced user :)  But hell how hard can it be.

    :) You should be able to install InfluxDB 2.x and check if your data from HC3 are OK

    Link to comment
    Share on other sites

    • 0
    39 minutes ago, petrkl12 said:

    :) You should be able to install InfluxDB 2.x and check if your data from HC3 are OK

     

    Well, then i am an advanced user for sure. :P

    Link to comment
    Share on other sites

    • 0

    @petrkl12

     

    On a serious note, maybe its worth opening a new topic.

    Just to keep all the information you need, or others need nicely seperated.

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

     Share

    ×
    ×
    • Create New...