• header.categories
    • header.recent
    • header.tags
    • header.popular
    • register
    • login

    Help logging data?

    scheduled pinned locked moved General Discussion
    8 posts 4 posters 2.7k views 2 watching
    loading-more-posts
    • oldest-to-newest
    • newest-to-oldest
    • most-votes
    reply
    • reply-as-topic
    guest-login-reply
    deleted-message
    • M offline
      mattjones
      global:last-edited-by,

      Hello everyone,

      I am struggling to understand how to get a raw data set through mycontroller on to my local machine some how? If at all possible?

      Can anyone offer any help?

      jkandasaJ one-reply-to-this-post last-reply-time reply quote 0
      • jkandasaJ offline
        jkandasa @mattjones
        global:last-edited-by,

        @mattjones Yes, you can get raw data with /mc/rest/metrics/stats API

        Example: GET https://<ip>:8443//mc/rest/metrics/stats?uid=sensor1&bucketDuration=raw&duration=1h

        one-reply-to-this-post last-reply-time reply quote 0
        • M offline
          mattjones
          global:last-edited-by,

          @jkandasa thanks for your quick reply. Can you spell it out a bit clearer for the less able ones out there? The links didnt seem to work.

          jkandasaJ one-reply-to-this-post last-reply-time reply quote 0
          • jkandasaJ offline
            jkandasa @mattjones
            global:last-edited-by,

            @mattjones I hope you are using latest SNAPSHOT version, If you are not, please use http://forum.mycontroller.org/topic/58/download-snapshot-build

            Here is the example:
            My Raspberry IP: 192.168.1.209

            I have a created a UID tag for my sensor variable water level as water-level as displayed below,
            0_1500564933133_image.png

            I use Restlet client in chrome to fetch REST data.
            0_1500565263169_image.png

            Here is the actual query:
            GET https://192.168.1.209:8443/mc/rest/metrics/stats?uid=water-level&bucketDuration=12h&duration=2d

            • uid : uid tag for sensor variable. You can use resourceType and resourceId also (ask me if you want more about this).
            • bucketDuration : interval options raw and minute(mn), hours(h), day(d), month(m) 1 minute = 1mn, 12 hours = 12h
            • duration : default 8 hours. You can mention last x hours(h), minutes(mn), days(d), months(m)

            Query samples:

            • I would like to query for last 12 hours in 4 hours interval.
              https://192.168.1.209:8443/mc/rest/metrics/stats?uid=water-level&bucketDuration=4h&duration=12h
            [ {
              "timestamp" : 1500537004582,
              "empty" : false,
              "min" : 94.4,
              "max" : 100.0,
              "avg" : 96.3425,
              "samples" : 320
            }, {
              "timestamp" : 1500551404582,
              "empty" : false,
              "min" : 92.3,
              "max" : 94.4,
              "avg" : 93.58117283950608,
              "samples" : 324
            }, {
              "timestamp" : 1500565804582,
              "empty" : false,
              "min" : 90.9,
              "max" : 99.3,
              "avg" : 95.56230529595034,
              "samples" : 321
            } ]
            
            • I would like to query for last 10 minutes raw data
              https://192.168.1.209:8443/mc/rest/metrics/stats?uid=water-level&bucketDuration=raw&duration=10mn
            [ {
              "timestamp" : 1500565352695,
              "empty" : false,
              "min" : 97.9,
              "max" : 97.9,
              "avg" : 97.9,
              "samples" : 2
            }, {
              "timestamp" : 1500565412695,
              "empty" : false,
              "min" : 97.2,
              "max" : 97.2,
              "avg" : 97.2,
              "samples" : 1
            }, {
              "timestamp" : 1500565472695,
              "empty" : false,
              "min" : 97.2,
              "max" : 97.2,
              "avg" : 97.2,
              "samples" : 1
            }, {
              "timestamp" : 1500565532695,
              "empty" : false,
              "min" : 97.2,
              "max" : 97.2,
              "avg" : 97.2,
              "samples" : 2
            }, {
              "timestamp" : 1500565592695,
              "empty" : false,
              "min" : 97.2,
              "max" : 97.2,
              "avg" : 97.2,
              "samples" : 1
            }, {
              "timestamp" : 1500565652695,
              "empty" : false,
              "min" : 97.2,
              "max" : 97.2,
              "avg" : 97.2,
              "samples" : 1
            }, {
              "timestamp" : 1500565712695,
              "empty" : false,
              "min" : 97.2,
              "max" : 97.2,
              "avg" : 97.2,
              "samples" : 2
            }, {
              "timestamp" : 1500565772695,
              "empty" : false,
              "min" : 97.2,
              "max" : 97.2,
              "avg" : 97.2,
              "samples" : 1
            }, {
              "timestamp" : 1500565790547,
              "empty" : false,
              "min" : 97.2,
              "max" : 97.2,
              "avg" : 97.2,
              "samples" : 1
            }, {
              "timestamp" : 1500565835758,
              "empty" : false,
              "min" : 97.2,
              "max" : 97.2,
              "avg" : 97.2,
              "samples" : 1
            }, {
              "timestamp" : 1500565880537,
              "empty" : false,
              "min" : 97.2,
              "max" : 97.2,
              "avg" : 97.2,
              "samples" : 1
            } ]
            

            I hope this will address your requirement.

            N one-reply-to-this-post last-reply-time reply quote 0
            • N offline
              naguraob @jkandasa
              global:last-edited-by,

              @jkandasa
              Can you help me in getting this thing working. I get the following error message "HTTP 401 Unauthorized".
              I have an UID for a Sensor Variable named N001S01 and I use the following link where <rpi_ip> is replaced by the actual Raspberry Pi's IP Address.

              https://<rpi_ip>:8443/mc/rest/metrics/stats?uid=N001S01&bucketDuration=raw&duration=1h.

              jkandasaJ one-reply-to-this-post last-reply-time reply quote 0
              • jkandasaJ offline
                jkandasa @naguraob
                global:last-edited-by,

                @naguraob on your client you should add authentication details.

                one-reply-to-this-post last-reply-time reply quote 0
                • W offline
                  wkwj00
                  global:last-edited-by,

                  Hi, I have a similar question regarding using REST API functionality of mycontroler software - how can I send data to a sensor variable (having UID) from a remote station using REST request ?
                  The question may seem stupid but as my hardware sensor devices are very limitted in power supply (actually they realy only on harvested power) I cannot use mysensor library. However I can send http requests (via my own "specialized" wifi-connected gateway). So my sensors communicate directly with "my" gateway and I wont the gateway to send data to mycontroller software.
                  Any example would be appreciated.
                  Besides - mycontroller is really a nice piece of programmers work 🙂
                  Best regards,
                  wkwj00

                  jkandasaJ one-reply-to-this-post last-reply-time reply quote 0
                  • jkandasaJ offline
                    jkandasa @wkwj00
                    global:last-edited-by, jkandasa

                    @wkwj00 MyController does not have any direct support for REST API endpoints. You may use MQTT, or other REST API like Sparkfun, etc.,

                    one-reply-to-this-post last-reply-time reply quote 0
                    • first-post
                      last-post

                    0

                    online

                    644

                    users

                    532

                    topics

                    3.4k

                    posts
                    Copyright © 2015-2025 MyController.org | Contributors | Localization