Skip to content

Commit 2a2216b

Browse files
committed
aded discovery of DashButtonDevice candidates
1 parent 16475d7 commit 2a2216b

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

HISTORY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* Added source host IP filter to filtering string to further limit
77
the number of matching packages
88
* Merged DashButtonDevice from pimatic-dash-button, thanks @michbeck100
9+
* Added discovery of DashButtonDevice candidates
910
* Updated dependencies
1011

1112
* 20171226, V0.9.14

amazing-dash-button.coffee

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,21 @@ module.exports = (env) ->
6666
@candidatesSeen = []
6767
@lastId = null
6868

69+
@createNewDevice = (className, info, candidateAddress) =>
70+
@lastId = @base.generateDeviceId @framework, "dash", @lastId
71+
72+
deviceConfig =
73+
id: @lastId
74+
name: @lastId
75+
class: className
76+
macAddress: candidateAddress
77+
78+
@framework.deviceManager.discoveredDevice(
79+
'pimatic-amazing-dash-button',
80+
"#{deviceConfig.name} (#{className}, #{deviceConfig.macAddress}, #{info.ip})",
81+
deviceConfig
82+
)
83+
6984
@candidateInfoHandler = (info) =>
7085
candidateAddress = info.mac
7186
if candidateAddress not in @candidatesSeen
@@ -75,19 +90,8 @@ module.exports = (env) ->
7590
if probeSucceeded
7691
@base.debug 'Amazon device appears to be a Chromecast server: ' + candidateAddress
7792
else
78-
@lastId = @base.generateDeviceId @framework, "dash", @lastId
79-
80-
deviceConfig =
81-
id: @lastId
82-
name: @lastId
83-
class: 'AmazingDashButton'
84-
macAddress: candidateAddress
85-
86-
@framework.deviceManager.discoveredDevice(
87-
'pimatic-amazing-dash-button',
88-
"#{deviceConfig.name} (#{deviceConfig.macAddress}, #{info.ip})",
89-
deviceConfig
90-
)
93+
@createNewDevice 'AmazingDashButton', info, candidateAddress
94+
@createNewDevice 'DashButton', info, candidateAddress
9195

9296
@on 'candidateInfo', @candidateInfoHandler
9397
@timer = setTimeout( =>

0 commit comments

Comments
 (0)