Announcement

Collapse
No announcement yet.

Direct Storage from HS Devices to InfluxDB

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #61
    This is perhaps a better example:

    Code:
    16-1-2021 01:03:53 571783 | HSEvent VALUE_CHANGE| 1024| F891BB20-180-Q319| 28,9| 29,2| 388
    16-1-2021 01:03:53 571783 | DoHSEvent InfluxDictionarySize=1 this ref is 388
    16-1-2021 01:03:53 571784 | InfluxDB Write URI http://192.168.1.30:8086/api/v2/write?bucket=MQTT&orgID=homeseer
    16-1-2021 01:03:53 571784 | BasicAuth user=admin, pass=xxxxx
    16-1-2021 01:03:53 571784 | BasicAuth unencoded admin:xxxxx
    16-1-2021 01:03:53 571784 | BasicAuth bytecount 19
    16-1-2021 01:03:53 571784 | BasicAuth encoded YWRtaW46UGlrbGVfNTU5MUluZg==
    16-1-2021 01:03:53 571784 | BasicAuth return Basic YWRtaW46UGlrbGVfNTU5MUluZg==
    16-1-2021 01:03:53 571784 | BasicAuth user=admin, pass=xxxxx
    16-1-2021 01:03:53 571784 | BasicAuth unencoded admin:xxxxx
    16-1-2021 01:03:53 571784 | BasicAuth bytecount 19
    16-1-2021 01:03:53 571784 | BasicAuth encoded YWRtaW46UGlrbGVfNTU5MUluZg==
    16-1-2021 01:03:53 571784 | BasicAuth return Basic YWRtaW46UGlrbGVfNTU5MUluZg==
    16-1-2021 01:03:53 571784 | InfluxDB Write Auth Authorization: Basic Basic YWRtaW46UGlrbGVfNTU5MUluZg==
    16-1-2021 01:03:53 571786 | InfluxDB Write Requesting Response
    16-1-2021 01:03:53 571805 | HSEvent VALUE_SET| 2048| F891BB20-180-Q319| 28,9| 28,9| 388
    16-1-2021 01:03:53 571805 | DoHSEvent InfluxDictionarySize=1 this ref is 388
    16-1-2021 01:03:53 571805 | InfluxDB Write URI http://192.168.1.30:8086/api/v2/write?bucket=MQTT&orgID=homeseer
    16-1-2021 01:03:53 571805 | BasicAuth user=admin, pass=xxxxx
    16-1-2021 01:03:53 571805 | BasicAuth unencoded admin:xxxxx
    16-1-2021 01:03:53 571805 | BasicAuth bytecount 19
    16-1-2021 01:03:53 571805 | BasicAuth encoded YWRtaW46UGlrbGVfNTU5MUluZg==
    16-1-2021 01:03:53 571805 | BasicAuth return Basic YWRtaW46UGlrbGVfNTU5MUluZg==
    16-1-2021 01:03:53 571805 | BasicAuth user=admin, pass=xxxxx
    16-1-2021 01:03:53 571806 | BasicAuth unencoded admin:xxxxx
    16-1-2021 01:03:53 571806 | BasicAuth bytecount 19
    16-1-2021 01:03:53 571806 | BasicAuth encoded YWRtaW46UGlrbGVfNTU5MUluZg==
    16-1-2021 01:03:53 571806 | BasicAuth return Basic YWRtaW46UGlrbGVfNTU5MUluZg==
    16-1-2021 01:03:53 571806 | InfluxDB Write Auth Authorization: Basic Basic YWRtaW46UGlrbGVfNTU5MUluZg==
    16-1-2021 01:03:53 571807 | InfluxDB Write Requesting Response

    Comment


      #62
      Yes, note now you get an encode auth code in the statement "
      InfluxDB Write Auth Authorization: Basic Basic YWRtaW46UGlrbGVfNTU5MUluZg==" from the debug. I assume this did not change your success at writing to the database. I do not know what changed between the two versions because only debug was added and the newer one produces a auth code.

      Comment


        #63
        I did the test with RPi Buster. Created new database MQTT3 and toggled a device. CLI looks just as expected.

        Code:
        > use MQTT3
        Using database MQTT3
        > select * from mcsMQTT
        > select * from mcsMQTT
        name: mcsMQTT
        time device value
        ---- ------ -----
        1610772146203711111 Unknown_Unknown_Control 100
        1610772153208852330 Unknown_Unknown_Control 0
        Code:
        root@RPI4USB:~# mono -V
        Mono JIT compiler version 6.12.0.107 (tarball Thu Dec 10 05:44:54 UTC 2020)
        The debug
        Code:
        1/15/2021 9:39:21 PM 93585 | SubGet URL http://192.168.0.16:8086/api/v2/buckets?name=MQTT3
        1/15/2021 9:39:21 PM 93664 | BasicAuth user=hs, pass=x
        1/15/2021 9:39:21 PM 93664 | BasicAuth unencoded hs:x
        1/15/2021 9:39:21 PM 93664 | BasicAuth bytecount 9
        1/15/2021 9:39:21 PM 93664 | BasicAuth encoded aHM6Ym9laW5n
        1/15/2021 9:39:21 PM 93664 | BasicAuth return Basic aHM6Ym9laW5n
        1/15/2021 9:39:21 PM 93878 | BasicAuth user=hs, pass=x
        1/15/2021 9:39:21 PM 93879 | BasicAuth unencoded hs:x
        1/15/2021 9:39:21 PM 93879 | BasicAuth bytecount 9
        1/15/2021 9:39:21 PM 93879 | BasicAuth encoded aHM6Ym9laW5n
        1/15/2021 9:39:21 PM 93879 | BasicAuth return Basic aHM6Ym9laW5n
        1/15/2021 9:39:21 PM 93881 | InfluxDB Post URL http://192.168.0.16:8086/query Data: q=CREATE DATABASE MQTT3
        1/15/2021 9:39:21 PM 93881 | InfluxDB Post Header Authorization: Basic Basic aHM6Ym9laW5n
        1/15/2021 9:39:21 PM 93912 | InfluxDB Post Response Requested
        [B]1/15/2021 9:39:21 PM 93942 | InfluxDB Post Response Success {"results":[{"statement_id":0}]}[/B]
        
        
        
        1/15/2021 9:41:54 PM 247507 | Adding to Device Influx Dictionary 226
        1/15/2021 9:42:26 PM 278777 | DoHSEvent InfluxDictionarySize=1 this ref is 226
        1/15/2021 9:42:26 PM 278781 | InfluxDB Write URI http://192.168.0.16:8086/api/v2/write?bucket=MQTT3&orgID=homeseer
        1/15/2021 9:42:26 PM 278782 | BasicAuth user=hs, pass=x
        1/15/2021 9:42:26 PM 278782 | BasicAuth unencoded hs:x
        1/15/2021 9:42:26 PM 278782 | BasicAuth bytecount 9
        1/15/2021 9:42:26 PM 278782 | BasicAuth encoded aHM6Ym9laW5n
        1/15/2021 9:42:26 PM 278782 | BasicAuth return Basic aHM6Ym9laW5n
        1/15/2021 9:42:26 PM 278782 | BasicAuth user=hs, pass=x
        1/15/2021 9:42:26 PM 278782 | BasicAuth unencoded hs:x
        1/15/2021 9:42:26 PM 278782 | BasicAuth bytecount 9
        1/15/2021 9:42:26 PM 278782 | BasicAuth encoded aHM6Ym9laW5n
        1/15/2021 9:42:26 PM 278782 | BasicAuth return Basic aHM6Ym9laW5n
        1/15/2021 9:42:26 PM 278783 | InfluxDB Write Auth Authorization: Basic Basic aHM6Ym9laW5n
        1/15/2021 9:42:26 PM 278787 | InfluxDB Write Requesting Response
        [B]1/15/2021 9:42:26 PM 278826 | InfluxDB Write Response Success[/B]
        1/15/2021 9:42:33 PM 285786 | HSEvent VALUE_CHANGE| 1024| | 0| 100| 226
        1/15/2021 9:42:33 PM 285787 | DoHSEvent InfluxDictionarySize=1 this ref is 226
        1/15/2021 9:42:33 PM 285787 | InfluxDB Write URI http://192.168.0.16:8086/api/v2/write?bucket=MQTT3&orgID=homeseer
        1/15/2021 9:42:33 PM 285787 | BasicAuth user=hs, pass=x
        1/15/2021 9:42:33 PM 285787 | BasicAuth unencoded hs:x
        1/15/2021 9:42:33 PM 285788 | BasicAuth bytecount 9
        1/15/2021 9:42:33 PM 285788 | BasicAuth encoded aHM6Ym9laW5n
        1/15/2021 9:42:33 PM 285788 | BasicAuth return Basic aHM6Ym9laW5n
        1/15/2021 9:42:33 PM 285788 | BasicAuth user=hs, pass=x
        1/15/2021 9:42:33 PM 285788 | BasicAuth unencoded hs:x
        1/15/2021 9:42:33 PM 285788 | BasicAuth bytecount 9
        1/15/2021 9:42:33 PM 285788 | BasicAuth encoded aHM6Ym9laW5n
        1/15/2021 9:42:33 PM 285789 | BasicAuth return Basic aHM6Ym9laW5n
        1/15/2021 9:42:33 PM 285789 | InfluxDB Write Auth Authorization: Basic Basic aHM6Ym9laW5n
        1/15/2021 9:42:33 PM 285792 | InfluxDB Write Requesting Response
        [B]1/15/2021 9:42:33 PM 285796 | InfluxDB Write Response Success[/B]
        There was no error response for the failure of creating as version 2.0 database as there was with Windows. It looks like no response is not considered an error. I changed to logic to test and output at every step. I do not get failures for the create database so cannot show what that looks like, but if I write to a dropped database I get the following. Hopefully you will get more info when running to understand why it is not working for you. This was collected from the (4) zip attachment.

        [code]
        1/15/2021 11:06:38 PM 25384 | HSEvent VALUE_CHANGE| 1024| | 100| 0| 226
        1/15/2021 11:06:38 PM 25492 | InfluxDB Write URI http://192.168.0.16:8086/api/v2/write?bucket=MQTTN&orgID=homeseer
        1/15/2021 11:06:39 PM 25654 | InfluxDB Write Requesting Response
        1/15/2021 11:06:39 PM 25706 | InfluxDB Write Finally The remote server returned an error: (404) Not Found.
        1/15/2021 11:06:40 PM 27088 | HSEvent VALUE_CHANGE| 1024| | 0| 100| 226
        1/15/2021 11:06:40 PM 27089 | InfluxDB Write URI http://192.168.0.16:8086/api/v2/write?bucket=MQTTN&orgID=homeseer
        1/15/2021 11:06:40 PM 27103 | InfluxDB Write Requesting Response
        1/15/2021 11:06:40 PM 27110 | InfluxDB Write Finally The remote server returned an error: (404) Not Found.
        [code]

        I continue to not need any username password credentials either at CLI or from mcsMQTT. I don't know how to enable the protection if having a admin user does not do it.

        On a lark I also went back to a bogus form of auth that I had originally used. It is the (5) zip file if you want to try.

        Attached Files

        Comment


          #64
          My conclusion for now is that things stuck on the influx server. So I grabbed another RaspberryPi and installed influx on it, without any extra authorization and no changes to the conf file. This is a succes. Now the database MQTT and the measurement mcsMQTT are made and data is coming in. No credentials are given in the history tab.

          But, I think it is not a safe idea to have an open database on a system. So the question is how to go on. Some kind of authorization should be there right?

          Comment


            #65
            I will descibe here chronologically what I did:

            The next step was creating a user with all previleges:

            Code:
            CREATE USER <user> WITH PASSWORD <'password'> WITH ALL PRIVILEGES
            Now I filled these credentials in the history tab and the data keeps coming in.
            This is a surprise because now we have the same situation as with the former influx server, exept that the admin user does not exist.

            Now I disabled the mcsMQTT plugin and started it again right away.

            This action caused the stop of the data writing to the database.

            I dropped the database MQTT and a new was made:
            Code:
            16-1-2021 14:47:42 835188 | SubGet URL http://192.168.1.52:8086/api/v2/buckets?name=MQTT
            16-1-2021 14:47:42 835193 | SubmitGet Finally no Response
            16-1-2021 14:47:42 835193 | InfluxDB Post URL http://192.168.1.52:8086/query Data: q=CREATE DATABASE MQTT
            16-1-2021 14:47:42 835193 | InfluxDB Post Header Authorization: Basic Basic Y29wZTpQaWtsZV81NTkxSW5m
            16-1-2021 14:47:42 835195 | InfluxDB Post After postStream
            16-1-2021 14:47:42 835195 | InfluxDB Post After postStream Finally False
            16-1-2021 14:47:42 835195 | InfluxDB Post Response Requested
            16-1-2021 14:47:42 835219 | InfluxDB Post Response Success {"results":[{"statement_id":0}]}
            The measurement mcsMQTT is not created:
            Code:
            16-1-2021 14:48:08 861144 | InfluxDB Write URI http://192.168.1.52:8086/api/v2/write?bucket=MQTT&orgID=homeseer
            16-1-2021 14:48:08 861145 | InfluxDB Write Auth Authorization: Basic Basic Y29wZTpQaWtsZV81NTkxSW5m
            16-1-2021 14:48:08 861147 | InfluxDB Write Requesting Response
            16-1-2021 14:48:08 861149 | InfluxDB Write Finally The remote server returned an error: (400) Bad Request.
            16-1-2021 14:48:08 861159 | HSEvent VALUE_CHANGE| 1024| | 316620| 316619| 258
            16-1-2021 14:48:08 861175 | HSEvent VALUE_SET| 2048| F891BB20-180-Q319| 46,5| 46,5| 388
            16-1-2021 14:48:08 861175 | InfluxDB Write URI http://192.168.1.52:8086/api/v2/write?bucket=MQTT&orgID=homeseer
            16-1-2021 14:48:08 861176 | InfluxDB Write Auth Authorization: Basic Basic Y29wZTpQaWtsZV81NTkxSW5m
            16-1-2021 14:48:08 861177 | InfluxDB Write Requesting Response
            16-1-2021 14:48:08 861180 | InfluxDB Write Finally The remote server returned an error: (400) Bad Request.
            Removing the credentials on the history tab did make no difference.

            So databases are made now but no measurement.

            Comment


              #66
              After adding authorization to influx by changing the config file we are back to the previous situation.
              https://docs.influxdata.com/influxdb...authorization/

              No databases are made any more:
              Code:
              16-1-2021 15:23:34 1318900 | InfluxDB Post URL http://192.168.1.52:8086/query Data: q=CREATE DATABASE MQTT
              16-1-2021 15:23:34 1318900 | InfluxDB Post Header Authorization: Basic Basic Y29wZTpQaWtsZV81NTkxSW5m
              16-1-2021 15:23:34 1318901 | InfluxDB Post After postStream
              16-1-2021 15:23:34 1318901 | InfluxDB Post After postStream Finally False
              16-1-2021 15:23:34 1318902 | InfluxDB Post Response Requested
              16-1-2021 15:23:34 1318906 | InfluxDB Post Finally no Response The remote server returned an error: (401) Unauthorized.
              So writing to a database is only possible without any authorization enabled on the influx server.

              Comment


                #67
                If I roll back so change the config file to the original and drop the user I made then databases are made again, but no measurements. So creating the user made somewhere make a change that prevents the creation of measurements.

                Comment


                  #68
                  Thank You for the detailed information and analysis.

                  The (400) Bad Request is a response I have seen before when trying to read back the data and it was a mixture of different header parameters that finally was accepted by InfluxDB 1.8.

                  In the referenced link they described admin user. Based upon our combined experience it looks like they mean a username of admin rather than a user with admin privilege. Can you confirm that you continued to use admin as the user name. I used hs when I have been doing my testing.

                  I cannot explain why a restart of mcsMQTT caused data write to stop. Each write is a separate transaction with new credentials provided each time. There is no explicit environment setup such as with CLI where USE DATABASE provides a context.

                  With Influx 2.0 auth is required and that is working fine for me to both create the database and write data. I continue to get the response code of 400 when reading the data with Influx 2.0.

                  What I will do is setup another RPi image and try to get to the point where I see errors and then try to overcome them.

                  Comment


                    #69
                    In the referenced link they described admin user. Based upon our combined experience it looks like they mean a username of admin rather than a user with admin privilege. Can you confirm that you continued to use admin as the user name. I used hs when I have been doing my testing.
                    In the case that creating database, measurement and sending data was successful I had no authorization set up in Influxdb. When I created a user with all previleges it was finished after I dis- and enabled mcsMQTT PI.

                    I am looking forward to a 64bit OS for the Pi so I can then install the 2.0 version of InfluxDB. At the moment they have only a beta test version at raspberrypi.org.

                    Comment


                      #70
                      My question is the name of the user. Did you use the name "admin" or was it something else? When I use "hs" with all privileges it still operates as if no auth is needed.

                      Comment


                        #71
                        Ah, yes, I used admin for a long time. Afterwards I used another user with all privileges. Here no difference between the two.

                        Comment


                          #72
                          I setup another RPi Buster image and installed influxDB using apt-get install per instructions in the mcsMQTT manual. I created user admin with all privileges. Using show users it confirms admin user has admin true. I tried various sequences including restarting mcsMQTT, restarting influxDB, creating another influx user, using no user password in mcsMQTT, using wrong password. No matter what I do I continue to be able to write to the database. I have tried it with 32 bit Buster and 64 bit Buster on RPi4 and RPi3. No matter what I do I continue to be able to write to the database so this database is not enforcing auth.

                          I did read the InfluxDB 1.8 site closely and looked in the config file and discovered that the authentication is controlled by a setting in the http section of that file and this setting is not changed based upon having an admin user. When I enabled it there then the auth began to work and I was able to use Wireshark to compare what curl was sending vs. what mcsMQTT was sending and then updated mcsMQTT. Now the write is OK with a database that has password protection. I also confirmed a new database could be created. I left the detailed debug in the plugin to let you confirm it works for you too.



                          Attached Files

                          Comment


                            #73
                            I installed version 6 of the dll on the HomeSeer Rpi. I started from scratch with the spare RPi so removed the influxdb. Did a update/upgrade and installed influx following your manual. BTW this is the same way I always have used.

                            The influx deamon would not start, the conf file was missing in /etc/influxdb !!!!
                            I repeated the remove and install of influxdb, the same problem, very very weird!!

                            So I copied the conf file from the other RPi, still running influx in between NodeRED and Grafana. I commented the http stuff out.
                            Now the deamon started.

                            Looking to the database I can now see that the database (MQTT2) is created but no data is coming in, this is without an Authorization Token in the history tab.:

                            Code:
                            17-1-2021 12:00:59 142572 | SubGet URL http://192.168.1.52:8086/api/v2/buckets?name=MQTT2
                            17-1-2021 12:01:00 142860 | SubmitGet Finally no Response
                            17-1-2021 12:01:00 142863 | InfluxDB Post URL http://192.168.1.52:8086/query Data: q=CREATE DATABASE MQTT2
                            17-1-2021 12:01:00 142891 | InfluxDB Post After postStream
                            17-1-2021 12:01:00 142891 | InfluxDB Post After postStream Finally False
                            17-1-2021 12:01:00 142892 | InfluxDB Post Response Requested
                            17-1-2021 12:01:00 142927 | InfluxDB Post Response Success {"results":[{"statement_id":0}]}
                            Code:
                            17-1-2021 12:01:11 154089 | HSEvent VALUE_CHANGE| 1024| F891BB20-180-Q319| 46,4| 46,2| 388
                            17-1-2021 12:01:11 154092 | InfluxDB Write URI http://192.168.1.52:8086/api/v2/write?bucket=MQTT2&orgID=homeseer
                            17-1-2021 12:01:11 154094 | InfluxDB Write Requesting Response
                            17-1-2021 12:01:11 154097 | InfluxDB Write Finally The remote server returned an error: (400) Bad Request.
                            17-1-2021 12:01:11 154107 | HSEvent VALUE_SET| 2048| F891BB20-180-Q319| 46,4| 46,4| 388
                            17-1-2021 12:01:11 154107 | InfluxDB Write URI http://192.168.1.52:8086/api/v2/write?bucket=MQTT2&orgID=homeseer
                            17-1-2021 12:01:11 154109 | InfluxDB Write Requesting Response
                            17-1-2021 12:01:11 154112 | InfluxDB Write Finally The remote server returned an error: (400) Bad Request.
                            If I do add an Authorization Token of the admin user I get the same results:

                            Code:
                            17-1-2021 12:27:39 1741724 | SubGet URL http://192.168.1.52:8086/api/v2/buckets?name=MQTT
                            17-1-2021 12:27:39 1741735 | SubmitGet Finally no Response
                            17-1-2021 12:27:39 1741735 | InfluxDB Post URL http://192.168.1.52:8086/query Data: q=CREATE DATABASE MQTT
                            17-1-2021 12:27:39 1741735 | InfluxDB Post Header Authorization: Basic YWRtaW46UGlrbGVfNTU5MUluZg==
                            17-1-2021 12:27:39 1741736 | InfluxDB Post After postStream
                            17-1-2021 12:27:39 1741737 | InfluxDB Post After postStream Finally False
                            17-1-2021 12:27:39 1741737 | InfluxDB Post Response Requested
                            17-1-2021 12:27:39 1741739 | InfluxDB Post Response Success {"results":[{"statement_id":0}]}
                            Code:
                            17-1-2021 12:27:47 1750181 | InfluxDB Write URI http://192.168.1.52:8086/api/v2/write?bucket=MQTT&orgID=homeseer
                            17-1-2021 12:27:47 1750182 | InfluxDB Write Auth Authorization: Basic YWRtaW46UGlrbGVfNTU5MUluZg==
                            17-1-2021 12:27:47 1750186 | InfluxDB Write Requesting Response
                            17-1-2021 12:27:47 1750189 | InfluxDB Write Finally The remote server returned an error: (400) Bad Request.
                            17-1-2021 12:27:47 1750248 | HSEvent VALUE_SET| 2048| F891BB20-180-Q319| 46,4| 46,4| 388
                            17-1-2021 12:27:47 1750249 | InfluxDB Write URI http://192.168.1.52:8086/api/v2/write?bucket=MQTT&orgID=homeseer
                            17-1-2021 12:27:47 1750249 | InfluxDB Write Auth Authorization: Basic YWRtaW46UGlrbGVfNTU5MUluZg==
                            17-1-2021 12:27:47 1750252 | InfluxDB Write Requesting Response
                            17-1-2021 12:27:47 1750257 | InfluxDB Write Finally The remote server returned an error: (400) Bad Request.
                            In all these situations authorization was switched off in the conf file.

                            With the authorization swithed on nothing changes in the results, databases are made, no data coming in.

                            I use the tool Time Series Admin for quickly checking databases. Do you know this tool? Very handy.
                            https://timeseriesadmin.github.io/

                            What I see here is error message I have seen before, here is a screenshot:

                            Click image for larger version

Name:	2021-01-17_124404.png
Views:	245
Size:	23.1 KB
ID:	1448752

                            This message {"title":"401: Unauthorized","details":{},"isCommon":true} does that ring any bells??

                            I have no idea how going further


                            Comment


                              #74
                              Getting mad here.... I put a new PiOS on a SD. That went into a Rpi3B and I initiated the system.
                              Then Influx was installed as per your manual.
                              The config file was in place! Didn't change it.

                              I keep seeing the same behaviour: database made immediately but no data transport to the database.

                              Comment


                                #75
                                Maybe a screenshot of your settings in HomeSeer would be helpful, Cor ?
                                Karl S
                                HS4Pro on Windows 10
                                1070 Devices
                                56 Z-Wave Nodes
                                104 Events
                                HSTouch Clients: 3 Android, 1 iOS
                                Google Home: 3 Mini units, 1 Pair Audios, 2 Displays

                                Comment

                                Working...
                                X