atrea_control 2.0.0 → 2.1.0

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
  SHA256:
3
- metadata.gz: 01f3c707897b8cd1626855caaa5cd4758ebeae0497881dd5164c2fb67a610327
4
- data.tar.gz: f567bde666512960777679842366f249b0eff130e5a3fd1c487d5d652ef11687
3
+ metadata.gz: 47dfda0eb6906708f68c4d43dae4a9ed7249492e32150fb40e244302158a2f10
4
+ data.tar.gz: dd16ffa80d5b61380a14814690058165d3fc8b2e8ab79f3ca17d4ccf8f218e7e
5
5
  SHA512:
6
- metadata.gz: 6f4a7ef12bbfde071d91b350e6b100d4528c3275a2642680cf26117ace31ef9ca9ed3072aaad9cb38189f336ec563d4b764db13238248295fc84ecbfe6977f65
7
- data.tar.gz: d933b73a8afe23d567aba8f56d1d58060f53699fc5fadaa2eb897e9ff1a6f2e9aa1ed314b2f805a4923d08038c8db8924b7dfc2e5e155c6219a376e2fe05f84e
6
+ metadata.gz: 109c78b115fc8652a5f2b113c5ac14972ae8e7a469ca4453365edf01a3c8898f3e25c78bf39a7da02947440868ddcdcfa8f9a2b5a3f0be997ece7f6bc3598319
7
+ data.tar.gz: 696a0c42c1fe2b4881247753f318290e52450299cebeab73c2faffee8e7b151f5f4000e8896fe42ef227184ae881a0a324306f02d49d1aba416061a3620f8e0b
data/CHANGELOG.md CHANGED
@@ -1,4 +1,23 @@
1
1
  ## [Unreleased]
2
+
3
+ ## [2.1.0] - 2022-02-28
4
+ ### Added
5
+ - preheating is ON ?
6
+ - heat temperature
7
+ - current input temperature
8
+ ### Removed
9
+ - debug
10
+
11
+ ## [2.0.2] - 2022-01-20
12
+ ### Added
13
+ - debug unit values
14
+ - try token-based login (without success)
15
+
16
+ ## [2.0.1] - 2021-12-26
17
+ ### Fixed
18
+ - write correct arguments
19
+
20
+ ## [2.0.0] - 2021-12-26
2
21
  ### Changed
3
22
  - refactored codebase to more readable classes
4
23
  - selenium used only for login and then close => obtain SID (and user with unit)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- atrea_control (2.0.0)
4
+ atrea_control (2.1.0)
5
5
  i18n (~> 1.8)
6
6
  nokogiri (~> 1.12)
7
7
  rest-client (~> 2.1)
@@ -26,59 +26,59 @@ GEM
26
26
  http-accept (1.7.0)
27
27
  http-cookie (1.0.4)
28
28
  domain_name (~> 0.5)
29
- i18n (1.8.11)
29
+ i18n (1.10.0)
30
30
  concurrent-ruby (~> 1.0)
31
31
  method_source (1.0.0)
32
32
  mime-types (3.4.1)
33
33
  mime-types-data (~> 3.2015)
34
- mime-types-data (3.2021.1115)
34
+ mime-types-data (3.2022.0105)
35
35
  netrc (0.11.0)
36
- nokogiri (1.12.5-x86_64-darwin)
36
+ nokogiri (1.13.3-x86_64-darwin)
37
37
  racc (~> 1.4)
38
- nokogiri (1.12.5-x86_64-linux)
38
+ nokogiri (1.13.3-x86_64-linux)
39
39
  racc (~> 1.4)
40
40
  parallel (1.21.0)
41
- parser (3.0.3.2)
41
+ parser (3.1.1.0)
42
42
  ast (~> 2.4.1)
43
43
  pry (0.14.1)
44
44
  coderay (~> 1.1)
45
45
  method_source (~> 1.0)
46
46
  public_suffix (4.0.6)
47
47
  racc (1.6.0)
