huginn_myq_agent 0.1.1 → 0.2.4

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: 1f6c2e50439c85425e8d53e89c8645fd5f3c409a2308fc56223c55be401cf85b
4
- data.tar.gz: 3e4b5023a82f6522bfe1f9d064cfa8c8f299f0b2ac055f57ff75649598b85a2b
3
+ metadata.gz: 44661a919fb795033e31e61b2dcb83f4d4ac0d9d1def390f13a21c9772cacedb
4
+ data.tar.gz: c9a7c998b1e184ee9b995a35d049fe732f2a2b34af84fb01a81be67fefb5791a
5
5
  SHA512:
6
- metadata.gz: 0ce31f21d80423a754cce8cd4ca565d242f41302479ee611a9838197906fa51de65a8ef898857a6c235639e0649a52980fc7dc3d55f1da79741aa58e44c85aaf
7
- data.tar.gz: 9b973f95dadf73da34aaa71707646f55d5ea364712878ad54fa8fb839863acf5817fab3d068ad3a1f6b8665056595a4333ca43f5bac338db9eadf5f5aec8eb15
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
- 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,23 +38,32 @@ 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
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
- close(door)
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(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(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.1.1
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-12 00:00:00.000000000 Z
11
+ date: 2020-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler