HomeAss | add new product – example code

https://community.home-assistant.io/t/new-sonoff-s40-lite-zigbee-plug-us/426747/4

 

ure! its basically the same as the S31

The s40lite.js file needs to be added in the same folder as your configuration.yaml, and the configuration.yaml modified to include it.

configuration.yaml snippet

external_converters:
  - s40lite.js

s40lite.js

const fz = require('zigbee-herdsman-converters/converters/fromZigbee');
const tz = require('zigbee-herdsman-converters/converters/toZigbee');
const exposes = require('zigbee-herdsman-converters/lib/exposes');
const reporting = require('zigbee-herdsman-converters/lib/reporting');
const extend = require('zigbee-herdsman-converters/lib/extend');
const e = exposes.presets;
const ea = exposes.access;

const definition = {
    zigbeeModel: ['S40LITE'],
    model: 'S40ZBTPB',
    vendor: 'SONOFF',
    description: '15A Zigbee Smart Plug',
    extend: extend.switch(),
    fromZigbee: [fz.on_off_skip_duplicate_transaction],
    configure: async (device, coordinatorEndpoint, logger) => {
        const endpoint = device.getEndpoint(1);
        await reporting.bind(endpoint, coordinatorEndpoint, ['genOnOff']);
    },
};

module.exports = definition;

https://www.zigbee2mqtt.io/advanced/support-new-devices/01_support_new_devices.html 63

Scroll to Top