forked from aholstenson/miio
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improving discovery with update event and model info
- Loading branch information
1 parent
f51ab5d
commit b679ed8
Showing
5 changed files
with
82 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
const models = require('./models'); | ||
|
||
module.exports = function(hostname) { | ||
// Extract info via hostname structure | ||
const m = /(.+)_miio(\d+)/g.exec(hostname); | ||
if(! m) return null; | ||
|
||
const model = m[1].replace(/-/g, '.'); | ||
|
||
const device = models[model]; | ||
return { | ||
model: model, | ||
type: (device && device.TYPE) || 'generic', | ||
id: m[2] | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* Mapping from models into high-level devices. | ||
*/ | ||
const AirPurifier = require('./devices/air-purifier'); | ||
const Switch = require('./devices/switch'); | ||
const Vacuum = require('./devices/vacuum'); | ||
const Gateway = require('./devices/gateway'); | ||
|
||
module.exports = { | ||
'zhimi.airpurifier.m1': AirPurifier, | ||
'zhimi.airpurifier.v1': AirPurifier, | ||
'zhimi.airpurifier.v2': AirPurifier, | ||
'zhimi.airpurifier.v6': AirPurifier, | ||
|
||
'chuangmi.plug.m1': Switch, | ||
'chuangmi.plug.v1': require('./devices/chuangmi.plug.v1'), | ||
'chuangmi.plug.v2': Switch, | ||
|
||
'rockrobo.vacuum.v1': Vacuum, | ||
|
||
'lumi.gateway.v2': Gateway, | ||
'lumi.gateway.v3': Gateway, | ||
}; |