atrea_control 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -1
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/atrea_control/duplex.rb +26 -9
- data/lib/atrea_control/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 857675ccedb6095d28dced21a663615a053d1d12704da407ea0e6c029bd657eb
|
4
|
+
data.tar.gz: e2ed731b15bd2d742e230da0ae1b0b276f3b3d8a47dacac9f920424891507ed8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98f9cbff3552cfc90bf823048d5724b56b0f40877a096bab44181c4890c310bda7c6bb2238376529c730070746455f36a5efe10fd0bf6d75ac62108c280052b9
|
7
|
+
data.tar.gz: 7b5737cdd13aae0767a6ed41329ddbb886c6002e2d2bb65b248a35306a582859056d32afd7253fab54ae026a22f487ce700ce095ceb4e0dcaf416d459961759b
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -58,7 +58,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
58
58
|
|
59
59
|
## Contributing
|
60
60
|
|
61
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
61
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/luk4s/atrea_control. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/luk4s/atrea_control/blob/master/CODE_OF_CONDUCT.md).
|
62
62
|
|
63
63
|
## Code of Conduct
|
64
64
|
|
data/lib/atrea_control/duplex.rb
CHANGED
@@ -8,8 +8,6 @@ module AtreaControl
|
|
8
8
|
class Duplex
|
9
9
|
CONTROL_URI = "https://control.atrea.eu/"
|
10
10
|
|
11
|
-
attr_reader :driver
|
12
|
-
|
13
11
|
# @param [String] login
|
14
12
|
# @param [String] password
|
15
13
|
# @param [Hash] sensors_map which box is related to sensor ID
|
@@ -21,10 +19,14 @@ module AtreaControl
|
|
21
19
|
@login = login
|
22
20
|
@password = password
|
23
21
|
@sensors = sensors_map
|
22
|
+
end
|
23
|
+
|
24
|
+
def driver
|
25
|
+
return @driver if defined?(@driver)
|
24
26
|
|
25
27
|
options = Selenium::WebDriver::Firefox::Options.new
|
26
28
|
options.headless! unless ENV["NO_HEADLESS"]
|
27
|
-
@driver
|
29
|
+
@driver ||= Selenium::WebDriver.for :firefox, options: options
|
28
30
|
end
|
29
31
|
|
30
32
|
def logged?
|
@@ -95,15 +97,30 @@ module AtreaControl
|
|
95
97
|
element.find_element(css: "div:first-child").text
|
96
98
|
end
|
97
99
|
|
98
|
-
|
99
|
-
"<AtreaControl name: '#{name}' outdoor_temperature: #{outdoor_temperature}°C current_power: #{current_power}% current_mode: '#{current_mode}>'"
|
100
|
-
end
|
101
|
-
|
100
|
+
# quit selenium browser
|
102
101
|
def close
|
103
102
|
@logged = false
|
104
103
|
driver.quit
|
105
104
|
end
|
106
105
|
|
106
|
+
def as_json(_options = nil)
|
107
|
+
{
|
108
|
+
logged: logged?,
|
109
|
+
current_mode: current_mode,
|
110
|
+
current_power: current_power,
|
111
|
+
outdoor_temperature: outdoor_temperature,
|
112
|
+
}
|
113
|
+
end
|
114
|
+
|
115
|
+
def to_json(*args)
|
116
|
+
as_json.to_json(*args)
|
117
|
+
end
|
118
|
+
|
119
|
+
def inspect
|
120
|
+
"<AtreaControl name: '#{name}' outdoor_temperature: #{outdoor_temperature}°C current_power: #{current_power}% current_mode: '#{current_mode}'>"
|
121
|
+
end
|
122
|
+
|
123
|
+
|
107
124
|
private
|
108
125
|
|
109
126
|
def logger
|
@@ -115,10 +132,10 @@ module AtreaControl
|
|
115
132
|
end
|
116
133
|
|
117
134
|
def finish_login
|
118
|
-
|
135
|
+
13.times do |i|
|
119
136
|
return true if open_dashboard
|
120
137
|
rescue Selenium::WebDriver::Error::NoSuchElementError => _e
|
121
|
-
t = 5 * (1 + i)
|
138
|
+
t = [5 * (1 + i), 25].min
|
122
139
|
logger.debug "waiting #{t}s for login..."
|
123
140
|
sleep t
|
124
141
|
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: 1.
|
4
|
+
version: 1.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-
|
11
|
+
date: 2021-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: selenium-webdriver
|