Exemplo n.º 1
0
        public ActionResult ToggleSwitchState(uint homeId, byte nodeId, ulong valueId, SwitchState currentState)
        {
            var zWaveIdentity = new ZWaveValueIdentity(homeId, nodeId, valueId);
            var newState      = currentState == SwitchState.On ? SwitchState.Off : SwitchState.On;
            var result        = _zWaveNetwork.SetSwitchState(zWaveIdentity, newState);

            if (result.IsSuccessful)
            {
                return(Json(new { isSuccessful = true, newState = newState.ToString() }));
            }
            else
            {
                return(Json(new { isSuccessful = false, errorMessage = result.Message }));
            }
        }
Exemplo n.º 2
0
        public void Update()
        {
            var masterModel = _repository.GetCurrent();

            _projectStatusUpdater.UpdateAllProjectStatuses(masterModel);
            _repository.Save(masterModel);

            foreach (var project in masterModel.Projects)
            {
                var projectStatus = project.StatusMode.StatusLightConfiguration;
                foreach (var lightGroup in project.Groups)
                {
                    foreach (var light in lightGroup.Lights)
                    {
                        _zWaveNetwork.SetSwitchState(light.ZWaveIdentity, projectStatus[light.Color]);
                    }
                }
            }
        }