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


[HOWTO] HC2 + Grafana (influxdb)


10der

Recommended Posts

Quote

@RH_Dreambox any advise on the amount of internal memory?

I first started with a "Pi 3 Model B +" (1 Gb) and it worked perfectly well.

But then I wanted to try a Pi 4 that is a bit faster and then it became a "Pi 4 Model B / 4GB"

  • Thanks 1
Link to comment
Share on other sites

It looks very nice @10der!

I like to try this also with my HC3 but I am stucked.

On Pi 3B

I cant create user/data base

<create database home
use home

create user grafana with password 'XXXXX' with all privileges
grant all privileges on home to grafana

show users

user admin
---- -----
grafana true>

Give me an error:

command not found

Any idea or help for this noob?

Thanks in advance

//Sjakie

Link to comment
Share on other sites

@Sjakie

You may have missed typing the "influx" command required to create and edit the database.

 

pi@raspberrypi:~ $ influx
Connected to

Please login or register to see this link.

version 1.8.3
InfluxDB shell version: 1.8.3
>
 

Link to comment
Share on other sites

  • 3 weeks later...

I gave up on Docker. Got my Raspberry Pi today and got InfluxDB and Grafana running. 

 

I followed this instruction to get the Raspberry Pi started with InfluxDB and Grafana:

Please login or register to see this link.

 

Also installed @10der script. 

 

And it is running!

 

Now finding out how Grafana really works, get some values in and work on a fine dashboard like @jguellec 

Edited by SmartHomeEddy
Link to comment
Share on other sites

@RH_Dreambox @Sjakie @jguellec@antoniopll 

Experimenting with InfluxDB and Grafana. Now I put the values of some devices every minute in Influx. But there is a smarter way. 

 

Has anyone used the API for consumption, diagnostics, events, refreshstates and weather to put all the data in Influx?

 

Like converting the json output of the API to data measurements in Influx?

Edited by SmartHomeEddy
Link to comment
Share on other sites

Quote

Has anyone used the API for consumption, diagnostics, events, refreshstates and weather to put all the data in Influx?

Like converting the json output of the API to data measurements in Influx?

No, unfortunately, it's above my level. ? I just log different sensors and the level in the water well (Raspberry + HC SR04).

Link to comment
Share on other sites

Thanks you

 

I am looking for a translation of the api.get to this structure to insert all history values in Influx

 

{

    measurement = measurement_name,

    time = os.time(os.date("*t")) * 1000000000,

    tags = {deviceID = deviceID,

    deviceName = deviceName,

    roomName = roomName,

    sectionName = sectionName},

    fields = {value = value}

    }

 

Edited by SmartHomeEddy
Link to comment
Share on other sites

Hi @10der if you are still there

 

I would think this should work to get the battery level?

 

saveByDeviceID("Garage_CO_Sensor_BatteryLevel", 140, "batteryLevel")

Link to comment
Share on other sites

13 hours ago, SmartHomeEddy said:

Hi @10der if you are still there

No.

 

13 hours ago, SmartHomeEddy said:

I would think this should work to get the battery level?

 

saveByDeviceID("Garage_CO_Sensor_BatteryLevel", 140, "batteryLevel")

 

yup!

 

Please login or register to see this image.

/monthly_2021_02/image.png.c74245afc822c74979f2640a20cb717e.png" />

 

Link to comment
Share on other sites

  • 5 months later...

Hello,

 

the script seems doesn't work :

Grafana = ok

influxdb = ok 

script = ko

 

root@XXXXXX:/home/grafana# python /home/grafana/poll.py
Traceback (most recent call last):
  File "/home/grafana/poll.py", line 10, in <module>
    import requests
ImportError: No module named requests

 

Any idea for helping me ?

 

thanks in advance

Link to comment
Share on other sites

Hi @Manu_31

poll.py is an older variant where data was retrieved from HC2 / HC3 to Influx.
You should use the scene described in the post where HC3 sends data to the Influx server.

So, you don't need to use poll.py.

Link to comment
Share on other sites

Hello @RH_Dreambox,

 

Thanks for your reply.
Here my config in attachement.
 

In my part (I think)

Grafana and influxdb are OK

Grafana (in attachment) connect to influxdb =ok and request seems to be ok also.

Test influxdb with URL seems to be ok

 

In my HC3 make a scene and I have multiples error:

