This feature request is probably pretty big, but I still want to mention it because I think it’s important for the future of Pimatic. I’ve noticed several times now that there are a lot of ‘double’ plugins for example: you have the pimatic-homeduino
plugin which is used to control 433 devices but there is also a pimatic-rflink
and my plugin pimatic-rfxcom
. These plugins do essentially the same thing, only they use different drivers.
Another example would a z-wave or bluetooth driver plugin which could be used by other plugins.
I’m not quite sure what would be the best way to implement this but if you look at the way Homey does this:
var Signal = Homey.wireless('433').Signal;
// create & register a signal using the id from your app.json
var mySignal = new Signal('my_signal');
mySignal.register(function callback( err, result ){
if( err ) return console.error( err );
// on a receive event
mySignal.on('payload', function( payload ){
console.log('received from a device:', payload)
});
// transmit the bits 01011001
mySignal.tx([ 0, 1, 0, 1, 1, 0, 0, 1 ], console.log)
// unregister the signal
mySignal.unregister( console.log );
});
You subscribe to the wireless
driver and wait for updates. This way you’re super flexible and you create consistency / less duplicate plugins.
I don’t say this should be the way to do it, but it might be a step in the right direction.