roblans / ZWave4Net

ZWave4Net is a .NET library that interfaces with the Aeotec / Aeon Labs Z-Stick.
MIT License
41 stars 34 forks source link

Poor design #8

Closed beugnen closed 7 years ago

beugnen commented 7 years ago

It's not apparent that for any given node, what command class is relevant. Following from this is that the library is poorly designed where there is little typesafety. I could quite easily try and execute a command on a node that makes no sense.

Consider the following

     var nodes = await controller.GetNodes();

    // get the motionSensor
    var motionSensor = nodes[motionSensorID];

    // get the SensorAlarm commandclass
    var sensorAlarm = motionSensor.GetCommandClass<SensorAlarm>();
    var switchBinary = motionSensor.GetCommandClass<SwitchBinary>();

I'm pretty sure my Aeotec Multisensor has no switch; likewise my Smart Switch 6 has no "alarm".

I feel this library is not intuitive either with it's lack of object-orientation. e.g. trying to obtain power consumption for a given meter. It would have been better if there were an actual

             var switches = await controller.EnumerateAsync<IBinarySwitch>();
             var switch = switches[2];
             var consumption =  await switch.GetPowerConsumptionAsync();

...rather than the following code which has no compile-time checking:

            var switchBinary = device.GetCommandClass<SwitchBinary>();
            var report = await switchBinary.Get();

            var meter=device.GetCommandClass<Meter>();
            var supportedMeter = await meter.GetSupported();

An interesting library but its too immature for me

sstraus commented 7 years ago

Have you found good alternatives?