weathermatic 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/weathermatic.rb +35 -71
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76acfca5dc6a2378360f64bfa4c4b93a3ad41a26
|
4
|
+
data.tar.gz: 9c7e8ed7df3823f9e0e7b4b7fac9b67391e38fb6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b6b4052d2b7dabc8896f5747ca588fd66d22552c1463d8862eeea90009ec672d5e0f04f96bc57dfd4e6f6888f0647498ec095726e1ea24272e2c53974e35bd6
|
7
|
+
data.tar.gz: b0bc8405834d04735312f2d7d713c953dc2c7e35dd9791f155031ca7b952369fa9a506869bbcfe6b551c56e4dab75623575408f4bdb73c7122a05451d371270e
|
data/lib/weathermatic.rb
CHANGED
@@ -12,8 +12,9 @@ class WeatherMatic
|
|
12
12
|
def initialize(args)
|
13
13
|
@username = args[:username]
|
14
14
|
@password = args[:password]
|
15
|
-
@base_uri = "https://my.smartlinknetwork.com"
|
15
|
+
# @base_uri = "https://my.smartlinknetwork.com"
|
16
16
|
# @base_uri = 'http://localhost:3000'
|
17
|
+
@base_uri = 'https://beta.smartlinknetwork.com'
|
17
18
|
end
|
18
19
|
|
19
20
|
# All requests are essentially the same - the purpose of this note is really just to show the basic authorization header for reference
|
@@ -97,7 +98,7 @@ class WeatherMatic
|
|
97
98
|
|
98
99
|
def sites_list
|
99
100
|
uri = parse_uri(@base_uri+"/api/v2/sites?"+add_timestamp)
|
100
|
-
puts uri
|
101
|
+
# puts uri
|
101
102
|
@request = make_get(uri)
|
102
103
|
make_request(uri,@request)
|
103
104
|
end
|
@@ -436,140 +437,108 @@ class WeatherMatic
|
|
436
437
|
# Usage: wm.site_usage(:site_id => 157, :controller_id => [794,750], :range_start => "2014-06-01", :range_end => "2014-07-25", :interval => 'w' )
|
437
438
|
|
438
439
|
# Example Response: (all units are in gallons for this site)
|
439
|
-
# {
|
440
|
-
# "meta":{
|
440
|
+
# {
|
441
|
+
# "meta":{
|
441
442
|
# "access":true,
|
442
443
|
# "hmac":true,
|
443
444
|
# "success":true,
|
444
|
-
# "request":{
|
445
|
+
# "request":{
|
445
446
|
# "range_start":"2014-06-01",
|
446
447
|
# "range_end":"2014-07-25",
|
447
448
|
# "interval":"w",
|
448
|
-
# "controller_id":[
|
449
|
+
# "controller_id":[
|
449
450
|
# "794",
|
450
451
|
# "750"
|
451
452
|
# ],
|
452
453
|
# "zone_number":null,
|
453
|
-
# "timestamp":"
|
454
|
+
# "timestamp":"1407506612",
|
454
455
|
# "action":"usage",
|
455
456
|
# "controller":"api/v2/reports_sites",
|
456
457
|
# "id":"157",
|
457
458
|
# "format":"json",
|
458
|
-
# "reports_site":{
|
459
|
+
# "reports_site":{
|
459
460
|
|
460
461
|
# }
|
461
462
|
# },
|
462
463
|
# "message":null
|
463
464
|
# },
|
464
|
-
# "result":{
|
465
|
-
# "site":{
|
465
|
+
# "result":{
|
466
|
+
# "site":{
|
466
467
|
# "id":157,
|
467
468
|
# "name":"Engineering Dept",
|
468
|
-
# "controllers":[
|
469
|
-
# {
|
469
|
+
# "controllers":[
|
470
|
+
# {
|
470
471
|
# "id":750,
|
471
472
|
# "name":"Andey's",
|
472
|
-
# "usage":[
|
473
|
-
# {
|
473
|
+
# "usage":[
|
474
|
+
# {
|
474
475
|
# "gallons":1512,
|
475
|
-
# "seconds_ran":19166,
|
476
|
-
# "realtime_average_flow":null,
|
477
476
|
# "date":"2014-06-02"
|
478
477
|
# },
|
479
|
-
# {
|
478
|
+
# {
|
480
479
|
# "gallons":1454,
|
481
|
-
# "seconds_ran":16980,
|
482
|
-
# "realtime_average_flow":null,
|
483
480
|
# "date":"2014-06-09"
|
484
481
|
# },
|
485
|
-
# {
|
482
|
+
# {
|
486
483
|
# "gallons":1240,
|
487
|
-
# "seconds_ran":19788,
|
488
|
-
# "realtime_average_flow":null,
|
489
484
|
# "date":"2014-06-16"
|
490
485
|
# },
|
491
|
-
# {
|
486
|
+
# {
|
492
487
|
# "gallons":1620,
|
493
|
-
# "seconds_ran":16526,
|
494
|
-
# "realtime_average_flow":null,
|
495
488
|
# "date":"2014-06-23"
|
496
489
|
# },
|
497
|
-
# {
|
490
|
+
# {
|
498
491
|
# "gallons":1582,
|
499
|
-
# "seconds_ran":17794,
|
500
|
-
# "realtime_average_flow":null,
|
501
492
|
# "date":"2014-06-30"
|
502
493
|
# },
|
503
|
-
# {
|
494
|
+
# {
|
504
495
|
# "gallons":1217,
|
505
|
-
# "seconds_ran":15418,
|
506
|
-
# "realtime_average_flow":null,
|
507
496
|
# "date":"2014-07-07"
|
508
497
|
# },
|
509
|
-
# {
|
498
|
+
# {
|
510
499
|
# "gallons":1357,
|
511
|
-
# "seconds_ran":15333,
|
512
|
-
# "realtime_average_flow":null,
|
513
500
|
# "date":"2014-07-14"
|
514
501
|
# },
|
515
|
-
# {
|
502
|
+
# {
|
516
503
|
# "gallons":454,
|
517
|
-
# "seconds_ran":15325,
|
518
|
-
# "realtime_average_flow":null,
|
519
504
|
# "date":"2014-07-21"
|
520
505
|
# }
|
521
506
|
# ]
|
522
507
|
# },
|
523
|
-
# {
|
508
|
+
# {
|
524
509
|
# "id":794,
|
525
510
|
# "name":"Plan-Id Test - 1 year basic",
|
526
|
-
# "usage":[
|
527
|
-
# {
|
511
|
+
# "usage":[
|
512
|
+
# {
|
528
513
|
# "gallons":8306,
|
529
|
-
# "seconds_ran":32978,
|
530
|
-
# "realtime_average_flow":null,
|
531
514
|
# "date":"2014-06-02"
|
532
515
|
# },
|
533
|
-
# {
|
516
|
+
# {
|
534
517
|
# "gallons":9015,
|
535
|
-
# "seconds_ran":38352,
|
536
|
-
# "realtime_average_flow":null,
|
537
518
|
# "date":"2014-06-09"
|
538
519
|
# },
|
539
|
-
# {
|
520
|
+
# {
|
540
521
|
# "gallons":8068,
|
541
|
-
# "seconds_ran":35777,
|
542
|
-
# "realtime_average_flow":null,
|
543
522
|
# "date":"2014-06-16"
|
544
523
|
# },
|
545
|
-
# {
|
524
|
+
# {
|
546
525
|
# "gallons":8564,
|
547
|
-
# "seconds_ran":34419,
|
548
|
-
# "realtime_average_flow":null,
|
549
526
|
# "date":"2014-06-23"
|
550
527
|
# },
|
551
|
-
# {
|
528
|
+
# {
|
552
529
|
# "gallons":8693,
|
553
|
-
# "seconds_ran":38603,
|
554
|
-
# "realtime_average_flow":null,
|
555
530
|
# "date":"2014-06-30"
|
556
531
|
# },
|
557
|
-
# {
|
532
|
+
# {
|
558
533
|
# "gallons":7871,
|
559
|
-
# "seconds_ran":37822,
|
560
|
-
# "realtime_average_flow":null,
|
561
534
|
# "date":"2014-07-07"
|
562
535
|
# },
|
563
|
-
# {
|
536
|
+
# {
|
564
537
|
# "gallons":5892,
|
565
|
-
# "seconds_ran":33325,
|
566
|
-
# "realtime_average_flow":null,
|
567
538
|
# "date":"2014-07-14"
|
568
539
|
# },
|
569
|
-
# {
|
540
|
+
# {
|
570
541
|
# "gallons":949,
|
571
|
-
# "seconds_ran":29000,
|
572
|
-
# "realtime_average_flow":null,
|
573
542
|
# "date":"2014-07-21"
|
574
543
|
# }
|
575
544
|
# ]
|
@@ -588,7 +557,7 @@ class WeatherMatic
|
|
588
557
|
"zone_number" => params[:zone_number],
|
589
558
|
"timestamp" => Time.now.to_i.to_s
|
590
559
|
})
|
591
|
-
uri = parse_uri(@base_uri+"/api/v2/
|
560
|
+
uri = parse_uri(@base_uri+"/api/v2/sites/"+params[:site_id].to_s+"/report/usage.json?" + data)
|
592
561
|
@request = make_get(uri)
|
593
562
|
make_request(uri,@request)
|
594
563
|
end
|
@@ -688,7 +657,7 @@ class WeatherMatic
|
|
688
657
|
"controller_id[]" => params[:controller_id],
|
689
658
|
"timestamp" => Time.now.to_i.to_s
|
690
659
|
})
|
691
|
-
uri = parse_uri(@base_uri+"/api/v2/
|
660
|
+
uri = parse_uri(@base_uri+"/api/v2/sites/"+params[:site_id].to_s+"/report/weather.json?"+data)
|
692
661
|
@request = make_get(uri)
|
693
662
|
make_request(uri,@request)
|
694
663
|
end
|
@@ -696,7 +665,6 @@ class WeatherMatic
|
|
696
665
|
# Example
|
697
666
|
# params[:range_start] should be passed as 'YYYY-MM-DD' as the start date (on and after) you would like a usage report from
|
698
667
|
# params[:range_end] should be passed as 'YYYY-MM-DD' as the end date (on and before) you would like the usage report from
|
699
|
-
# params[:interval] *optional* w = Weekly Intervals, m = Monthly Intervals, y = Yearly Intervals. SUM of the usage by Interval passed
|
700
668
|
# params[:controller_id] *optional* pass a specific controller ID or an array of controller IDs with the request to get controller usage instead of entire SITE usage
|
701
669
|
# params[:zone_number] *optional* pass a specific zone number or an array of zone numbers with the request to get zone usage instead of entire SITE usage (DEPENDS ON SINGLE CONTROLLER ID ALSO BEING PASSED)
|
702
670
|
|
@@ -711,7 +679,6 @@ class WeatherMatic
|
|
711
679
|
# "request":{
|
712
680
|
# "range_start":"2013-12-01",
|
713
681
|
# "range_end":"2013-12-30",
|
714
|
-
# "interval":null,
|
715
682
|
# "controller_id":[
|
716
683
|
# "699",
|
717
684
|
# "700"
|
@@ -881,17 +848,15 @@ class WeatherMatic
|
|
881
848
|
data = URI.encode_www_form({
|
882
849
|
"range_start" => params[:range_start],
|
883
850
|
"range_end" => params[:range_end],
|
884
|
-
"interval" => params[:interval],
|
885
851
|
"controller_id[]" => params[:controller_id],
|
886
852
|
"zone_number[]" => params[:zone_number],
|
887
853
|
"timestamp" => Time.now.to_i.to_s
|
888
854
|
})
|
889
|
-
uri = parse_uri(@base_uri+"/api/v2/
|
855
|
+
uri = parse_uri(@base_uri+"/api/v2/sites/"+params[:site_id].to_s+"/report/events.json?"+data)
|
890
856
|
@request = make_get(uri)
|
891
857
|
make_request(uri,@request)
|
892
858
|
end
|
893
859
|
|
894
|
-
|
895
860
|
private
|
896
861
|
|
897
862
|
# This is the generic request - it cannot be called directly
|
@@ -933,7 +898,6 @@ class WeatherMatic
|
|
933
898
|
def secret_api_key
|
934
899
|
ENV['SLN_API_SECRET_KEY']
|
935
900
|
# '245aa67451c534803dc93e7953ff40b6' # This should be an environment variable for best security - this is not a production key
|
936
|
-
# '245aa67451c534803dc93e7953ffffff'
|
937
901
|
end
|
938
902
|
|
939
903
|
def make_get(uri)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: weathermatic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler Merritt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: SmartLink provides a web portal which connects SmartLine controllers
|
14
14
|
in the field to the cloud allowing basic operations like starting or stopping irrigation
|