48
- rainbow (3.0.0)
48
+ rainbow (3.1.1)
49
49
  rake (13.0.6)
50
- regexp_parser (2.2.0)
50
+ regexp_parser (2.2.1)
51
51
  rest-client (2.1.0)
52
52
  http-accept (>= 1.7.0, < 2.0)
53
53
  http-cookie (>= 1.0.2, < 2.0)
54
54
  mime-types (>= 1.16, < 4.0)
55
55
  netrc (~> 0.8)
56
56
  rexml (3.2.5)
57
- rspec (3.10.0)
58
- rspec-core (~> 3.10.0)
59
- rspec-expectations (~> 3.10.0)
60
- rspec-mocks (~> 3.10.0)
61
- rspec-core (3.10.1)
62
- rspec-support (~> 3.10.0)
63
- rspec-expectations (3.10.1)
57
+ rspec (3.11.0)
58
+ rspec-core (~> 3.11.0)
59
+ rspec-expectations (~> 3.11.0)
60
+ rspec-mocks (~> 3.11.0)
61
+ rspec-core (3.11.0)
62
+ rspec-support (~> 3.11.0)
63
+ rspec-expectations (3.11.0)
64
64
  diff-lcs (>= 1.2.0, < 2.0)
65
- rspec-support (~> 3.10.0)
66
- rspec-mocks (3.10.2)
65
+ rspec-support (~> 3.11.0)
66
+ rspec-mocks (3.11.0)
67
67
  diff-lcs (>= 1.2.0, < 2.0)
68
- rspec-support (~> 3.10.0)
69
- rspec-support (3.10.3)
70
- rubocop (1.24.0)
68
+ rspec-support (~> 3.11.0)
69
+ rspec-support (3.11.0)
70
+ rubocop (1.25.1)
71
71
  parallel (~> 1.10)
72
- parser (>= 3.0.0.0)
72
+ parser (>= 3.1.0.0)
73
73
  rainbow (>= 2.2.2, < 4.0)
74
74
  regexp_parser (>= 1.8, < 3.0)
75
75
  rexml
76
- rubocop-ast (>= 1.15.0, < 2.0)
76
+ rubocop-ast (>= 1.15.1, < 2.0)
77
77
  ruby-progressbar (~> 1.7)
78
78
  unicode-display_width (>= 1.4.0, < 3.0)
79
- rubocop-ast (1.15.0)
80
- parser (>= 3.0.1.1)
81
- rubocop-rspec (2.6.0)
79
+ rubocop-ast (1.16.0)
80
+ parser (>= 3.1.1.0)
81
+ rubocop-rspec (2.9.0)
82
82
  rubocop (~> 1.19)
83
83
  ruby-progressbar (1.11.0)
84
84
  rubyzip (2.3.2)
@@ -91,7 +91,7 @@ GEM
91
91
  simplecov-html (~> 0.11)
92
92
  simplecov_json_formatter (~> 0.1)
93
93
  simplecov-html (0.12.3)
94
- simplecov_json_formatter (0.1.3)
94
+ simplecov_json_formatter (0.1.4)
95
95
  unf (0.1.4)
96
96
  unf_ext
97
97
  unf_ext (0.0.8)
@@ -1,3 +1,5 @@
1
+ require "digest"
2
+ require "rest-client"
1
3
  require "selenium-webdriver"
2
4
 
3
5
  module AtreaControl
@@ -23,6 +25,17 @@ module AtreaControl
23
25
  @login = login
24
26
  @password = password
25
27
  end
28
+ #
29
+ # def crypto_password
30
+ # md5 = Digest::MD5.new
31
+ # md5 << "\r\n"
32
+ # md5 << @password
33
+ # md5.hexdigest
34
+ # end
35
+ #
36
+ # def token
37
+ # RestClient.get "#{AtreaControl::Duplex::CONTROL_URI}/config/login.cgi", params: { magic: crypto_password }
38
+ # end
26
39
 
27
40
  def user
