mirror of
https://github.com/skydiver/ewelink-api.git
synced 2025-12-21 21:33:11 +01:00
* new method to check for device firmware updates * moved mixin * generate firmware update payload * new method to check for devices firmware updates * removed unused function * moved firmware tests to own file * added firmware test cases * return device id on response * updated credentials list * version bump
28 lines
700 B
JavaScript
28 lines
700 B
JavaScript
const { _get } = require('../../lib/helpers');
|
|
|
|
const getFirmwareVersionMixin = {
|
|
/**
|
|
* Get device firmware version
|
|
*
|
|
* @param deviceId
|
|
*
|
|
* @returns {Promise<{fwVersion: *, status: string}|{msg: string, error: *}>}
|
|
*/
|
|
async getFirmwareVersion(deviceId) {
|
|
const device = await this.getDevice(deviceId);
|
|
const error = _get(device, 'error', false);
|
|
const fwVersion = _get(device, 'params.fwVersion', false);
|
|
|
|
if (error || !fwVersion) {
|
|
if (error && parseInt(error) === 401) {
|
|
return device;
|
|
}
|
|
return { error, msg: 'Device does not exist' };
|
|
}
|
|
|
|
return { status: 'ok', fwVersion };
|
|
},
|
|
};
|
|
|
|
module.exports = getFirmwareVersionMixin;
|