huginn_myq_agent 0.1.1 → 0.2.4
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/lib/huginn_myq_agent/myq_agent.rb +24 -25
- 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: 44661a919fb795033e31e61b2dcb83f4d4ac0d9d1def390f13a21c9772cacedb
|
4
|
+
data.tar.gz: c9a7c998b1e184ee9b995a35d049fe732f2a2b34af84fb01a81be67fefb5791a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7b7243bbfa07a9cd9b308f970096db930ad4193f6cb9754ea6819ed4cbd4c903099dc8c455cb63d6ddde807fbcd475d0e843efbd396388646f9412d835f37b3
|
7
|
+
data.tar.gz: d88b15ef578028e55609a230622c7eb80992deeeeda26b2bb81e6efb78944c5983a0c11d763a72759d31f84f5c872837f905dea0251757a174eb63fd8fd15e99
|
@@ -7,21 +7,19 @@ module Agents
|
|
7
7
|
default_schedule '12h'
|
8
8
|
|
9
9
|
description <<-MD
|
10
|
-
|
10
|
+
Allows for the control of a Chamberlain MyQ garage door.
|
11
11
|
MD
|
12
12
|
|
13
13
|
def default_options
|
14
14
|
{
|
15
15
|
'email_address' => '',
|
16
16
|
'password' => '',
|
17
|
-
'door_name' => '',
|
18
|
-
'action' => ''
|
19
17
|
}
|
20
18
|
end
|
21
19
|
|
22
|
-
form_configurable :email_address
|
23
|
-
form_configurable :password
|
24
|
-
form_configurable :door_name,
|
20
|
+
form_configurable :email_address
|
21
|
+
form_configurable :password
|
22
|
+
form_configurable :door_name, roles: :completable
|
25
23
|
form_configurable :action, type: :array, values: ['status', 'open', 'close', 'toggle']
|
26
24
|
|
27
25
|
def validate_options
|
@@ -40,23 +38,32 @@ module Agents
|
|
40
38
|
end
|
41
39
|
|
42
40
|
def working?
|
43
|
-
|
44
|
-
|
41
|
+
!recent_error_logs?
|
42
|
+
end
|
43
|
+
|
44
|
+
def complete_door_name
|
45
|
+
system = create_system
|
46
|
+
system.garage_doors.map { |door| {id: door.name, text: door.name} }
|
45
47
|
end
|
46
48
|
|
47
49
|
def check
|
48
50
|
door = select_door(interpolated['door_name'])
|
49
51
|
if interpolated['action'] == 'status'
|
50
|
-
create_event :payload => status(door)
|
52
|
+
create_event :payload => status(door.name)
|
51
53
|
elsif interpolated['action'] == 'open'
|
52
54
|
open_door(door)
|
53
|
-
create_event :payload => status(door)
|
55
|
+
create_event :payload => status(door.name)
|
54
56
|
elsif interpolated['action'] == 'close'
|
55
|
-
|
56
|
-
create_event :payload => status(door)
|
57
|
+
close_door(door)
|
58
|
+
create_event :payload => status(door.name)
|
59
|
+
elsif interpolated['action'] == 'toggle'
|
60
|
+
toggle_door(door)
|
61
|
+
create_event :payload => status(door.name)
|
57
62
|
end
|
58
63
|
end
|
59
64
|
|
65
|
+
private
|
66
|
+
|
60
67
|
def create_system
|
61
68
|
system = RubyMyq::System.new(interpolated['email_address'],interpolated['password'])
|
62
69
|
end
|
@@ -66,27 +73,23 @@ module Agents
|
|
66
73
|
door = system.find_door_by_name(door_name)
|
67
74
|
end
|
68
75
|
|
69
|
-
def status(
|
70
|
-
door = select_door(door_name)
|
76
|
+
def status(door)
|
71
77
|
status = {
|
78
|
+
'name' => door.name,
|
72
79
|
'state' => door.status,
|
73
80
|
'since' => door.status_since
|
74
81
|
}
|
75
|
-
return status
|
76
82
|
end
|
77
83
|
|
78
|
-
def close_door(
|
79
|
-
door = select_door(door_name)
|
84
|
+
def close_door(door)
|
80
85
|
door.close
|
81
86
|
end
|
82
87
|
|
83
|
-
def open_door(
|
84
|
-
door = select_door(door_name)
|
88
|
+
def open_door(door)
|
85
89
|
door.open
|
86
90
|
end
|
87
91
|
|
88
|
-
def toggle_door(
|
89
|
-
door = select_door(door_name)
|
92
|
+
def toggle_door(dorr)
|
90
93
|
if door.status == "open"
|
91
94
|
door.close
|
92
95
|
elsif door.status == "closed"
|
@@ -94,9 +97,5 @@ module Agents
|
|
94
97
|
end
|
95
98
|
end
|
96
99
|
|
97
|
-
|
98
|
-
|
99
|
-
# def receive(incoming_events)
|
100
|
-
# end
|
101
100
|
end
|
102
101
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: huginn_myq_agent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jesse Gillies
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-11-
|
11
|
+
date: 2020-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|