private void HandleDeviceConnected(OpenZWaveDevice device, bool connected)
        {
            if (device.IsConnected == connected)
            {
                return;
            }

            device.IsConnected = connected;

            var @event = connected ? DeviceEvent.Found(device, null) : DeviceEvent.Lost(device, null);

            device.AddEvent(@event);
        }
Example #2
0
        public static string FormatData(this OpenZWaveDevice device)
        {
            var result = new StringBuilder();

            foreach (var value in device.Values)
            {
                var entry = value.FormatData();

                result.AppendLine(entry);
            }

            return(result.ToString());
        }
        public OpenZWaveSetpointCollection(OpenZWaveDevice device)
        {
            _setpoints = new Dictionary<ThermostatSetpointType, ThermostatSetpointDataEntry>();

            var setpointTypes = new[]
            {
                ThermostatSetpointType.Heat,
                ThermostatSetpointType.Cool
            };

            foreach (var setpointType in setpointTypes)
            {
                var setpoint = new ThermostatSetpointDataEntry(device, setpointType);

                _setpoints.Add(setpointType, setpoint);
            }
        }
Example #4
0
        public OpenZWaveSetpointCollection(OpenZWaveDevice device)
        {
            _setpoints = new Dictionary <ThermostatSetpointType, ThermostatSetpointDataEntry>();

            var setpointTypes = new[]
            {
                ThermostatSetpointType.Heat,
                ThermostatSetpointType.Cool
            };

            foreach (var setpointType in setpointTypes)
            {
                var setpoint = new ThermostatSetpointDataEntry(device, setpointType);

                _setpoints.Add(setpointType, setpoint);
            }
        }
Example #5
0
        public override Device RemoveDevice()
        {
            OpenZWaveDevice device = null;

            using (var watcher = new ControllerNotificationWatcher(this))
            {
                Manager.RemoveNode(HomeId.Value);

                watcher.ProcessChanges(notification =>
                {
                    if (notification.Type == ZWNotification.Type.NodeRemoved)
                    {
                        device = notification.Device;
                        return(ControllerNotificationWatcher.ProcessAction.Quit);
                    }

                    return(ControllerNotificationWatcher.ProcessAction.Continue);
                });
            }

            return(device);
        }
Example #6
0
 internal void AddDevice(OpenZWaveDevice device)
 {
     _devices.Add(device);
 }
Example #7
0
 public OpenZWaveThermostat(OpenZWaveDevice device)
 {
     _core = new OpenZWaveThermostatCore(device);
     _fan = new OpenZWaveThermostatFan(device);
     _setpoints = new OpenZWaveSetpointCollection(device);
 }
 private void HandleDeviceValueUpdated(OpenZWaveDevice device, OpenZWaveDeviceValue value, ValueUpdateType updateType)
 {
     HandleDeviceConnected(device, true);
     device.ProcessValueUpdate(value, updateType);
 }
Example #9
0
 public OpenZWaveHumiditySensor(OpenZWaveDevice device)
 {
     _dataEntry = new HumiditySensorDataEntry(device);
 }
 private void HandleDeviceValueUpdated(OpenZWaveDevice device, OpenZWaveDeviceValue value, ValueUpdateType updateType)
 {
     HandleDeviceConnected(device, true);
     device.ProcessValueUpdate(value, updateType);
 }
Example #11
0
 public OpenZWaveThermostatCore(OpenZWaveDevice device)
 {
     _mode = new ThermostatModeDataEntry(device);
     _currentAction = new ThermostatCoreCurrentActionDataEntry(device);
 }
Example #12
0
 public OpenZWavePowerSensor(OpenZWaveDevice device)
 {
     _device    = device;
     _dataEntry = new ImmediatePowerDataEntry(device);
 }
Example #13
0
 public OpenZWaveToggleSwitch(OpenZWaveDevice device)
 {
     _device    = device;
     _dataEntry = new SwitchBinaryDataEntry(device);
 }
Example #14
0
 public OpenZWaveToggleSwitch(OpenZWaveDevice device)
 {
     _device = device;
     _dataEntry = new SwitchBinaryDataEntry(device);
 }
 public OpenZWaveIlluminanceSensor(OpenZWaveDevice device)
 {
     _dataEntry = new IlluminanceSensorDataEntry(device);
 }
