midea-air-condition 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7a7001346211ad18fb8e3f5fc2383024c6c4429a
4
- data.tar.gz: 47926522126546b46d17849330ea9141ded166e4
3
+ metadata.gz: 3af2b2f6acab9c8e14961b31c6d0511f733ca7fd
4
+ data.tar.gz: 2998975b1bfb8af9febf289bdcbdeae8d52fa6bd
5
5
  SHA512:
6
- metadata.gz: 90dcdb2e2342380400c117bd18dd57f8438882c38fd2e6dafea002bdcea0f66fc12eae9cae5e4ebe2095b8224d8a025ef17a503cbef113ee1f1dc6cfb9086991
7
- data.tar.gz: 49e96c6572017ac06b166a569e26bb07475292f93432ae418cd88bbe48c5795b5f8d66519d586362844f1d0f7bbcc4330e9a38cb33f09bccff89cb7f794fca9c
6
+ metadata.gz: 279731dd15a90ac4b307cc4f4cc8780a58bc3a398d2ae1181507952d800574b7b637bc20e19a54bc76e2e12d29043ce9daa58ac9ffe2b92014d977a4621832e0
7
+ data.tar.gz: 48682755e533e08db47ec47aa7c73fa5094d172d3431641e498ba44391b190aec9829ce2df8d90d77e159625307687a88fa3322ccbdda74d12544c4780e10bf5
@@ -71,6 +71,7 @@ class MideaCLI < Thor
71
71
  no_commands do
72
72
  def credentials
73
73
  return @credentials if @credentials
74
+
74
75
  if (@credentials = credentials_from_env)
75
76
  @credentials
76
77
  elsif (@credentials = credentials_from_yaml)
@@ -84,6 +85,7 @@ class MideaCLI < Thor
84
85
  env_variables = %w[MIDEA_AC_EMAIL MIDEA_AC_PASSWORD MIDEA_AC_APP_KEY]
85
86
  env_prefix = 'MIDEA_AC_'
86
87
  return nil unless env_variables.all? { |k| ENV.key? k }
88
+
87
89
  Hash[
88
90
  ENV.select { |k, _| env_variables.include?(k) }
89
91
  .map { |k, v| [k.gsub(env_prefix, '').downcase, v] }
@@ -92,11 +94,13 @@ class MideaCLI < Thor
92
94
 
93
95
  def credentials_from_yaml
94
96
  return nil unless File.file?(CONFIG_PATH)
97
+
95
98
  YAML.load_file(CONFIG_PATH)
96
99
  end
97
100
 
98
101
  def client
99
102
  return @client if @client
103
+
100
104
  @client = MideaAirCondition::Client.new(
101
105
  credentials['email'],
102
106
  credentials['password'],
@@ -113,6 +117,7 @@ class MideaCLI < Thor
113
117
  response = client.appliance_transparent_send(id, builder.finalize)
114
118
  rescue RuntimeError => e
115
119
  raise Thor::Error, 'The device is offline.' if e.message == 'the appliance is off line.'
120
+
116
121
  raise e
117
122
  end
118
123
 
@@ -19,6 +19,7 @@ module MideaAirCondition
19
19
 
20
20
  def add_command(command)
21
21
  raise Exception, 'Invalid argument' if command.is_a?(Command)
22
+
22
23
  @command += command.finalize(@security)
23
24
  end
24
25
 
@@ -106,7 +106,8 @@ module MideaAirCondition
106
106
  final += aes.update(b) + aes.final
107
107
  end
108
108
 
109
- final.unpack1('H*')
109
+ unpacked = final.unpack('H*')
110
+ unpacked.first
110
111
  end
111
112
  # rubocop:enable Metrics/AbcSize
112
113
  # rubocop:enable Metrics/MethodLength
@@ -3,5 +3,5 @@
3
3
  module MideaAirCondition
4
4
  # Current version to publish
5
5
  # Gemspec also uses this constant
6
- VERSION = '0.0.2'
6
+ VERSION = '0.0.3'
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: midea-air-condition
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Balazs Nadasdi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-03 00:00:00.000000000 Z
11
+ date: 2018-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json