public ZWavePowerPlugDevice(string id, string title, bool automated, ZWayDevice switchDevice, ZWayDevice powerDevice, IDeviceService parentService) : base(id, title, switchDevice, parentService) { InternalPowerDevice = powerDevice; if (InternalPowerDevice != null && !string.Equals(InternalPowerDevice.deviceType, "sensormultilevel", StringComparison.InvariantCultureIgnoreCase)) { throw new ZWayDeviceConfigurationException($"{nameof(ZWayDevice)} must have deviceType 'sensormultilevel'. Is '{InternalPowerDevice.deviceType}'"); } if (!string.Equals(switchDevice.deviceType, "switchBinary", StringComparison.InvariantCultureIgnoreCase)) { throw new ZWayDeviceConfigurationException($"{nameof(ZWayDevice)} must have deviceType 'switchBinary'. Is '{switchDevice.deviceType}'"); } if (InternalPowerDevice != null) { InternalPowerDevice.ParentDevice = this; } Automated = automated; }
public ZWaveDevice(string id, string title, ZWayDevice zWayDevice, IDeviceService parentService) { Id = id; Title = title; ParentService = parentService; InternalDevice = zWayDevice; if (InternalDevice.ParentDevice != null) { throw new ZWayDeviceConfigurationException("A ZWayDevice cannot have multiple parent devices"); } if (!string.Equals(InternalDevice.deviceType, "sensormultilevel", StringComparison.InvariantCultureIgnoreCase) && !string.Equals(InternalDevice.deviceType, "sensorbinary", StringComparison.InvariantCultureIgnoreCase) && !string.Equals(InternalDevice.deviceType, "switchBinary", StringComparison.InvariantCultureIgnoreCase)) { throw new ZWayDeviceConfigurationException($"{nameof(ZWayDevice)} must have deviceType 'sensormultilevel', 'sensorBinary' or 'switchBinary'. Is '{InternalDevice.deviceType}'"); } InternalDevice.ParentDevice = this; InternalDevice.OnDeviceUpdated += OnInternalDeviceUpdated; }