Example #16
0
 public OpenZWaveBinarySensor(OpenZWaveDevice device)
 {
     _device    = device;
     _dataEntry = new BinarySensorDataEntry(device);
 }
Example #17
0
 public OpenZWaveThermostat(OpenZWaveDevice device)
 {
     _core      = new OpenZWaveThermostatCore(device);
     _fan       = new OpenZWaveThermostatFan(device);
     _setpoints = new OpenZWaveSetpointCollection(device);
 }
Example #18
0
 internal void AddDevice(OpenZWaveDevice device)
 {
     _devices.Add(device);
 }
Example #19
0
 public OpenZWaveDimmerSwitch(OpenZWaveDevice device)
 {
     _device    = device;
     _dataEntry = new SwitchMultilevelDataEntry(device);
 }
Example #20
0
 public OpenZWaveThermostatCore(OpenZWaveDevice device)
 {
     _mode          = new ThermostatModeDataEntry(device);
     _currentAction = new ThermostatCoreCurrentActionDataEntry(device);
 }
        public void Process(OpenZWaveNotification notification)
        {
            if (_network.HomeId == null)
            {
                _network.SetHomeId(notification.HomeId);

            }

            if (_network.HomeId != notification.HomeId)
            {
                throw new Exception("Unexpected Home ID");
            }

            Debug.WriteLine(notification.NodeId + "\t" + notification.Type + "\t" + notification.Event + "\t" + notification.Value.GetValue());

            //TODO: fill in other cases
            switch (notification.Type)
            {
                case NotificationType.AllNodesQueried:
                    _network.Log("All nodes queried");
                    break;

                case NotificationType.AllNodesQueriedSomeDead:
                    _network.Log("All nodes queried, some dead");
                    break;

                case NotificationType.AwakeNodesQueried:
                    _network.Log("All awake nodes queried");
                    break;

                case NotificationType.ButtonOff:
                case NotificationType.ButtonOn:
                case NotificationType.ControllerCommand:
                case NotificationType.CreateButton:
                case NotificationType.DeleteButton:
                case NotificationType.DriverFailed:
                case NotificationType.DriverReady:
                case NotificationType.DriverRemoved:
                case NotificationType.DriverReset:
                case NotificationType.EssentialNodeQueriesComplete:
                case NotificationType.Group:
                    break;

                case NotificationType.NodeAdded:
                    var newDevice = new OpenZWaveDevice(_network, _network.Manager, notification.NodeId);
                    _network.AddDevice(newDevice);
                    break;

                case NotificationType.NodeEvent:
                    var device = notification.Device;

                    HandleDeviceConnected(device, true);

                    device.Event.Update(notification.Event);
                    break;

                case NotificationType.NodeNaming:
                    Nodification("node named", notification);
                    break;

                case NotificationType.NodeNew:
                    Nodification("new device", notification);
                    break;

                case NotificationType.NodeProtocolInfo:
                    Nodification("protocol info", notification);
                    break;

                case NotificationType.NodeQueriesComplete:
                    Nodification("queries complete", notification);
                    break;

                case NotificationType.NodeRemoved:
                    Nodification("removed", notification);
                    break;

                case NotificationType.Notification:
                    HandleDeviceConnected(notification.Device, false);
                    break;

                case NotificationType.PollingDisabled:
                    Nodification("polling disabled", notification);
                    break;

                case NotificationType.PollingEnabled:
                    Nodification("polling enabled", notification);
                    break;

                case NotificationType.SceneEvent:
                    break;

                case NotificationType.ValueAdded:
                    notification.Device.Values.Add(notification.Value);
                    HandleDeviceValueUpdated(notification.Device, notification.Value, ValueUpdateType.Add);
                    break;

                case NotificationType.ValueRefreshed:
                    HandleDeviceValueUpdated(notification.Device, notification.Value, ValueUpdateType.Refresh);
                    break;

                case NotificationType.ValueChanged:
                    HandleDeviceValueUpdated(notification.Device, notification.Value, ValueUpdateType.Change);
                    break;

                case NotificationType.ValueRemoved:
                    notification.Device.Values.Remove(notification.Value);
                    HandleDeviceValueUpdated(notification.Device, notification.Value, ValueUpdateType.Remove);
                    break;

                default:
                    throw new Exception("Unexpected notification type " + notification.Type);
            }
        }
