1.3.0 • Published 10 months ago

openhab-proxy-pattern v1.3.0

Weekly downloads
-
License
ISC
Repository
github
Last release
10 months ago

JS wrapper to implement common used Proxy Item pattern

Pattern explanation

Usage examples

let proxy = require('openhab-proxy-pattern');

/*
proxy.bind(proxy_item_name, hardware_item_name).update([callback]).forward([callback]);
*/

// one direction proxy
proxy.bind('Equipment_WF_OutTemperature', 'SmartMAC_D105_1_T2').update();

// bi-directional proxy
proxy.bind("GF_Toilet_MirrorLight", "Shelly_25R_3_1Output")
    .forward()
    .update();

// proxy with custom values
proxy.bind('Equipment_ElectricityInverterBattery_Voltage', 'PZEM_1_Voltage')
    .update(function(value) {

        if (typeof value == 'string') {
            const v = parseInt(value) / 100;
            return `${v} V`;
        } else {
            return undefined;
        }
    });

// wide-options proxy
const v = function(value) {
    if (typeof value == 'string') {
        const v = parseInt(value);
        return `${v} V`;
    } else return undefined;
};

['A', 'B', 'C'].forEach(function(phase) {
    proxy.bind(`Equipment_ElectricityHomeV${phase}`, `Shelly_EM3_2_${phase}Voltage`, 15)
      .update(v, 15); // 15 seconds gap between updates. For too-fast hardware
});
1.3.0

10 months ago

1.2.0

2 years ago

1.2.1

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago