mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-07-02 18:11:36 +00:00
5d3461c4c6
* Add timestamp on receiving message from Zigbee Add last_message to the payload * Discovery on HASS restart and last_message attribute added - On restarting Home Assistant, resending device discovery information - Add timestamp on receiving message from Zigbee * Add option: add_timestamp in settings * Add option: add_timestamp in settings * Add option: add_timestamp in settings * typo * Update homeassistant.js * Update homeassistant.js * Update homeassistant.js * Update deviceReceive.js * Update deviceReceive.js * Update homeassistant.js * Update settings.js * Update deviceReceive.js * Update deviceReceive.js * Update deviceReceive.js * Update deviceReceive.js * Fix tests * Fix lint * Fix lint
29 lines
791 B
JavaScript
29 lines
791 B
JavaScript
const logger = require('../lib/util/logger');
|
|
|
|
module.exports = {
|
|
stubLogger: (sandbox) => {
|
|
sandbox.stub(logger, 'info').callsFake(() => {});
|
|
sandbox.stub(logger, 'warn').callsFake(() => {});
|
|
sandbox.stub(logger, 'debug').callsFake(() => {});
|
|
sandbox.stub(logger, 'error').callsFake(() => {});
|
|
},
|
|
zigbeeMessage: (device, cid, type, data, epId) => {
|
|
return {data: {cid: cid, data: data}, type: type, endpoints: [{device: device, epId: epId}]};
|
|
},
|
|
withoutLastSeen: (obj) => {
|
|
const isString = typeof obj === 'string';
|
|
|
|
if (isString) {
|
|
obj = JSON.parse(obj);
|
|
}
|
|
|
|
delete obj.last_seen;
|
|
|
|
if (isString) {
|
|
obj = JSON.stringify(obj);
|
|
}
|
|
|
|
return obj;
|
|
},
|
|
};
|