Example #22
0
 public OpenZWaveEvent(OpenZWaveDevice device)
 {
     _device = device;
 }
        public void Process(OpenZWaveNotification notification)
        {
            if (_network.HomeId == null)
            {
                _network.SetHomeId(notification.HomeId);
            }

            if (_network.HomeId != notification.HomeId)
            {
                throw new Exception("Unexpected Home ID");
            }

            Debug.WriteLine(notification.NodeId + "\t" + notification.Type + "\t" + notification.Event + "\t" + notification.Value.GetValue());

            //TODO: fill in other cases
            switch (notification.Type)
            {
            case NotificationType.AllNodesQueried:
                _network.Log("All nodes queried");
                break;

            case NotificationType.AllNodesQueriedSomeDead:
                _network.Log("All nodes queried, some dead");
                break;

            case NotificationType.AwakeNodesQueried:
                _network.Log("All awake nodes queried");
                break;

            case NotificationType.ButtonOff:
            case NotificationType.ButtonOn:
            case NotificationType.ControllerCommand:
            case NotificationType.CreateButton:
            case NotificationType.DeleteButton:
            case NotificationType.DriverFailed:
            case NotificationType.DriverReady:
            case NotificationType.DriverRemoved:
            case NotificationType.DriverReset:
            case NotificationType.EssentialNodeQueriesComplete:
            case NotificationType.Group:
                break;

            case NotificationType.NodeAdded:
                var newDevice = new OpenZWaveDevice(_network, _network.Manager, notification.NodeId);
                _network.AddDevice(newDevice);
                break;

            case NotificationType.NodeEvent:
                var device = notification.Device;

                HandleDeviceConnected(device, true);

                device.Event.Update(notification.Event);
                break;

            case NotificationType.NodeNaming:
                Nodification("node named", notification);
                break;

            case NotificationType.NodeNew:
                Nodification("new device", notification);
                break;

            case NotificationType.NodeProtocolInfo:
                Nodification("protocol info", notification);
                break;

            case NotificationType.NodeQueriesComplete:
                Nodification("queries complete", notification);
                break;

            case NotificationType.NodeRemoved:
                Nodification("removed", notification);
                break;

            case NotificationType.Notification:
                HandleDeviceConnected(notification.Device, false);
                break;

            case NotificationType.PollingDisabled:
                Nodification("polling disabled", notification);
                break;

            case NotificationType.PollingEnabled:
                Nodification("polling enabled", notification);
                break;

            case NotificationType.SceneEvent:
                break;

            case NotificationType.ValueAdded:
                notification.Device.Values.Add(notification.Value);
                HandleDeviceValueUpdated(notification.Device, notification.Value, ValueUpdateType.Add);
                break;

            case NotificationType.ValueRefreshed:
                HandleDeviceValueUpdated(notification.Device, notification.Value, ValueUpdateType.Refresh);
                break;

            case NotificationType.ValueChanged:
                HandleDeviceValueUpdated(notification.Device, notification.Value, ValueUpdateType.Change);
                break;

            case NotificationType.ValueRemoved:
                notification.Device.Values.Remove(notification.Value);
                HandleDeviceValueUpdated(notification.Device, notification.Value, ValueUpdateType.Remove);
                break;

            default:
                throw new Exception("Unexpected notification type " + notification.Type);
            }
        }
 public OpenZWaveTemperatureSensor(OpenZWaveDevice device)
 {
     _dataEntry = new ThermometerDataEntry(device);
 }
Example #25
0
 public OpenZWaveBinarySensor(OpenZWaveDevice device)
 {
     _device = device;
     _dataEntry = new BinarySensorDataEntry(device);
 }
Example #26
0
 public OpenZWaveEvent(OpenZWaveDevice device)
 {
     _device = device;
 }
Example #27
0
 public OpenZWaveDimmerSwitch(OpenZWaveDevice device)
 {
     _device = device;
     _dataEntry = new SwitchMultilevelDataEntry(device);
 }
        private void HandleDeviceConnected(OpenZWaveDevice device, bool connected)
        {
            if (device.IsConnected == connected)
            {
                return;
            }

            device.IsConnected = connected;

            var @event = connected ? DeviceEvent.Found(device, null) : DeviceEvent.Lost(device, null);
            device.AddEvent(@event);
        }