28
41
  raise AtreaControl::Error, "Must be logged in" unless login
@@ -4,6 +4,7 @@ module AtreaControl
4
4
  module Duplex
5
5
  # Process request with duplex unit itself. Handle response
6
6
  class Request
7
+ include AtreaControl::Logger
7
8
 
8
9
  # @param [String, Integer] user_id
9
10
  # @param [String, Integer] unit_id
@@ -6,7 +6,9 @@ module AtreaControl
6
6
  class Unit
7
7
  include AtreaControl::Logger
8
8
 
9
- attr_reader :current_mode, :current_power, :outdoor_temperature
9
+ attr_reader :current_mode, :current_power, :outdoor_temperature, :preheat_temperature, :input_temperature
10
+ # @return [Boolean] preheating air is ON ?
11
+ attr_reader :preheating
10
12
  # @return [DateTime] store time of last update
11
13
  attr_reader :valid_for
12
14
  # @return [UserCtrl]
@@ -35,20 +37,28 @@ module AtreaControl
35
37
  current_power || values[:current_power]
36
38
  end
37
39
 
40
+ def preheating?
41
+ preheating || values[:preheating]
42
+ end
43
+
38
44
  # @param [String] value 0 - power-off; 1 - automat
39
45
  def mode=(value)
40
- v = parser.input(@user_ctrl.sensors["mode_input"], value.to_s)
41
- write(v)
46
+ v = [parser.input(@user_ctrl.sensors["mode_input"], value.to_s)]
47
+ v << parser.input(@user_ctrl.sensors["mode_switch"], "2")
48
+ write(*v)
42
49
  end
43
50
 
44
51
  def power=(value)
45
- v = [parser.input(@user_ctrl.sensors["power_input"], value.to_s)]
46
- v << parser.input(@user_ctrl.sensors["mode_switch"], "2")
52
+ v = parser.input(@user_ctrl.sensors["power_input"], value.to_s)
47
53
  write(v)
48
54
  end
49
55
 
56
+ def parsed
57
+ parser.values(read.body)
58
+ end
59
+
50
60
  def values
51
- parser.values(read.body).each do |name, value|
61
+ parsed.each do |name, value|
52
62
  instance_variable_set :"@#{name}", value
53
63
  end
54
64
  as_json
@@ -59,6 +69,9 @@ module AtreaControl
59
69
  current_mode: current_mode,
60
70
  current_power: current_power,
61
71
  outdoor_temperature: outdoor_temperature,
72
+ preheat_temperature: preheat_temperature,
73
+ input_temperature: input_temperature,
74
+ preheating: preheating,
62
75
  valid_for: valid_for,
63
76
  }
64
77
  end
@@ -67,6 +80,13 @@ module AtreaControl
67
80
  values.to_json(*args)
68
81
  end
69
82
 
83
+ # Additional "parameters" for each sensors
84
+ # @note its changed in time ?
85
+ def params
86
+ response = request.call(_t: "user/params.xml")
87
+ Nokogiri::XML response.body
88
+ end
89
+
70
90
  private
71
91
 
72
92
  def parser
@@ -85,7 +105,7 @@ module AtreaControl
85
105
  # @param [Array<String>] values in format SENSOR0000VALUE
86
106
  def write(*values)
87
107
  inputs = values.to_h { |i| [i, nil] }
88
- logger.debug("set RD5 #{inputs.keys}")
108
+ logger.debug("set RD5 #{inputs}")
89
109
  request.call({ _t: "config/xml.cgi", _w: 1 }.merge(inputs))
90
110
  end
91
111
  end
@@ -54,8 +54,14 @@ module AtreaControl
54
54
  power_input = power.xpath("onchange").text[/getUrlPar\('(\w+)',val\)/, 1]
55
55
  m = mode.xpath("onchange").text.match(/getUrlPar\('(\w+)',val\).*getUrlPar\(.(\w+).,2\)/)
56
56
 
