nature_remo_e 1.0.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +1 -1
- data/.rubocop.yml +1 -0
- data/CHANGELOG.md +10 -1
- data/Gemfile +0 -3
- data/README.md +39 -0
- data/exe/remoe +6 -0
- data/lib/nature_remo_e/cli.rb +59 -0
- data/lib/nature_remo_e/client.rb +18 -11
- data/lib/nature_remo_e/version.rb +1 -1
- data/lib/nature_remo_e.rb +2 -0
- data/lib/patches/thor_ext.rb +26 -0
- data/nature_remo_e.gemspec +3 -2
- metadata +31 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67168370d37a3df1c18c38ac393b5f36d65016f15845d304811403d0fce63200
|
4
|
+
data.tar.gz: 8b6182c418a3731a6db967f3133eff7ad99ec7c817662a0733dad35ab4508662
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67dc246c78b27ee6f97a995acd77b5cf5dde2622e6a25e6df0c54ed3b4e338b30761670050111f42c8030a0e0b0727bebde2fcba050aa4926ae4fdcd4acc4f59
|
7
|
+
data.tar.gz: c423e40de4205b13de03e5f07438c36c7eb679654621b23aff512d8b094e7f7edce4bad60a85514743bc810a47326e0c1abac491555f34825e3d3ae27a825469
|
data/.github/workflows/main.yml
CHANGED
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
## Unreleased
|
2
|
-
[full changelog](https://github.com/ytkg/nature_remo_e/compare/
|
2
|
+
[full changelog](https://github.com/ytkg/nature_remo_e/compare/v2.0.0...main)
|
3
|
+
|
4
|
+
## v2.0.0
|
5
|
+
[full changelog](https://github.com/ytkg/nature_remo_e/compare/v1.0.2...v2.0.0)
|
6
|
+
|
7
|
+
* :bomb: **[BREAKING CHANGE]** Drop support ruby 2.5
|
8
|
+
* https://github.com/ytkg/nature_remo_e/pull/3
|
9
|
+
|
10
|
+
* Add CLI command
|
11
|
+
* https://github.com/ytkg/nature_remo_e/pull/5
|
3
12
|
|
4
13
|
## v1.0.2
|
5
14
|
[full changelog](https://github.com/ytkg/nature_remo_e/compare/v1.0.1...v1.0.2)
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -54,6 +54,45 @@ client.measured_instantaneous
|
|
54
54
|
#=> 630
|
55
55
|
```
|
56
56
|
|
57
|
+
### CLI
|
58
|
+
```bash
|
59
|
+
$ remoe
|
60
|
+
coefficient: 1
|
61
|
+
cumulative_electric_energy_effective_digits: 6
|
62
|
+
normal_direction_cumulative_electric_energy: 72164
|
63
|
+
cumulative_electric_energy_unit: 1
|
64
|
+
reverse_direction_cumulative_electric_energy: 10
|
65
|
+
measured_instantaneous: 651
|
66
|
+
|
67
|
+
$ bundle exec ruby exe/remoe --json | jq .
|
68
|
+
{
|
69
|
+
"coefficient": 1,
|
70
|
+
"cumulative_electric_energy_effective_digits": 6,
|
71
|
+
"normal_direction_cumulative_electric_energy": 72164,
|
72
|
+
"cumulative_electric_energy_unit": 1,
|
73
|
+
"reverse_direction_cumulative_electric_energy": 10,
|
74
|
+
"measured_instantaneous": 651
|
75
|
+
}
|
76
|
+
|
77
|
+
$ remoe coefficient
|
78
|
+
1
|
79
|
+
|
80
|
+
$ remoe cumulative_electric_energy_effective_digits
|
81
|
+
6
|
82
|
+
|
83
|
+
$ remoe normal_direction_cumulative_electric_energy
|
84
|
+
72164
|
85
|
+
|
86
|
+
$ remoe cumulative_electric_energy_unit
|
87
|
+
1
|
88
|
+
|
89
|
+
$ remoe reverse_direction_cumulative_electric_energy
|
90
|
+
10
|
91
|
+
|
92
|
+
$ remoe measured_instantaneous
|
93
|
+
651
|
94
|
+
```
|
95
|
+
|
57
96
|
## Development
|
58
97
|
|
59
98
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/exe/remoe
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
|
5
|
+
module NatureRemoE
|
6
|
+
class Cli < Thor
|
7
|
+
default_command :all
|
8
|
+
|
9
|
+
desc 'all', 'Get all value'
|
10
|
+
option 'json', type: :boolean
|
11
|
+
def all
|
12
|
+
return puts echonetlite_properties.to_json if options['json']
|
13
|
+
|
14
|
+
echonetlite_properties.each do |name, value|
|
15
|
+
puts "#{name}: #{value}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
desc 'coefficient', 'Get coefficient value'
|
20
|
+
def coefficient
|
21
|
+
puts echonetlite_properties[:coefficient]
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'cumulative_electric_energy_effective_digits', 'Get cumulative_electric_energy_effective_digits value'
|
25
|
+
def cumulative_electric_energy_effective_digits
|
26
|
+
puts echonetlite_properties[:cumulative_electric_energy_effective_digits]
|
27
|
+
end
|
28
|
+
|
29
|
+
desc 'normal_direction_cumulative_electric_energy', 'Get normal_direction_cumulative_electric_energy value'
|
30
|
+
def normal_direction_cumulative_electric_energy
|
31
|
+
puts echonetlite_properties[:normal_direction_cumulative_electric_energy]
|
32
|
+
end
|
33
|
+
|
34
|
+
desc 'cumulative_electric_energy_unit', 'Get cumulative_electric_energy_unit value'
|
35
|
+
def cumulative_electric_energy_unit
|
36
|
+
puts echonetlite_properties[:cumulative_electric_energy_unit]
|
37
|
+
end
|
38
|
+
|
39
|
+
desc 'reverse_direction_cumulative_electric_energy', 'Get reverse_direction_cumulative_electric_energy value'
|
40
|
+
def reverse_direction_cumulative_electric_energy
|
41
|
+
puts echonetlite_properties[:reverse_direction_cumulative_electric_energy]
|
42
|
+
end
|
43
|
+
|
44
|
+
desc 'measured_instantaneous', 'Get measured_instantaneous value'
|
45
|
+
def measured_instantaneous
|
46
|
+
puts echonetlite_properties[:measured_instantaneous]
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def echonetlite_properties
|
52
|
+
client = NatureRemoE::Client.new(ENV['NATURE_REMO_API_TOKEN'])
|
53
|
+
client.echonetlite_properties
|
54
|
+
rescue StandardError => e
|
55
|
+
puts e.message
|
56
|
+
exit!
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/lib/nature_remo_e/client.rb
CHANGED
@@ -5,14 +5,17 @@ require 'json'
|
|
5
5
|
|
6
6
|
module NatureRemoE
|
7
7
|
class Client
|
8
|
+
BASE_URL = 'https://api.nature.global'
|
9
|
+
API_VERSION = '1'
|
10
|
+
|
8
11
|
def initialize(token)
|
9
12
|
@token = token
|
10
13
|
end
|
11
14
|
|
12
15
|
def echonetlite_properties
|
13
|
-
device[:smart_meter][:echonetlite_properties].
|
16
|
+
device[:smart_meter][:echonetlite_properties].to_h do |echonetlite_property|
|
14
17
|
[echonetlite_property[:name].to_sym, echonetlite_property[:val].to_i]
|
15
|
-
end
|
18
|
+
end
|
16
19
|
end
|
17
20
|
|
18
21
|
def coefficient
|
@@ -41,21 +44,25 @@ module NatureRemoE
|
|
41
44
|
|
42
45
|
private
|
43
46
|
|
47
|
+
def headers
|
48
|
+
{
|
49
|
+
'User-Agent' => "NatureRemoE v#{NatureRemoE::VERSION} (https://github.com/ytkg/nature_remo_e)",
|
50
|
+
'Authorization' => "Bearer #{@token}"
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
44
54
|
def client
|
45
|
-
@client ||= Faraday.new(
|
46
|
-
|
47
|
-
|
48
|
-
)
|
55
|
+
@client ||= Faraday.new(url: "#{BASE_URL}/#{API_VERSION}", headers: headers) do |f|
|
56
|
+
f.response :json, parser_options: { symbolize_names: true }
|
57
|
+
end
|
49
58
|
end
|
50
59
|
|
51
60
|
def appliances
|
52
|
-
response = client.get
|
53
|
-
req.url '/1/appliances'
|
54
|
-
end
|
61
|
+
response = client.get('appliances')
|
55
62
|
|
56
|
-
raise NatureRemoE::Error,
|
63
|
+
raise NatureRemoE::Error, response.body[:message] if response.status != 200
|
57
64
|
|
58
|
-
|
65
|
+
response.body
|
59
66
|
end
|
60
67
|
|
61
68
|
def device
|
data/lib/nature_remo_e.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
# rubocop:disable all
|
2
|
+
class Thor
|
3
|
+
class << self
|
4
|
+
def exit_on_failure?
|
5
|
+
true
|
6
|
+
end
|
7
|
+
|
8
|
+
def help(shell, subcommand = false)
|
9
|
+
list = printable_commands(true, subcommand)
|
10
|
+
Thor::Util.thor_classes_in(self).each do |klass|
|
11
|
+
list += klass.printable_commands(false)
|
12
|
+
end
|
13
|
+
# list.sort! { |a, b| a[0] <=> b[0] }
|
14
|
+
|
15
|
+
if defined?(@package_name) && @package_name
|
16
|
+
shell.say "#{@package_name} commands:"
|
17
|
+
else
|
18
|
+
shell.say "Commands:"
|
19
|
+
end
|
20
|
+
|
21
|
+
shell.print_table(list, :indent => 2, :truncate => true)
|
22
|
+
shell.say
|
23
|
+
class_options_help(shell)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/nature_remo_e.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
12
12
|
# spec.description = "TODO: Write a longer description or delete this line."
|
13
13
|
spec.homepage = "https://github.com/ytkg/nature_remo_e"
|
14
14
|
spec.license = "MIT"
|
15
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
|
16
16
|
|
17
17
|
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
18
18
|
|
@@ -31,7 +31,8 @@ Gem::Specification.new do |spec|
|
|
31
31
|
|
32
32
|
# Uncomment to register a new dependency of your gem
|
33
33
|
# spec.add_dependency "example-gem", "~> 1.0"
|
34
|
-
spec.add_dependency "faraday", "
|
34
|
+
spec.add_dependency "faraday", ">= 2.0.0"
|
35
|
+
spec.add_dependency "thor"
|
35
36
|
|
36
37
|
# For more information and examples about making a new gem, checkout our
|
37
38
|
# guide at: https://bundler.io/guides/creating_gem.html
|
metadata
CHANGED
@@ -1,33 +1,48 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nature_remo_e
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yoshiki Takagi
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-01-
|
11
|
+
date: 2022-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
27
|
-
|
26
|
+
version: 2.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: thor
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description:
|
28
42
|
email:
|
29
43
|
- yoshiki.tkg@gmail.com
|
30
|
-
executables:
|
44
|
+
executables:
|
45
|
+
- remoe
|
31
46
|
extensions: []
|
32
47
|
extra_rdoc_files: []
|
33
48
|
files:
|
@@ -43,9 +58,12 @@ files:
|
|
43
58
|
- Rakefile
|
44
59
|
- bin/console
|
45
60
|
- bin/setup
|
61
|
+
- exe/remoe
|
46
62
|
- lib/nature_remo_e.rb
|
63
|
+
- lib/nature_remo_e/cli.rb
|
47
64
|
- lib/nature_remo_e/client.rb
|
48
65
|
- lib/nature_remo_e/version.rb
|
66
|
+
- lib/patches/thor_ext.rb
|
49
67
|
- nature_remo_e.gemspec
|
50
68
|
homepage: https://github.com/ytkg/nature_remo_e
|
51
69
|
licenses:
|
@@ -53,7 +71,7 @@ licenses:
|
|
53
71
|
metadata:
|
54
72
|
homepage_uri: https://github.com/ytkg/nature_remo_e
|
55
73
|
source_code_uri: https://github.com/ytkg/nature_remo_e
|
56
|
-
post_install_message:
|
74
|
+
post_install_message:
|
57
75
|
rdoc_options: []
|
58
76
|
require_paths:
|
59
77
|
- lib
|
@@ -61,15 +79,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
61
79
|
requirements:
|
62
80
|
- - ">="
|
63
81
|
- !ruby/object:Gem::Version
|
64
|
-
version: 2.
|
82
|
+
version: 2.6.0
|
65
83
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
84
|
requirements:
|
67
85
|
- - ">="
|
68
86
|
- !ruby/object:Gem::Version
|
69
87
|
version: '0'
|
70
88
|
requirements: []
|
71
|
-
rubygems_version: 3.
|
72
|
-
signing_key:
|
89
|
+
rubygems_version: 3.3.3
|
90
|
+
signing_key:
|
73
91
|
specification_version: 4
|
74
92
|
summary: Nature Remo API client for Nature Remo E
|
75
93
|
test_files: []
|