Skip to content

Instantly share code, notes, and snippets.

@Koenkk
Last active April 20, 2020 06:46
Show Gist options
  • Save Koenkk/16f00544fb7e46f6681495363dfad078 to your computer and use it in GitHub Desktop.
Save Koenkk/16f00544fb7e46f6681495363dfad078 to your computer and use it in GitHub Desktop.
class Example {
/**
* Besides intializing variables, the constructor should do nothing!
*
* @param {Zigbee} zigbee Zigbee controller
* @param {MQTT} mqtt MQTT controller
* @param {State} state State controller
* @param {Function} publishEntityState Method to publish device state to MQTT.
* @param {EventBus} eventBus The event bus
*/
constructor(zigbee, mqtt, state, publishEntityState, eventBus) {
this.zigbee = zigbee;
this.mqtt = mqtt;
this.state = state;
this.publishEntityState = publishEntityState;
this.eventBus = eventBus;
}
/**
* This method is called by the controller once Zigbee has been started.
*/
onZigbeeStarted() {
console.log('Zigbee started');
}
/**
* This method is called by the controller once connected to the MQTT server.
*/
// onMQTTConnected() {}
/**
* Is called when a Zigbee message from a device is received.
* @param {string} type Type of the message
* @param {Object} data Data of the message
* @param {Object?} resolvedEntity Resolved entity returned from this.zigbee.resolveEntity()
*/
onZigbeeEvent(type, data, resolvedEntity) {
}
/**
* Is called when a MQTT message is received
* @param {string} topic Topic on which the message was received
* @param {Object} message The received message
* @return {boolean} if the message was handled
*/
onMQTTMessage(topic, message) {
return false;
}
/**
* Is called once the extension has to stop
*/
stop() {
}
}
module.exports = Example;
@sjorge
Copy link

sjorge commented Apr 19, 2020

Is the onZigbeeEvent missing a parameter that is mentioned in the docstring? I'll have a play with this next weekend :)

@Koenkk
Copy link
Author

Koenkk commented Apr 20, 2020

No, the doc string was incorrect :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment