• Recent
    • Tags
    • Popular
    • Register
    • Login

    Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

    Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website Mango 5 Documentation Website

    Sunrise/Sunset

    How-To
    3
    7
    2.3k
    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.
    • F
      fishfacs
      last edited by

      Hello,

      I'm trying to get sunrise and sunset times for my local area into a data point. I know that there are plenty of websites that serve this data in various forms and there are probably various different ways to approach this.

      I am just wondering if anyone has done anything like this before and what the recommended approach would be before I attempt it. I tried the forum search, but I didn't find any applicable results.

      Any suggestions?

      Thanks,

      1 Reply Last reply Reply Quote 0
      • phildunlapP
        phildunlap
        last edited by phildunlap

        Hi fishfacs,

        By far the easiest way would be to use the Http Retriever data source. After that it's a matter of picking a source for the information that is easy to regex the value out of.

        For instance, https://www.timeanddate.com/sun/usa/denver seems like it would be an easy page, because it has pretty simple text for the value and it isn't being fetched by a script (i.e. wget gets that information, too, not just a browser):

        <span class=four>Sunrise Today: </span><span class=three>7:06 am</span>
        <span class=four>Sunset Today: </span><span class=three>6:26 pm</span>
        
        1 Reply Last reply Reply Quote 0
        • phildunlapP
          phildunlap
          last edited by

          Here's an HTTP Retriever with sunrise and sunset points for the link in my last post:

          {
             "dataSources":[
                {
                   "xid":"DS_082d3c5d-adea-44b1-9076-332adfce9dfb",
                   "name":"fishfacs!",
                   "enabled":false,
                   "type":"HTTP_RETRIEVER",
                   "alarmLevels":{
                      "DATA_RETRIEVAL_FAILURE":"URGENT",
                      "POLL_ABORTED":"URGENT",
                      "SET_POINT_FAILURE":"URGENT",
                      "PARSE_EXCEPTION":"URGENT"
                   },
                   "purgeType":"YEARS",
                   "updatePeriodType":"HOURS",
                   "quantize":false,
                   "retries":0,
                   "setPointUrl":"",
                   "timeoutSeconds":30,
                   "updatePeriods":4,
                   "url":"https:\/\/www.timeanddate.com\/sun\/usa\/denver",
                   "editPermission":"",
                   "purgeOverride":false,
                   "purgePeriod":1
                }
             ],
             "dataPoints":[
                {
                   "xid":"DP_2bc4f110-c5b2-4d8d-bf9c-c1c62e24cf78",
                   "name":"Sunrise",
                   "enabled":true,
                   "loggingType":"ON_CHANGE",
                   "intervalLoggingPeriodType":"MINUTES",
                   "intervalLoggingType":"INSTANT",
                   "purgeType":"YEARS",
                   "pointLocator":{
                      "dataType":"ALPHANUMERIC",
                      "ignoreIfMissing":false,
                      "setPointName":"",
                      "settable":false,
                      "timeFormat":"",
                      "timeGroup":1,
                      "timeRegex":"",
                      "valueFormat":"",
                      "valueGroup":1,
                      "valueRegex":".*Sunrise Today:.*?(\\d?\\d:\\d\\d [ap]m).*"
                   },
                   "eventDetectors":[
                   ],
                   "plotType":"STEP",
                   "rollup":"NONE",
                   "unit":"",
                   "templateXid":"Alphanumeric_Default",
                   "simplifyType":"NONE",
                   "chartColour":"",
                   "chartRenderer":{
                      "type":"TABLE",
                      "limit":10
                   },
                   "dataSourceXid":"DS_082d3c5d-adea-44b1-9076-332adfce9dfb",
                   "defaultCacheSize":1,
                   "deviceName":"fishfacs!",
                   "discardExtremeValues":false,
                   "discardHighLimit":1.7976931348623157E308,
                   "discardLowLimit":-1.7976931348623157E308,
                   "intervalLoggingPeriod":15,
                   "intervalLoggingSampleWindowSize":0,
                   "overrideIntervalLoggingSamples":false,
                   "preventSetExtremeValues":false,
                   "purgeOverride":false,
                   "purgePeriod":1,
                   "readPermission":"",
                   "setExtremeHighLimit":1.7976931348623157E308,
                   "setExtremeLowLimit":-1.7976931348623157E308,
                   "setPermission":"",
                   "tags":{
                   },
                   "textRenderer":{
                      "type":"PLAIN",
                      "useUnitAsSuffix":true,
                      "unit":"",
                      "renderedUnit":"",
                      "suffix":""
                   },
                   "tolerance":0.0
                },
                {
                   "xid":"DP_edaa622a-8e7f-44b8-aaae-79d14206f0a0",
                   "name":"Sunset",
                   "enabled":true,
                   "loggingType":"ON_CHANGE",
                   "intervalLoggingPeriodType":"MINUTES",
                   "intervalLoggingType":"INSTANT",
                   "purgeType":"YEARS",
                   "pointLocator":{
                      "dataType":"ALPHANUMERIC",
                      "ignoreIfMissing":false,
                      "setPointName":"",
                      "settable":false,
                      "timeFormat":"",
                      "timeGroup":1,
                      "timeRegex":"",
                      "valueFormat":"",
                      "valueGroup":1,
                      "valueRegex":".*Sunset Today:.*?(\\d?\\d:\\d\\d [ap]m).*"
                   },
                   "eventDetectors":[
                   ],
                   "plotType":"STEP",
                   "rollup":"NONE",
                   "unit":"",
                   "templateXid":"Alphanumeric_Default",
                   "simplifyType":"NONE",
                   "chartColour":"",
                   "chartRenderer":{
                      "type":"TABLE",
                      "limit":10
                   },
                   "dataSourceXid":"DS_082d3c5d-adea-44b1-9076-332adfce9dfb",
                   "defaultCacheSize":1,
                   "deviceName":"fishfacs!",
                   "discardExtremeValues":false,
                   "discardHighLimit":1.7976931348623157E308,
                   "discardLowLimit":-1.7976931348623157E308,
                   "intervalLoggingPeriod":15,
                   "intervalLoggingSampleWindowSize":0,
                   "overrideIntervalLoggingSamples":false,
                   "preventSetExtremeValues":false,
                   "purgeOverride":false,
                   "purgePeriod":1,
                   "readPermission":"",
                   "setExtremeHighLimit":1.7976931348623157E308,
                   "setExtremeLowLimit":-1.7976931348623157E308,
                   "setPermission":"",
                   "tags":{
                   },
                   "textRenderer":{
                      "type":"PLAIN",
                      "useUnitAsSuffix":true,
                      "unit":"",
                      "renderedUnit":"",
                      "suffix":""
                   },
                   "tolerance":0.0
                }
             ]
          }
          
          1 Reply Last reply Reply Quote 0
          • F
            fishfacs
            last edited by

            I put the data point in exactly as above. Not as an import; just manually. I get the following error when I click the green Test Value checkbutton.

            "java.lang.IllegalArgumentException: Illegal character in opaque part at index 6: https://www.timeanddate.com/sun/usa/denver"

            My knowledge of regular expressions is not great. Any ideas on what I missed?

            1 Reply Last reply Reply Quote 0
            • phildunlapP
              phildunlap
              last edited by

              Did you get a whole stack trace?

              I would guess something is malformed in how you set up the URL in the data source? Idk, the JSON I provided works and has example regex.

              1 Reply Last reply Reply Quote 0
              • Jared WiltshireJ
                Jared Wiltshire
                last edited by

                A JSON/XML API might be easier
                e.g. Government (TSA) supplied API for sunset/sunrise that returns XML
                https://www.dhs.gov/mytsa-api-documentation

                Developer at Radix IoT

                1 Reply Last reply Reply Quote 0
                • F
                  fishfacs
                  last edited by

                  I figured it out. There was a typo in my URL. Thanks for this.

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