Files
zigbee2mqtt/test/utils.js
T
Gergely Markics 5d3461c4c6 Add the timestamp of last received zigbee message visible in HASS (#739)
* 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
2018-12-26 17:33:39 +01:00

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;
},
};