57
+ preheat_temperature = user_ctrl.xpath("//body/content/i[@title='$requiredTemp']")
58
+
59
+ input_temp = user_ctrl.xpath("//body/content/i[@title='$inletTemp']") # "I10200"
60
+ input_temperature = input_temp.xpath("displayval").text[/val=values\.(\w\d+);/, 1]
57
61
  @sensors = {
58
62
  "outdoor_temperature" => outdoor_temp.attribute("id").value, # "I10208"
63
+ "preheat_temperature" => preheat_temperature.attribute("id").value, # "H10706"
64
+ "input_temperature" => input_temperature,
59
65
  "current_power" => power.attribute("id").value, # "H10704"
60
66
  "current_mode" => mode.attribute("id").value, # "H10705"
61
67
  "current_mode_switch" => switch_mode, # "H10712"
@@ -6,6 +6,8 @@ module AtreaControl
6
6
  # Call RD5 unit ang get current sensors values
7
7
  # parse it and return Hash
8
8
  class SensorParser
9
+ include AtreaControl::Logger
10
+
9
11
  # @param [AtreaControl::Duplex::UserCtrl] user_ctrl
10
12
  def initialize(user_ctrl)
11
13
  @user_ctrl = user_ctrl
@@ -28,13 +30,21 @@ module AtreaControl
28
30
  # values[key]=values[key]/params[key].coef;
29
31
  def parse(xml)
30
32
  xml = Nokogiri::XML xml
31
- @user_ctrl.sensors.transform_values do |id|
32
- value = xml.xpath("//O[@I=\"#{id}\"]/@V").last&.value.to_i
33
+ parsed = @user_ctrl.sensors.transform_values do |id|
34
+ # node = xml.xpath("//O[@I=\"#{id}\"]/@V").last
35
+ node = xml.xpath("//O[@I=\"#{id}\"]").last
36
+ # logger.debug node.to_s
37
+ value = node.attribute("V").value.to_i
33
38
  value -= 65_536 if value > 32_767
34
39
  # value -= 0 if "offset"
35
- # value -= 0 if "coef"
40
+ # value = value / coef if "coef"
36
41
  value
37
42
  end
43
+ preheating = %w[C10200 C10202 C10215 C10217].any? do |i|
44
+ xml.xpath("//O[@I=\"#{i}\"]/@V").last&.value == "1"
45
+ end
46
+ parsed["preheating"] = preheating
47
+ parsed
38
48
  end
39
49
 
40
50
  # @param [Hash] values
@@ -44,6 +54,9 @@ module AtreaControl
44
54
  "current_mode" => parse_current_mode(values),
45
55
  "current_power" => values["current_power"].to_f,
46
56
  "outdoor_temperature" => values["outdoor_temperature"].to_f / 10.0,
57
+ "preheat_temperature" => values["preheat_temperature"].to_f / 10.0,
58
+ "input_temperature" => values["input_temperature"].to_f / 10.0,
59
+ "preheating" => !!values["preheating"],
47
60
  "valid_for" => Time.now,
48
61
  }
49
62
  end
@@ -53,10 +66,10 @@ module AtreaControl
53
66
  # `current_mode_switch` = mode trigger by wall switch or something similar
54
67
  # `current_mode` = is common "builtin" mode
55
68
  def parse_current_mode(values)
56
- if values['current_mode_switch'].positive?
57
- @user_ctrl.user_modes[values['current_mode_switch'].to_s]
69
+ if values["current_mode_switch"].positive?
70
+ @user_ctrl.user_modes[values["current_mode_switch"].to_s]
58
71
  else
59
- @user_ctrl.modes[values['current_mode'].to_s]
72
+ @user_ctrl.modes[values["current_mode"].to_s]
60
73
  end
61
74
  end
62
75
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module AtreaControl
4
4
 
5
- VERSION = "2.0.0"
5
+ VERSION = "2.1.0"
6
6
 
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: atrea_control
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lukáš Pokorný
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-12-25 00:00:00.000000000 Z
11
+ date: 2022-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n