-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from TheAgentK/dev
Release 3.0.0
- Loading branch information
Showing
14 changed files
with
3,222 additions
and
1,049 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
devices/ | ||
old/ | ||
test/ | ||
config.json | ||
|
||
|
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,29 @@ | ||
const TuyaDevice = require('./tuya-device') | ||
const debug = require('debug')('tuya-mqtt:device') | ||
const utils = require('../lib/utils') | ||
|
||
class GenericDevice extends TuyaDevice { | ||
async init() { | ||
this.deviceData.mdl = 'Generic Device' | ||
|
||
// Check if custom template in device config | ||
if (this.config.hasOwnProperty('template')) { | ||
// Map generic DPS topics to device specific topic names | ||
this.deviceTopics = this.config.template | ||
} else { | ||
// Try to get schema to at least know what DPS keys to get initial update | ||
const result = await this.device.get({"schema": true}) | ||
if (!utils.isJsonString(result)) { | ||
if (result === 'Schema for device not available') { | ||
debug('Device id '+this.config.id+' failed schema discovery and no custom template defined') | ||
debug('Cannot get initial DPS state data for device '+this.options.name+' but data updates will be publish') | ||
} | ||
} | ||
} | ||
|
||
// Get initial states and start publishing topics | ||
this.getStates() | ||
} | ||
} | ||
|
||
module.exports = GenericDevice |
Oops, something went wrong.