• Categories
  • Recent
  • Tags
  • Popular
  • Register
  • Login
  • Categories
  • Recent
  • Tags
  • Popular
  • Register
  • Login

Help logging data?

Scheduled Pinned Locked Moved General Discussion
8 Posts 4 Posters 2.4k Views 2 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    mattjones
    last edited by 19 Jul 2017, 10:25

    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?

    J 1 Reply Last reply 19 Jul 2017, 13:52 Reply Quote 0
    • J Offline
      jkandasa @mattjones
      last edited by 19 Jul 2017, 13:52

      @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

      1 Reply Last reply Reply Quote 0
      • M Offline
        mattjones
        last edited by 20 Jul 2017, 01:19

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

        J 1 Reply Last reply 20 Jul 2017, 15:52 Reply Quote 0
        • J Offline
          jkandasa @mattjones
          last edited by 20 Jul 2017, 15:52

          @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 1 Reply Last reply 11 Aug 2017, 18:16 Reply Quote 0
          • N Offline
            naguraob @jkandasa
            last edited by 11 Aug 2017, 18:16

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

            J 1 Reply Last reply 12 Aug 2017, 03:12 Reply Quote 0
            • J Offline
              jkandasa @naguraob
              last edited by 12 Aug 2017, 03:12

              @naguraob on your client you should add authentication details.

              1 Reply Last reply Reply Quote 0
              • W Offline
                wkwj00
                last edited by 7 Nov 2017, 20:11

                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

                J 1 Reply Last reply 9 Nov 2017, 16:51 Reply Quote 0
                • J Offline
                  jkandasa @wkwj00
                  last edited by jkandasa 11 Sept 2017, 22:22 9 Nov 2017, 16:51

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

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post

                  0

                  Online

                  588

                  Users

                  529

                  Topics

                  3.4k

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