@@ -66,6 +66,21 @@ module.exports = (env) ->
66
66
@candidatesSeen = []
67
67
@lastId = null
68
68
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
+
69
84
@ candidateInfoHandler = (info ) =>
70
85
candidateAddress = info .mac
71
86
if candidateAddress not in @candidatesSeen
@@ -75,19 +90,8 @@ module.exports = (env) ->
75
90
if probeSucceeded
76
91
@base .debug ' Amazon device appears to be a Chromecast server: ' + candidateAddress
77
92
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
91
95
92
96
@ on ' candidateInfo' , @candidateInfoHandler
93
97
@timer = setTimeout ( =>
0 commit comments