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); }
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); } }
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); } }
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); }
internal void AddDevice(OpenZWaveDevice device) { _devices.Add(device); }
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); }
public OpenZWaveHumiditySensor(OpenZWaveDevice device) { _dataEntry = new HumiditySensorDataEntry(device); }
public OpenZWaveThermostatCore(OpenZWaveDevice device) { _mode = new ThermostatModeDataEntry(device); _currentAction = new ThermostatCoreCurrentActionDataEntry(device); }
public OpenZWavePowerSensor(OpenZWaveDevice device) { _device = device; _dataEntry = new ImmediatePowerDataEntry(device); }
public OpenZWaveToggleSwitch(OpenZWaveDevice device) { _device = device; _dataEntry = new SwitchBinaryDataEntry(device); }
public OpenZWaveIlluminanceSensor(OpenZWaveDevice device) { _dataEntry = new IlluminanceSensorDataEntry(device); }
public OpenZWaveBinarySensor(OpenZWaveDevice device) { _device = device; _dataEntry = new BinarySensorDataEntry(device); }
public OpenZWaveDimmerSwitch(OpenZWaveDevice device) { _device = device; _dataEntry = new SwitchMultilevelDataEntry(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 OpenZWaveEvent(OpenZWaveDevice device) { _device = device; }
public OpenZWaveTemperatureSensor(OpenZWaveDevice device) { _dataEntry = new ThermometerDataEntry(device); }