- Comment l.16 (same as bello in discussion)  JSon line

- But Power device is not exist (do i mak all my power device or juste one ?)

 And if i comment this line I have another error (attempt to concatenate a nil value (local 'roomID')

 

Thanks in advance for your help ;) 

Please login or register to see this attachment.

Please login or register to see this attachment.

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

Hello again @Manu_31

There are a few things you can check.

I see in your picture that you have created a database called HC2 (or have you just copied what 10der shows in their pictures?).
Have you then written the same database name in the scene, where it says "smarthome" by default?

 

local host = "192.168.1.10"
local port = "8086"
local dbName = "smarthome"

 

It is also important that you have created a database in Influx with the same name.

 

You must change the code below to your own ID.
The rows below are intended for a 3 phase energy meter, for example. Aeotec HEM.
If you do not have an 3 phase energy meter, delete or deselect these lines.


(1141, "poll") refers to the energy meter's "main" which is normally hidden.

 

fibaro.call(1141, 'poll')
fibaro.sleep(1000)

saveByDeviceID("PhaseA", 1149)
saveByDeviceID("PhaseB", 1152)
saveByDeviceID("PhaseC", 1146)

saveByDeviceID("PhaseA_Energy", 1148, "power")
saveByDeviceID("PhaseC_Energy", 1151, "power")
saveByDeviceID("PhaseC_Energy", 1145, "power")

 

Add the devices you want to log into Influx.
Depending on which devices you have and which version of HC3 you have installed, "power" and "energy" can also be called "value".

 

This is how I configured some of my devices

 

saveByDeviceID("Washer", 90, "power")
saveByDeviceID("Dryer", 92, "power")
saveByDeviceID("Platlight", 48, "power")
saveByDeviceID("Greenroom", 46, "power")

saveByDeviceID("Hum_out", 236, "value")
saveByDeviceID("Temp_out", 180, "value")
saveByDeviceID("Lux_out", 68, "value")

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

  • 4 weeks later...

Hello,

 

I hope everybody's fine.
I came back to my holidays and remake from scratch and have the same error in my HC3 v5.080.12

For answer:

DBName Influx = smarthome

In HC2 scene = smarthome

scene in HC3 same as before.

 

My errors (in attachment):

 1. Device 1141 does not exists 

If I comment this line the script continue to second error

2. (load):93: attempt to concatenate a nil value (local 'roomID')

But if i try since web browers to get this from API it's work.

 

Do you have any ideas to help me ?

 

Thanks in advance

 

BR

 

Please login or register to see this attachment.

Please login or register to see this attachment.

Link to comment
Share on other sites

  • Topic Author
  • 219 is systems room

    please exclude this room in scrip

    Link to comment
    Share on other sites

    Hello @10der:

     

    How to exclude ? 

    Comment wich line, this ?

    local roomID = fibaro.getRoomID(deviceID)
        local room = api.get("/rooms?id="..roomID)
        local section = api.get("/sections?id="..room.sectionID)
     
    Thanks in advance
    Link to comment
    Share on other sites

  • Topic Author
  • @Manu_31

     

    ok. use this script

     

    1st of set own value for init influx

    2nd by default scrip save only ALL temp and hum sensors

    3d if you want save a custom sensor or device look example at the bottom -> comment code

     

    Please login or register to see this code.

     

    Edited by 10der
    Link to comment
    Share on other sites

    • 2 months later...

    Good morning at all 

     

    I have a question about transferring data to Influx.

    In the dashboard of @jguellec I saw that the active profile is displayed. As well as the last update and the runtime of the HC. Can anyone help me how to transfer this data to Influx? Which line of code do I have to enter in the script of @10der?

    Thanks

    Link to comment
    Share on other sites

  • Topic Author
  • 13 hours ago, KaWi said:

    Good morning at all 

     

    I have a question about transferring data to Influx.

    In the dashboard of @jguellec I saw that the active profile is displayed. As well as the last update and the runtime of the HC. Can anyone help me how to transfer this data to Influx? Which line of code do I have to enter in the script of @10der?

    Thanks

    Yes, I can help but later 

    I am in busses trip right now

    Edited by 10der
    Link to comment
    Share on other sites

    • 2 weeks later...

    Hello @10der

    Are you still on a bus trip? ?

     

    In the meantime, I tried to create the code myself. Unfortunately, I failed.

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