huginn_myq_agent 0.2.0 → 0.2.5

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: 10450e75efd00ad997b9fa9e8808b8a472210106d66585210480a86e6072f98d
4
- data.tar.gz: 203f5a8434e8a1554d095b014fc53b7cc2d69a79319073936b2369e1abc0e9c0
3
+ metadata.gz: 1a14d1451dc070eb5e1519f50ff8825755cc970a8458f21fb32753bf15c7eae0
4
+ data.tar.gz: 93c72c7c6ea7cf3c16c5a8e236560171758f108e6b1e0809162e93f116e61796
5
5
  SHA512:
6
- metadata.gz: 3158e92d9149cb6e59b5a06106c1eeea399773e27aa522258bb33c3b2b062c0524edc0402509077d588109d96702e031c29aba2ee33909fe26962b1ecac1be83
7
- data.tar.gz: 8e5e15352d1c6aa40bfcdec75920681887364ea08fff399fb2739439959274e4d42ba6cf9f966b93302a76079956bb8ca1388c008877d3413c6f38886f86dab7
6
+ metadata.gz: 702af78b42d4bdaf914e697e8a804614dc24a2b04c6da560d795a65024dd1ca3c9480e80fbfa8ea507431c685670e4efbe1890aad46daced2abd446ab2928ea0
7
+ data.tar.gz: 9c4897704759774aff5221d3a42a3c87acf625b8243d37c80f3e9011aafa87daf1cb82fdb26b6773d4cb019017ccbc75554e454485bd5fc8a68fefc9df00bb59
@@ -7,21 +7,19 @@ module Agents
7
7
  default_schedule '12h'
8
8
 
9
9
  description <<-MD
10
- Add a Agent description here
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, type: :text
23
- form_configurable :password, type: :text
24
- form_configurable :door_name, type: :text
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,8 +38,12 @@ module Agents
40
38
  end
41
39
 
42
40
  def working?
43
- # Implement me! Maybe one of these next two lines would be a good fit?
44
- received_event_without_error?
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
@@ -52,11 +54,16 @@ module Agents
52
54
  open_door(door)
53
55
  create_event :payload => status(door)
54
56
  elsif interpolated['action'] == 'close'
55
- close(door)
57
+ close_door(door)
58
+ create_event :payload => status(door)
59
+ elsif interpolated['action'] == 'toggle'
60
+ toggle_door(door)
56
61
  create_event :payload => status(door)
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(door_name)
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(door_name)
79
- door = select_door(door_name)
84
+ def close_door(door)
80
85
  door.close
81
86
  end
82
87
 
83
- def open_door(door_name)
84
- door = select_door(door_name)
88
+ def open_door(door)
85
89
  door.open
86
90
  end
87
91
 
88
- def toggle_door(door_name)
89
- door = select_door(door_name)
92
+ def toggle_door(door)
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.2.0
4
+ version: 0.2.5
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-12 00:00:00.000000000 Z
11
+ date: 2020-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler