@@ -24,6 +24,8 @@ module Agents |
||
24 | 24 |
|
25 | 25 |
If you do not select an existing device, Huginn will create a new one with the name 'Huginn'. |
26 | 26 |
|
27 |
+ To push to all of your devices, select `All Devices` from the devices list. |
|
28 |
+ |
|
27 | 29 |
You have to provide a message `type` which has to be `note`, `link`, or `address`. The message types `checklist`, and `file` are not supported at the moment. |
28 | 30 |
|
29 | 31 |
Depending on the message `type` you can use additional fields: |
@@ -71,7 +73,9 @@ module Agents |
||
71 | 73 |
end |
72 | 74 |
|
73 | 75 |
def complete_device_id |
74 |
- devices.map { |d| {text: d['nickname'], id: d['iden']} } |
|
76 |
+ devices |
|
77 |
+ .map { |d| {text: d['nickname'], id: d['iden']} } |
|
78 |
+ .unshift(text: 'All Devices', id: '__ALL__') |
|
75 | 79 |
end |
76 | 80 |
|
77 | 81 |
def working? |
@@ -114,14 +118,14 @@ module Agents |
||
114 | 118 |
end |
115 | 119 |
end |
116 | 120 |
|
117 |
- |
|
118 | 121 |
def basic_auth |
119 | 122 |
{basic_auth: {username: interpolated[:api_key].presence || credential('pushbullet_api_key'), password: ''}} |
120 | 123 |
end |
121 | 124 |
|
122 | 125 |
def query_options(event) |
123 | 126 |
mo = interpolated(event) |
124 |
- basic_auth.merge(body: {device_iden: mo[:device_id], type: mo[:type]}.merge(payload(mo))) |
|
127 |
+ dev_ident = mo[:device_id] == "__ALL__" ? '' : mo[:device_id] |
|
128 |
+ basic_auth.merge(body: {device_iden: dev_ident, type: mo[:type]}.merge(payload(mo))) |
|
125 | 129 |
end |
126 | 130 |
|
127 | 131 |
def payload(mo) |
@@ -93,7 +93,7 @@ describe Agents::PushbulletAgent do |
||
93 | 93 |
describe '#complete_device_id' do |
94 | 94 |
it "should return an array" do |
95 | 95 |
mock(@checker).devices { [{'iden' => '12345', 'nickname' => 'huginn'}] } |
96 |
- expect(@checker.complete_device_id).to eq([{:text=>"huginn", :id=>"12345"}]) |
|
96 |
+ expect(@checker.complete_device_id).to eq([{:text=>"All Devices", :id=>"__ALL__"}, {:text=>"huginn", :id=>"12345"}]) |
|
97 | 97 |
end |
98 | 98 |
end |
99 | 99 |
|