Esempio n. 1
0
        public async Task PopulateDevices(ZWayDeviceConfiguration[] deviceConfigurations)
        {
            _zWaveDeviceDictonary = new Dictionary <string, IDevice>();
            _zWayDeviceDictonary  = (await GetDeviceDataAsync(0)).devices.ToDictionary(d => d.id);

            foreach (var config in deviceConfigurations)
            {
                ZWaveDevice device = null;

                if (!_zWayDeviceDictonary.ContainsKey(config.ZWayId))
                {
                    throw new ZWayDeviceConfigurationException($"No ZWayDevice found with id '{config.ZWayId}'");
                }

                if (config.ZWayPowerId != null && !_zWayDeviceDictonary.ContainsKey(config.ZWayPowerId))
                {
                    throw new ZWayDeviceConfigurationException($"No ZWayDevice found with id '{config.ZWayPowerId}'");
                }

                switch (config.Type)
                {
                case "sensor":
                    device = new ZWaveDevice(id: config.Id, title: config.Title, zWayDevice: _zWayDeviceDictonary[config.ZWayId], parentService: this);
                    break;

                case "powerplug":
                    device = new ZWavePowerPlugDevice
                                 (id: config.Id,
                                 title: config.Title,
                                 automated: config.Automated,
                                 switchDevice: _zWayDeviceDictonary[config.ZWayId],
                                 powerDevice: config.ZWayPowerId == null ? null : _zWayDeviceDictonary[config.ZWayPowerId],
                                 parentService: this);
                    break;

                default:
                    throw new ZWayDeviceConfigurationException($"Unable to create device with type '{config.Type}'");
                }

                device.LastChanged = DateTime.Now;

                _zWaveDeviceDictonary.Add(config.Id, device);
            }
        }
 private void ListValue(RoomieCommandInterpreter interpreter, ZWaveDevice device, byte i)
 {
     var parameter = device.BackingObject.ConfigurationParameters[i];
     interpreter.WriteEvent(i + ": " + parameter.Value);
 }
Esempio n. 3
0
        private void ListValue(RoomieCommandInterpreter interpreter, ZWaveDevice device, byte i)
        {
            var parameter = device.BackingObject.ConfigurationParameters[i];

            interpreter.WriteEvent(i + ": " + parameter.Value);
        }