private void UpdateDevice(string station, IStationModule module)
        {
            var id = $"{station}-{module.ModuleName}";

            var device = GetDevices().SingleOrDefault(d => d.Id.Equals(id));

            if (device == null)
            {
                device = new NetatmoDevice(id, module.ModuleName);
                _devices.Add(device);
            }

            PublishVariables(device, module);

            if (module.BatteryPercent > 85)
            {
                device.BatteryStatus = DeviceBatteryStatus.Full;
            }
            else if (module.BatteryPercent > 25)
            {
                device.BatteryStatus = DeviceBatteryStatus.Good;
            }
            else
            {
                device.BatteryStatus = DeviceBatteryStatus.Low;
            }
        }
        private void PublishVariables(NetatmoDevice device, IStationModule module)
        {
            var properties = module.DashboardData.GetType().GetProperties();

            foreach (var property in properties)
            {
                if (module.DataType.Contains(property.Name))
                {
                    var name  = property.Name[0] + property.Name.ToLowerInvariant().Substring(1);
                    var value = (double)property.GetValue(module.DashboardData);
                    _messageQueue.Publish(new UpdateVariableMessage(Name, device.Id, name, value));

                    switch (name)
                    {
                    case "Co2":
                        device.Co2 = module.DashboardData.CO2;
                        break;

                    case "Humidity":
                        device.Humidity = module.DashboardData.Humidity;
                        break;

                    case "Noise":
                        device.Noise = module.DashboardData.Noise;
                        break;

                    case "Pressure":
                        device.Pressure = module.DashboardData.Pressure;
                        break;

                    case "Temperature":
                        device.Temperature = module.DashboardData.Temperature;
                        break;
                    }
                }
            }
        }
        private void PublishVariables(NetatmoDevice device, IStationModule module)
        {
            var properties = module.DashboardData.GetType().GetProperties();

            foreach (var property in properties)
            {
                if (module.DataType.Contains(property.Name))
                {
                    var name = property.Name[0] + property.Name.ToLowerInvariant().Substring(1);
                    var value = (double) property.GetValue(module.DashboardData);
                    _messageQueue.Publish(new UpdateVariableMessage(Name, device.Id, name, value));

                    switch (name)
                    {
                        case "Co2":
                            device.Co2 = module.DashboardData.CO2;
                            break;
                        case "Humidity":
                            device.Humidity = module.DashboardData.Humidity;
                            break;
                        case "Noise":
                            device.Noise = module.DashboardData.Noise;
                            break;
                        case "Pressure":
                            device.Pressure = module.DashboardData.Pressure;
                            break;
                        case "Temperature":
                            device.Temperature = module.DashboardData.Temperature;
                            break;
                    }
                }
            }
        }
        private void UpdateDevice(string station, IStationModule module)
        {
            var id = $"{station}-{module.ModuleName}";

            var device = GetDevices().SingleOrDefault(d => d.Id.Equals(id));

            if (device == null)
            {
                device = new NetatmoDevice(id, module.ModuleName);
                _devices.Add(device);
            }

            PublishVariables(device, module);

            if (module.BatteryPercent > 85)
            {
                device.BatteryStatus = DeviceBatteryStatus.Full;
            }
            else if (module.BatteryPercent > 25)
            {
                device.BatteryStatus = DeviceBatteryStatus.Good;
            }
            else
            {
                device.BatteryStatus = DeviceBatteryStatus.Low;
            }
        }
 public NetatmoScriptObject(NetatmoDevice device)
 {
     _device = device;
 }
 public NetatmoScriptObject(NetatmoDevice device)
 {
     _device = device;
 }