ruby-macrodroid 0.9.12 → 0.9.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/ruby-macrodroid/actions.rb +14 -3
- data/lib/ruby-macrodroid/base.rb +2 -0
- data/lib/ruby-macrodroid/macro.rb +1 -1
- data/lib/ruby-macrodroid/triggers.rb +128 -18
- data/lib/ruby-macrodroid/triggersnlp.rb +51 -2
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c63b70d5cc34184d15c46395e1add89a6c8999163d4fb1e9362aa80a568dba4
|
4
|
+
data.tar.gz: 797fab9bff840db398067dc5b99ac53bb3d3129668573728c31aa0883a28d792
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bbf5ca42c6fe1be4eeeda1ba597bc4be3f0944e7a871785b629d5344268bd65d3c560fcf65de0e5b0a619c075a31f6f61eea1d8eefbd29d066777f9fb414584
|
7
|
+
data.tar.gz: 139c4462602b86d49d87d9b2e73873354550b67c8bc435bfed41d6fe6434419d4cbdfef375efdc659978e012bbb8bb9d685a08d1d75f63ae0a403a6796295da7
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
@@ -888,8 +888,17 @@ end
|
|
888
888
|
#
|
889
889
|
class SayTimeAction < DateTimeAction
|
890
890
|
|
891
|
-
def initialize(
|
892
|
-
|
891
|
+
def initialize(obj=nil)
|
892
|
+
|
893
|
+
h = if obj.is_a? Hash then
|
894
|
+
obj
|
895
|
+
elsif obj.is_a? Array
|
896
|
+
|
897
|
+
e, macro = obj
|
898
|
+
{:'12_hour' => e.text('item/description').to_s[/^\d+/] == '12'}
|
899
|
+
|
900
|
+
end
|
901
|
+
|
893
902
|
options = {
|
894
903
|
:'12_hour' => true
|
895
904
|
}
|
@@ -910,7 +919,9 @@ class SayTimeAction < DateTimeAction
|
|
910
919
|
end
|
911
920
|
|
912
921
|
def to_s(colour: false, indent: 0)
|
913
|
-
'Say Current Time'
|
922
|
+
@s = 'Say Current Time'
|
923
|
+
@s += "\n%s hour clock" % (@h[:'12_hour'] ? '12' : '24')
|
924
|
+
super()
|
914
925
|
end
|
915
926
|
|
916
927
|
end
|
data/lib/ruby-macrodroid/base.rb
CHANGED
@@ -35,6 +35,7 @@ module ObjectX
|
|
35
35
|
puts 'r: ' + r.inspect if debug
|
36
36
|
|
37
37
|
nested = description.element('item/description')
|
38
|
+
puts 'nested: ' + nested.inspect if debug
|
38
39
|
|
39
40
|
if r[1].any? and not nested then
|
40
41
|
|
@@ -204,6 +205,7 @@ class MacroObject
|
|
204
205
|
new_key = key.to_s.gsub(/\w_\w/){|x| x[0] + x[-1].upcase}
|
205
206
|
new_key = new_key.prepend 'm_' unless @list.include? new_key
|
206
207
|
new_key = 'm_SIGUID' if new_key == 'm_siguid'
|
208
|
+
new_key = 'm_SSIDList' if new_key == 'm_ssidList'
|
207
209
|
new_val = value.is_a?(Hash) ? hashify(value) : value
|
208
210
|
r.merge(new_key => new_val)
|
209
211
|
end
|
@@ -268,7 +268,7 @@ class Macro
|
|
268
268
|
r = tp.find_trigger trigger
|
269
269
|
puts 'r: ' + r.inspect if @debug
|
270
270
|
#o = r[0].new([description, self]) if r
|
271
|
-
o = object_create(r[0], [description, self]) if r
|
271
|
+
o = object_create(r[0], [description, self, r[1]]) if r
|
272
272
|
puts 'after o' if @debug
|
273
273
|
o
|
274
274
|
|
@@ -61,6 +61,7 @@ class Trigger < MacroObject
|
|
61
61
|
{|x| 'c: ' + x.to_summary(colour: colour, indent: 1)}.join(" %s " % operator)
|
62
62
|
|
63
63
|
@constraints.any? ? @s + "\n" + constraints : @s
|
64
|
+
super()
|
64
65
|
|
65
66
|
end
|
66
67
|
|
@@ -85,7 +86,7 @@ end
|
|
85
86
|
# ["Any Network"]
|
86
87
|
# ["some Wifi SSID"] - 1 or more SSID can be supplied
|
87
88
|
|
88
|
-
class
|
89
|
+
class WifiConnectionTrigger2 < Trigger
|
89
90
|
|
90
91
|
def initialize(h={})
|
91
92
|
|
@@ -216,7 +217,7 @@ class PowerButtonToggleTrigger < Trigger
|
|
216
217
|
end
|
217
218
|
|
218
219
|
def to_s(colour: false)
|
219
|
-
|
220
|
+
"Power Button Toggle (%s)" % @h[:num_toggles] #+ @h.inspect
|
220
221
|
end
|
221
222
|
|
222
223
|
alias to_summary to_s
|
@@ -457,7 +458,7 @@ class WebHookTrigger < Trigger
|
|
457
458
|
|
458
459
|
url = "https://trigger.macrodroid.com/%s/%s" % \
|
459
460
|
[@deviceid, @h[:identifier]]
|
460
|
-
@s = 'WebHook (Url)' + "\n
|
461
|
+
@s = 'WebHook (Url)' + "\n" + url
|
461
462
|
super()
|
462
463
|
|
463
464
|
end
|
@@ -469,8 +470,15 @@ end
|
|
469
470
|
#
|
470
471
|
class WifiConnectionTrigger < Trigger
|
471
472
|
|
472
|
-
def initialize(
|
473
|
+
def initialize(obj=nil)
|
473
474
|
|
475
|
+
h = if obj.is_a? Hash then
|
476
|
+
obj
|
477
|
+
elsif obj.is_a? Array
|
478
|
+
e, macro = obj
|
479
|
+
{ssid_list: [e.text('item/description').to_s], wifi_state: 2}
|
480
|
+
end
|
481
|
+
|
474
482
|
options = {
|
475
483
|
ssid_list: [],
|
476
484
|
wifi_state: 0
|
@@ -482,10 +490,15 @@ class WifiConnectionTrigger < Trigger
|
|
482
490
|
|
483
491
|
def to_s(colour: false)
|
484
492
|
access_point = @h[:ssid_list].first
|
485
|
-
'Connected to network
|
493
|
+
@s = 'Connected to network'
|
494
|
+
@s += "\n" + access_point
|
495
|
+
super()
|
486
496
|
end
|
487
497
|
|
488
|
-
|
498
|
+
def to_summary()
|
499
|
+
access_point = @h[:ssid_list].first
|
500
|
+
'Connected to network' + access_point
|
501
|
+
end
|
489
502
|
end
|
490
503
|
|
491
504
|
# Category: Connectivity
|
@@ -1010,7 +1023,7 @@ class MusicPlayingTrigger < DeviceEventsTrigger
|
|
1010
1023
|
def to_s(colour: false)
|
1011
1024
|
|
1012
1025
|
event = @h[:option] == 0 ? 'Started' : 'Stopped'
|
1013
|
-
@s = 'Music/Sound Playing' + "\n
|
1026
|
+
@s = 'Music/Sound Playing' + "\n%s" % event #+ @h.inspect
|
1014
1027
|
super()
|
1015
1028
|
|
1016
1029
|
end
|
@@ -1026,8 +1039,15 @@ end
|
|
1026
1039
|
#
|
1027
1040
|
class NFCTrigger < DeviceEventsTrigger
|
1028
1041
|
|
1029
|
-
def initialize(
|
1030
|
-
|
1042
|
+
def initialize(obj=nil)
|
1043
|
+
|
1044
|
+
h = if obj.is_a? Hash then
|
1045
|
+
obj
|
1046
|
+
elsif obj.is_a? Array
|
1047
|
+
e, macro = obj
|
1048
|
+
{tag_name: e.text('item/description').to_s}
|
1049
|
+
end
|
1050
|
+
|
1031
1051
|
options = {
|
1032
1052
|
}
|
1033
1053
|
|
@@ -1367,8 +1387,24 @@ end
|
|
1367
1387
|
#
|
1368
1388
|
class ActivityRecognitionTrigger < SensorsTrigger
|
1369
1389
|
|
1370
|
-
def initialize(
|
1371
|
-
|
1390
|
+
def initialize(obj=nil)
|
1391
|
+
|
1392
|
+
#puts 'obj: ' + obj.inspect
|
1393
|
+
|
1394
|
+
h = if obj.is_a? Hash then
|
1395
|
+
|
1396
|
+
obj
|
1397
|
+
|
1398
|
+
elsif obj.is_a? Array
|
1399
|
+
|
1400
|
+
e, macro, h2 = obj
|
1401
|
+
#puts 'h2: ' + h2.inspect
|
1402
|
+
#puts 'e: ' + e.xml
|
1403
|
+
s = e.text('item/description').to_s
|
1404
|
+
#puts 's: ' + s.inspect
|
1405
|
+
{confidence_level: s[/\d+%$/].to_i}.merge h2
|
1406
|
+
end
|
1407
|
+
|
1372
1408
|
options = {
|
1373
1409
|
confidence_level: 50,
|
1374
1410
|
selected_index: 1
|
@@ -1381,8 +1417,13 @@ class ActivityRecognitionTrigger < SensorsTrigger
|
|
1381
1417
|
end
|
1382
1418
|
|
1383
1419
|
def to_s(colour: false)
|
1420
|
+
|
1384
1421
|
activity = @activity[@h[:selected_index]]
|
1385
|
-
'Activity - ' + activity
|
1422
|
+
@s = 'Activity - ' + activity #+ @h.inspect
|
1423
|
+
@s += "\nConfidence >= %s%%" % @h[:confidence_level]
|
1424
|
+
|
1425
|
+
super()
|
1426
|
+
|
1386
1427
|
end
|
1387
1428
|
|
1388
1429
|
def to_summary(colour: false)
|
@@ -1577,7 +1618,7 @@ class ShortcutTrigger < Trigger
|
|
1577
1618
|
end
|
1578
1619
|
|
1579
1620
|
def to_s(colour: false)
|
1580
|
-
'
|
1621
|
+
'Shortcut Launched' #+ @h.inspect
|
1581
1622
|
end
|
1582
1623
|
|
1583
1624
|
alias to_summary to_s
|
@@ -1633,8 +1674,15 @@ end
|
|
1633
1674
|
#
|
1634
1675
|
class MediaButtonPressedTrigger < Trigger
|
1635
1676
|
|
1636
|
-
def initialize(
|
1677
|
+
def initialize(obj=nil)
|
1637
1678
|
|
1679
|
+
h = if obj.is_a? Hash then
|
1680
|
+
obj
|
1681
|
+
elsif obj.is_a? Array
|
1682
|
+
e, macro = obj
|
1683
|
+
{option: e.text('item/description').to_s}
|
1684
|
+
end
|
1685
|
+
|
1638
1686
|
options = {
|
1639
1687
|
option: 'Single Press',
|
1640
1688
|
cancel_press: false
|
@@ -1645,7 +1693,50 @@ class MediaButtonPressedTrigger < Trigger
|
|
1645
1693
|
end
|
1646
1694
|
|
1647
1695
|
def to_s(colour: false)
|
1648
|
-
|
1696
|
+
|
1697
|
+
@s = 'Media Button Pressed ' #+ @h.inspect
|
1698
|
+
@s += "\n" + @h[:option]
|
1699
|
+
super()
|
1700
|
+
|
1701
|
+
end
|
1702
|
+
|
1703
|
+
alias to_summary to_s
|
1704
|
+
end
|
1705
|
+
|
1706
|
+
class MediaButtonV2Trigger < Trigger
|
1707
|
+
|
1708
|
+
def initialize(obj=nil)
|
1709
|
+
|
1710
|
+
@a = %w(Play Play/Pause Pause Stop Previous Next Headset Hook)
|
1711
|
+
|
1712
|
+
h = if obj.is_a? Hash then
|
1713
|
+
obj
|
1714
|
+
elsif obj.is_a? Array
|
1715
|
+
e, macro = obj
|
1716
|
+
s = e.text('item/description').to_s
|
1717
|
+
a = s.split(/, /)
|
1718
|
+
{options_enabled_array: @a.map {|x| a.include? x } }
|
1719
|
+
end
|
1720
|
+
|
1721
|
+
|
1722
|
+
|
1723
|
+
options = {
|
1724
|
+
options_enabled_array: [true, false, false, false, false, false, false]
|
1725
|
+
}
|
1726
|
+
|
1727
|
+
super(options.merge h)
|
1728
|
+
|
1729
|
+
end
|
1730
|
+
|
1731
|
+
def to_s(colour: false)
|
1732
|
+
|
1733
|
+
|
1734
|
+
options = @a.zip(@h[:options_enabled_array]).select(&:last).map(&:first)
|
1735
|
+
|
1736
|
+
@s = 'Media Button V2 ' #+ @h.inspect
|
1737
|
+
@s += "\n" + options.join(', ')
|
1738
|
+
super()
|
1739
|
+
|
1649
1740
|
end
|
1650
1741
|
|
1651
1742
|
alias to_summary to_s
|
@@ -1655,8 +1746,22 @@ end
|
|
1655
1746
|
#
|
1656
1747
|
class SwipeTrigger < Trigger
|
1657
1748
|
|
1658
|
-
def initialize(
|
1659
|
-
|
1749
|
+
def initialize(obj=nil)
|
1750
|
+
|
1751
|
+
h = if obj.is_a? Hash then
|
1752
|
+
obj
|
1753
|
+
elsif obj.is_a? Array
|
1754
|
+
|
1755
|
+
e, macro = obj
|
1756
|
+
s = e.text('item/description').to_s
|
1757
|
+
start, motion = s.split(/ - /,2)
|
1758
|
+
|
1759
|
+
{
|
1760
|
+
swipe_start_area: ['Top Left', 'Top Right'].index(start),
|
1761
|
+
swipe_motion: %w(Across Diagonal Down).index(motion)
|
1762
|
+
}
|
1763
|
+
end
|
1764
|
+
|
1660
1765
|
options = {
|
1661
1766
|
swipe_start_area: 0,
|
1662
1767
|
swipe_motion: 0,
|
@@ -1668,7 +1773,12 @@ class SwipeTrigger < Trigger
|
|
1668
1773
|
end
|
1669
1774
|
|
1670
1775
|
def to_s(colour: false)
|
1671
|
-
|
1776
|
+
|
1777
|
+
direction = [['Top Left', 'Top Right'][@h[:swipe_start_area]],
|
1778
|
+
%w(Across Diagonal Down)[@h[:swipe_motion]]].join(' - ')
|
1779
|
+
@s = 'Swipe Screen'# + @h.inspect
|
1780
|
+
@s += "\n" + direction
|
1781
|
+
super()
|
1672
1782
|
end
|
1673
1783
|
|
1674
1784
|
alias to_summary to_s
|
@@ -19,6 +19,10 @@ class TriggersNlp
|
|
19
19
|
|
20
20
|
# -- Battery/Power ---------------------------------------------
|
21
21
|
|
22
|
+
get /Power Button Toggle \((\d)\)/i do |num|
|
23
|
+
[PowerButtonToggleTrigger, {num_toggles: num.to_i}]
|
24
|
+
end
|
25
|
+
|
22
26
|
get /^Power Connected: (Wired \([^\)]+\))/i do |s|
|
23
27
|
|
24
28
|
h = {
|
@@ -50,7 +54,24 @@ class TriggersNlp
|
|
50
54
|
[ExternalPowerTrigger, h]
|
51
55
|
end
|
52
56
|
|
57
|
+
# -- Connectivity ----------------------------------------------------
|
58
|
+
#
|
59
|
+
|
60
|
+
# Wifi State Change
|
61
|
+
|
62
|
+
get /^Connected to network (.*)$/i do |network|
|
63
|
+
[WifiConnectionTrigger, {ssid_list: [network], wifi_state: 2 }]
|
64
|
+
end
|
65
|
+
|
66
|
+
get /^Connected to network$/i do
|
67
|
+
[WifiConnectionTrigger, {}]
|
68
|
+
end
|
69
|
+
|
53
70
|
# -- Device Events ----------------------------------------------------
|
71
|
+
|
72
|
+
get /^NFC Tag$/i do |state|
|
73
|
+
[NFCTrigger, {}]
|
74
|
+
end
|
54
75
|
|
55
76
|
get /^Screen[ _](On|Off)/i do |state|
|
56
77
|
[ScreenOnOffTrigger, {screen_on: state.downcase == 'on'}]
|
@@ -132,11 +153,39 @@ class TriggersNlp
|
|
132
153
|
[WebHookTrigger, params]
|
133
154
|
end
|
134
155
|
|
135
|
-
|
156
|
+
#-- MacroDroid specific ---------------------------------------------------------------
|
136
157
|
|
137
158
|
get /^EmptyTrigger$/i do
|
138
159
|
[EmptyTrigger, params]
|
139
|
-
end
|
160
|
+
end
|
161
|
+
|
162
|
+
#-- Sensors ---------------------------------------------------------------
|
163
|
+
|
164
|
+
get /^Activity - (.*)$/i do |s|
|
165
|
+
|
166
|
+
a = ['In Vehicle', 'On Bicycle', 'Running', 'Walking', 'Still']
|
167
|
+
r = a.find {|x| x.downcase == s.downcase}
|
168
|
+
h = r ? {selected_index: a.index(r)} : {}
|
169
|
+
[ActivityRecognitionTrigger , h]
|
170
|
+
end
|
171
|
+
|
172
|
+
# -- User Input ---------------------------------------------------------------
|
173
|
+
|
174
|
+
get /^Media Button Pressed$/i do
|
175
|
+
[MediaButtonPressedTrigger, {}]
|
176
|
+
end
|
177
|
+
|
178
|
+
get /^Media Button V2$/i do
|
179
|
+
[MediaButtonV2Trigger, {}]
|
180
|
+
end
|
181
|
+
|
182
|
+
get /^Shortcut Launched$/i do
|
183
|
+
[ShortcutTrigger, {}]
|
184
|
+
end
|
185
|
+
|
186
|
+
get /^Swipe Screen$/i do
|
187
|
+
[SwipeTrigger, {}]
|
188
|
+
end
|
140
189
|
|
141
190
|
end
|
142
191
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-macrodroid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
NZ2kdBIUDnAM24e0/wXdVxg4HnsZbdymxyzMQ4P5pKYcpI6oisBxI37p/Xy+wAg3
|
36
36
|
SBHno3GEuuD8ZWj24IMJpfbp
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2020-10-
|
38
|
+
date: 2020-10-20 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: glw
|
metadata.gz.sig
CHANGED
Binary file
|