huginn_myq_agent 0.0.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/huginn_myq_agent/myq_agent.rb +20 -24
- 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: 22ebb0df9739af60226e463ea6468fe1501513f243beca6ddde073d458495c22
|
4
|
+
data.tar.gz: 8ea02626edc18e961e290559564d0a1a5608c6301594858a8932ca361971e6ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf2b063dede17692b573450be4ce66a33875c55bb7427bc5d4bc2d176bd1086ce262379f0dfb04a82781c0006ab442532f3ea410fd5e689c110dd547cb5eb0f8
|
7
|
+
data.tar.gz: 3c1a325fd24fb0bbfd392c91560a835d99ec256641ef1f58a4e5d5b67302516ae207e2cc7602e7453c88b3ebae0a804becf7b581a2d6238115d4ab41b75a31cf
|
@@ -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,29 @@ 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
57
|
close(door)
|
56
|
-
create_event :payload => status(door)
|
58
|
+
create_event :payload => status(door.name)
|
57
59
|
end
|
58
60
|
end
|
59
61
|
|
62
|
+
private
|
63
|
+
|
60
64
|
def create_system
|
61
65
|
system = RubyMyq::System.new(interpolated['email_address'],interpolated['password'])
|
62
66
|
end
|
@@ -66,27 +70,23 @@ module Agents
|
|
66
70
|
door = system.find_door_by_name(door_name)
|
67
71
|
end
|
68
72
|
|
69
|
-
def status(
|
70
|
-
door = select_door(door_name)
|
73
|
+
def status(door)
|
71
74
|
status = {
|
75
|
+
'name' => door.name,
|
72
76
|
'state' => door.status,
|
73
77
|
'since' => door.status_since
|
74
78
|
}
|
75
|
-
return status
|
76
79
|
end
|
77
80
|
|
78
|
-
def close_door(
|
79
|
-
door = select_door(door_name)
|
81
|
+
def close_door(door)
|
80
82
|
door.close
|
81
83
|
end
|
82
84
|
|
83
|
-
def open_door(
|
84
|
-
door = select_door(door_name)
|
85
|
+
def open_door(door)
|
85
86
|
door.open
|
86
87
|
end
|
87
88
|
|
88
|
-
def toggle_door(
|
89
|
-
door = select_door(door_name)
|
89
|
+
def toggle_door(dorr)
|
90
90
|
if door.status == "open"
|
91
91
|
door.close
|
92
92
|
elsif door.status == "closed"
|
@@ -94,9 +94,5 @@ module Agents
|
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
|
-
|
98
|
-
|
99
|
-
# def receive(incoming_events)
|
100
|
-
# end
|
101
97
|
end
|
102
98
|
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.3
|
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
|