How to use zigbee-herdsman-converters - 10 common examples

To help you get started, we’ve selected a few zigbee-herdsman-converters examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hobbyquaker / node-red-contrib-zigbee / nodes / converter.js View on Github external
this.error('device unknown ' + name + ' ' + ieeeAddr);
                        return;
                    }
                }

                let model;
                let converters;

                if (isGroup) {
                    converters = groupConverters;
                } else {
                    // Map device to a model
                    if (this.models.has(device.modelID)) {
                        model = this.models.get(device.modelID);
                    } else {
                        model = herdsmanConverters.findByZigbeeModel(device.modelID);
                        this.models.set(device.modelID, model);
                    }

                    if (!model) {
                        this.warn(`Device with modelID '${device.modelID}' is not supported.`);
                        this.warn('Please see: https://www.zigbee2mqtt.io/how_tos/how_to_support_new_devices.html');
                        return;
                    }

                    converters = model.toZigbee;
                }

                // TODO understand postfix
                let endpoint;
                // Determine endpoint to publish to.
                if (typeof model.endpoint !== 'undefined') {
github Koenkk / zigbee2mqtt / lib / extension / homeassistant.js View on Github external
async onMQTTConnected() {
        this.mqtt.subscribe(this.statusTopic);

        // MQTT discovery of all paired devices on startup.
        for (const device of this.zigbee.getClients()) {
            const mappedModel = zigbeeHerdsmanConverters.findByZigbeeModel(device.modelID);
            if (mappedModel) {
                this.discover(device.ieeeAddr, mappedModel, true);
            }
        }
    }
github Koenkk / zigbee2mqtt / lib / extension / deviceAvailability.js View on Github external
const logger = require('../util/logger');
const settings = require('../util/settings');
const utils = require('../util/utils');
const zigbeeHerdsmanConverters = require('zigbee-herdsman-converters');
const BaseExtension = require('./baseExtension');

// Some EndDevices should be pinged
// e.g. E11-G13 https://github.com/Koenkk/zigbee2mqtt/issues/775#issuecomment-453683846
const forcedPingable = [
    zigbeeHerdsmanConverters.devices.find((d) => d.model === 'E11-G13'),
];

const toZigbeeCandidates = ['state', 'brightness', 'color', 'color_temp'];

const Hours25 = 1000 * 60 * 60 * 25;

/**
 * This extensions pings devices to check if they are online.
 */
class DeviceAvailability extends BaseExtension {
    constructor(zigbee, mqtt, state, publishEntityState) {
        super(zigbee, mqtt, state, publishEntityState);

        this.availability_timeout = settings.get().advanced.availability_timeout;
        this.timers = {};
        this.state = {};
github Koenkk / zigbee2mqtt / lib / extension / entityPublish.js View on Github external
const settings = require('../util/settings');
const zigbeeHerdsmanConverters = require('zigbee-herdsman-converters');
const logger = require('../util/logger');
const utils = require('../util/utils');
const assert = require('assert');
const BaseExtension = require('./baseExtension');

const postfixes = utils.getPostfixes();
const topicRegex = new RegExp(`^(.+?)(?:/(${postfixes.join('|')}))?/(get|set)(?:/(.+))?`);

const groupConverters = [
    zigbeeHerdsmanConverters.toZigbeeConverters.light_onoff_brightness,
    zigbeeHerdsmanConverters.toZigbeeConverters.light_colortemp,
    zigbeeHerdsmanConverters.toZigbeeConverters.light_color,
    zigbeeHerdsmanConverters.toZigbeeConverters.light_alert,
    zigbeeHerdsmanConverters.toZigbeeConverters.ignore_transition,
];

class EntityPublish extends BaseExtension {
    onMQTTConnected() {
        // Subscribe to topics.
        const baseTopic = settings.get().mqtt.base_topic;
        for (let step = 1; step < 20; step++) {
            const topic = `${baseTopic}/${'+/'.repeat(step)}`;
            this.mqtt.subscribe(`${topic}set`);
            this.mqtt.subscribe(`${topic}set/+`);
            this.mqtt.subscribe(`${topic}get`);
            this.mqtt.subscribe(`${topic}get/+`);
        }
github Koenkk / zigbee2mqtt / lib / extension / entityPublish.js View on Github external
const settings = require('../util/settings');
const zigbeeHerdsmanConverters = require('zigbee-herdsman-converters');
const logger = require('../util/logger');
const utils = require('../util/utils');
const assert = require('assert');
const BaseExtension = require('./baseExtension');

const postfixes = utils.getPostfixes();
const topicRegex = new RegExp(`^(.+?)(?:/(${postfixes.join('|')}))?/(get|set)(?:/(.+))?`);

const groupConverters = [
    zigbeeHerdsmanConverters.toZigbeeConverters.light_onoff_brightness,
    zigbeeHerdsmanConverters.toZigbeeConverters.light_colortemp,
    zigbeeHerdsmanConverters.toZigbeeConverters.light_color,
    zigbeeHerdsmanConverters.toZigbeeConverters.light_alert,
    zigbeeHerdsmanConverters.toZigbeeConverters.ignore_transition,
];

class EntityPublish extends BaseExtension {
    onMQTTConnected() {
        // Subscribe to topics.
        const baseTopic = settings.get().mqtt.base_topic;
        for (let step = 1; step < 20; step++) {
            const topic = `${baseTopic}/${'+/'.repeat(step)}`;
            this.mqtt.subscribe(`${topic}set`);
            this.mqtt.subscribe(`${topic}set/+`);
            this.mqtt.subscribe(`${topic}get`);
            this.mqtt.subscribe(`${topic}get/+`);
github Koenkk / zigbee2mqtt / scripts / generateNewSupportedDevices.js View on Github external
const fs = require('fs');
const filename = process.argv[2];
const text = fs.readFileSync(filename, 'utf8');
const zigbeeHerdsmanConverters = require('zigbee-herdsman-converters');


for (const line of text.split('\n')) {
    const model = zigbeeHerdsmanConverters.devices.find((d) => d.model === line);
    console.log(`- \`${line}\` ${model.vendor} ${model.description}`);
}
github Koenkk / zigbee2mqtt / lib / extension / deviceConfigure.js View on Github external
async onZigbeeStarted() {
        this.coordinatorEndpoint = this.zigbee.getDevicesByType('Coordinator')[0].getEndpoint(1);

        for (const device of this.zigbee.getClients()) {
            const mappedDevice = zigbeeHerdsmanConverters.findByZigbeeModel(device.modelID);
            const settingsDevice = settings.getDevice(device.ieeeAddr);
            if (this.shouldConfigure(device, mappedDevice)) {
                await this.configure(device, mappedDevice, settingsDevice);
            }
        }
    }
github hobbyquaker / node-red-contrib-zigbee / nodes / converter.js View on Github external
RED.httpAdmin.get('/zigbee-shepherd/converters', RED.auth.needsPermission('zigbee.read'), (req, res) => {
        const converters = herdsmanConverters.findByZigbeeModel(req.query.modelID);
        res.status(200).send(JSON.stringify({supports: converters.supports || ''}));
    });
github Koenkk / zigbee2mqtt / lib / extension / deviceEvent.js View on Github external
callOnEvent(device, type, data, mappedDevice) {
        if (!mappedDevice) {
            mappedDevice = zigbeeHerdsmanConverters.findByZigbeeModel(device.modelID);
        }

        if (mappedDevice && mappedDevice.onEvent) {
            mappedDevice.onEvent(type, data, device);
        }
    }
}
github Koenkk / zigbee2mqtt / lib / zigbee.js View on Github external
return {
                    type: 'device', device, settings: entity, mapped, endpoint, name: entity.friendlyName,
                    isDefaultEndpoint, endpointName,
                };
            } else {
                let group = this.getGroupByID(entity.ID);
                if (!group) group = this.createGroup(entity.ID);
                return {type: 'group', group, settings: entity, name: entity.friendlyName};
            }
        } else {
            const setting = settings.getEntity(key.ieeeAddr);
            return {
                type: 'device',
                device: key,
                settings: setting,
                mapped: zigbeeHerdsmanConverters.findByZigbeeModel(key.modelID),
                name: setting ? setting.friendlyName : (key.type === 'Coordinator' ? 'Coordinator' : key.ieeeAddr),
            };
        }
    }

zigbee-herdsman-converters

Collection of device converters to be used with zigbee-herdsman

MIT
Latest version published 2 days ago

Package Health Score

83 / 100
Full package analysis