Skip to content

Instantly share code, notes, and snippets.

@rclsilver
Created February 9, 2022 15:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rclsilver/6707e5467aed72f1fe2889e2cbe2caa5 to your computer and use it in GitHub Desktop.
Save rclsilver/6707e5467aed72f1fe2889e2cbe2caa5 to your computer and use it in GitHub Desktop.
profalux integration
const fz = require('zigbee-herdsman-converters/converters/fromZigbee');
const exposes = require('zigbee-herdsman-converters/lib/exposes');
const utils = require('zigbee-herdsman-converters/lib/utils');
const reporting = require('zigbee-herdsman-converters/lib/reporting');
const e = exposes.presets;
const ea = exposes.access;
let tzCover = {
key: ['position', 'state'],
options: [exposes.options.invert_cover()],
convertSet: async (entity, key, value, meta) => {
if (typeof value !== 'number') {
switch(value.toLowerCase()) {
case 'stop':
await entity.command('genLevelCtrl', 'stop', {}, utils.getOptions(meta.mapped, entity));
return;
case 'open':
value = 100;
break;
case 'close':
value = 0;
break;
default:
return;
}
}
const invert = utils.getMetaValue(entity, meta.mapped, 'coverInverted', 'allEqual', false)
? !meta.options.invert_cover
: meta.options.invert_cover;
const position = invert ? 100 - value : value;
const level = utils.mapNumberRange(Number(position), 0, 100, 0, 255).toString();
await entity.command(
'genLevelCtrl',
'moveToLevelWithOnOff',
{
level: level,
transtime: 0
},
utils.getOptions(meta.mapped, entity),
);
return {state: {position: value}, readAfterWriteTime: 0};
},
convertGet: async (entity, key, meta) => {
await entity.read('genLevelCtrl', ['currentLevel']);
},
};
module.exports = [
{
fingerprint: [
{ manufId: 4368, endpoints: [ { ID: 1, deviceID: 513 } ] },
],
model: 'Remote',
vendor: 'Profalux',
description: 'Store profalux',
fromZigbee: [],
toZigbee: [],
exposes: [],
},
{
fingerprint: [
{ manufId: 4368, endpoints: [ { ID: 1, deviceID: 512 } ] },
],
model: 'Store',
vendor: 'Profalux',
description: 'Store profalux',
fromZigbee: [fz.cover_position_via_brightness, fz.cover_state_via_onoff],
toZigbee: [tzCover],
exposes: [e.cover_position().setAccess('state', ea.ALL)],
configure: async (device, coordinatorEndpoint, logger) => {
const endpoint = device.getEndpoint(1);
await reporting.bind(endpoint, coordinatorEndpoint, ['genLevelCtrl']);
await reporting.brightness(endpoint);
},
},
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment