public ApplianceCommand getApplianceCommand(SenseGuardAppliance appliance)
        {
            ApiResponse <ApplianceCommand> applianceApiResponse = getApiClient()
                                                                  .get <ApplianceCommand>(String.Format(getApiClient().apiPath() + APPLIANCE_COMMAND_URL_TEMPLATE,
                                                                                                        appliance.getRoom().getLocation().getId(),
                                                                                                        appliance.getRoom().getId(),
                                                                                                        appliance.getApplianceId()
                                                                                                        ));

            if (applianceApiResponse.getStatusCode() != 200)
            {
                return(null);
            }

            ApplianceCommand applianceDataOptional = applianceApiResponse.getContent();

            if (applianceDataOptional != null)
            {
                ApplianceCommand applianceData = applianceDataOptional;
                applianceData.setAppliance(appliance);
                applianceDataOptional = applianceData;
            }

            return(applianceDataOptional);
        }
Example #2
0
        /*
         * Constructor
         */

        public CommandListViewItemCIO(ApplianceCommand cmd)
        {
            _command = cmd;

            _command.EnableChangedEvent += new PUC.ApplianceObject.EnableChangedHandler(this.enableChanged);
            _command.LabelChangedEvent  += new PUC.ApplianceObject.LabelChangedHandler(this.labelChanged);
        }
Example #3
0
        static void Main(string[] args)
        {
            string userName = ""; // The username of the GROHE account
            string password = ""; // The password of the GROHE account

            OndusService ondusService = OndusService.loginWebForm(userName, password);

            //string refresh = ondusService.refreshAuthorization();
            //DateTime expireDate = ondusService.authorizationExpiresAt();

            List <Location> locationList = ondusService.getLocations();

            foreach (Location currentLocation in locationList)
            {
                Console.WriteLine(currentLocation);

                List <Room> roomList = ondusService.getRooms(currentLocation);

                foreach (Room currentRoom in roomList)
                {
                    Console.WriteLine(currentRoom);

                    List <BaseAppliance> applianceList = ondusService.getAppliances(currentRoom);

                    foreach (BaseAppliance currentAppliance in applianceList)
                    {
                        switch (currentAppliance.getType())
                        {
                        case SenseAppliance.TYPE:
                            SenseAppliance senseAppliance = ondusService.getAppliance(currentRoom, currentAppliance.getApplianceId()) as SenseAppliance;

                            Console.WriteLine(senseAppliance);

                            break;

                        case SenseGuardAppliance.TYPE:
                            SenseGuardAppliance senseGuardAppliance = ondusService.getAppliance(currentRoom, currentAppliance.getApplianceId()) as SenseGuardAppliance;

                            Console.WriteLine(senseGuardAppliance);

                            ApplianceCommand applianceCommand = ondusService.getApplianceCommand(senseGuardAppliance);

                            Console.WriteLine(applianceCommand);

                            //ondusService.setValveOpen(senseGuardAppliance, false);
                            //ondusService.setValveOpen(senseGuardAppliance, true);

                            break;
                        }

                        ApplianceStatus applianceStatus = ondusService.getApplianceStatus(currentAppliance);
                        Console.WriteLine(applianceStatus);

                        BaseApplianceData baseApplianceData = ondusService.getApplianceData(currentAppliance, DateTime.Now - TimeSpan.FromDays(1), DateTime.Now);
                        Console.WriteLine(baseApplianceData);
                    }
                }
            }
        }
 public void putApplianceCommand(SenseGuardAppliance appliance, ApplianceCommand command)
 {
     getApiClient()
     .post <ApplianceCommand>(String.Format(getApiClient().apiPath() + APPLIANCE_COMMAND_URL_TEMPLATE,
                                            appliance.getRoom().getLocation().getId(),
                                            appliance.getRoom().getId(),
                                            appliance.getApplianceId()),
                              command);
 }
Example #5
0
        /*
         * Constructors
         */


        public MediaCommandAction(ImageButton button, ApplianceCommand cmd)
            : base(button)
        {
            _command = cmd;

            _command.EnableChangedEvent += new PUC.ApplianceObject.EnableChangedHandler(_command_EnableChangedEvent);

            _button.Activated += new EventHandler(_button_Activated);
        }
        public IActionResult SendCommand(int id, [FromBody] ApplianceCommand remoteCommand)
        {
            SendToConditionerCommand command = new SendToConditionerCommand()
            {
                Command = remoteCommand, DeviceID = id
            };

            commandBus.Execute(command);
            return(Ok());
        }
Example #7
0
        /// <summary>
        /// Changes the valve state of the appliance. The call to this function is blocking until the API acknowledges the
        /// execution or failure of the command.
        /// </summary>
        /// <param name="appliance">The appliance to change the valve state of</param>
        /// <param name="open">The requested valve state</param>
        public void setValveOpen(SenseGuardAppliance appliance, bool open)
        {
            ApplianceAction action = apiClient.getAction <ApplianceAction>();

            ApplianceCommand applianceCommandOptional = getApplianceCommand(appliance);

            if (applianceCommandOptional == null)
            {
                return;
            }

            ApplianceCommand applianceCommand = applianceCommandOptional;

            ApplianceCommand.Command command = applianceCommand.getCommand();
            command.setValveOpen(open);
            applianceCommand.setCommand(command);

            action.putApplianceCommand(appliance, applianceCommand);
        }
Example #8
0
        /*
         * Constructor
         */

        public MediaControlsSmartCIO(GroupNode specSnippet)
            : base(new PhoneMediaControls(), specSnippet)
        {
            _valueToTypeMap = new Hashtable();

            if (_specSnippet.IsObject())
            {
                // single state translations
                _playState = (ApplianceState)_objects[SINGLE_STATE];

                createButtonsFromState();
            }
            else
            {
                // multiple state translation

                _playState = (ApplianceState)_objects[MODE_STATE_LABEL];

                createButtonsFromState();

                IEnumerator objenum = _objects.Keys.GetEnumerator();
                while (objenum.MoveNext())
                {
                    string name = (string)objenum.Current;

                    try
                    {
                        ApplianceCommand   cmd = (ApplianceCommand)_objects[name];
                        MediaCommandAction m;

                        switch (name)
                        {
                        case PLAY_LABEL:
                            m = new MediaCommandAction(cmd);
                            ((PhoneMediaControls)GetControl()).Play += new EventHandler(m.Activate);
                            break;

                        case STOP_LABEL:
                            m = new MediaCommandAction(cmd);
                            ((PhoneMediaControls)GetControl()).Stop += new EventHandler(m.Activate);
                            break;

                        case PAUSE_LABEL:
                            m = new MediaCommandAction(cmd);
                            ((PhoneMediaControls)GetControl()).Pause += new EventHandler(m.Activate);
                            break;

                        case NEXT_TRK_CMD_LABEL:
                            m = new MediaCommandAction(cmd);
                            ((PhoneMediaControls)GetControl()).NextTrack       += new EventHandler(m.Activate);
                            ((PhoneMediaControls)GetControl()).NextTrackEnabled = cmd.Enabled;
                            cmd.EnableChangedEvent += new PUC.ApplianceObject.EnableChangedHandler(NextTrack_EnableChangedEvent);
                            break;

                        case PREV_TRK_CMD_LABEL:
                            m = new MediaCommandAction(cmd);
                            ((PhoneMediaControls)GetControl()).PrevTrack       += new EventHandler(m.Activate);
                            ((PhoneMediaControls)GetControl()).PrevTrackEnabled = cmd.Enabled;
                            cmd.EnableChangedEvent += new PUC.ApplianceObject.EnableChangedHandler(PrevTrack_EnableChangedEvent);
                            break;
                        }
                    }
                    catch (Exception)
                    {
                        // probably a ClassCastException because the object wasn't a
                        // command ignore this case (because this high-level type
                        // doesn't recognize states besides Mode)
                    }
                }
            }
        }
Example #9
0
        /*
         * Constructor
         */

        public MediaCommandAction(ApplianceCommand cmd)
        {
            _cmd = cmd;
        }
Example #10
0
        /*
         * Constructor
         */

        public DimmerSmartCIO(GroupNode specSnippet)
            : base(new Panel(), specSnippet)
        {
            if (_specSnippet.IsObject())
            {
                // single state translation

                // this means that there is only a dimmer and no on or off switches

                _dimState   = (ApplianceState)_objects[SINGLE_STATE];
                _onCommand  = null;
                _offCommand = null;
            }
            else
            {
                // multiple state translation

                _dimState   = (ApplianceState)_objects[DIM_LABEL];
                _onCommand  = (ApplianceCommand)_objects[ON_LABEL];
                _offCommand = (ApplianceCommand)_objects[OFF_LABEL];
            }

            if (_dimState != null)
            {
                doNotRenderObject(_dimState);

                _dimmerControl             = new HScrollBar();
                _dimmerControl.Minimum     = 0;
                _dimmerControl.SmallChange = 1;
                _dimmerControl.LargeChange = 10;
                _dimmerControl.Maximum     = 109;
                GetControl().Controls.Add(_dimmerControl);

                _sentValues = new Hashtable();

                _dimState.ValueChangedEvent  += new PUC.ApplianceState.ValueChangedHandler(this.ValueChanged);
                _dimState.EnableChangedEvent += new PUC.ApplianceObject.EnableChangedHandler(this.EnableChanged);
                _dimmerControl.ValueChanged  += new EventHandler(this._dimmerControl_ValueChanged);
            }

            System.Drawing.Font f = new System.Drawing.Font("Tahoma", 9, System.Drawing.FontStyle.Regular);

            if (_onCommand != null)
            {
                doNotRenderObject(_onCommand);

                _onButton      = new Button();
                _onButton.Text = "On";
                _onButton.Font = f;
                GetControl().Controls.Add(_onButton);

                _onCommand.EnableChangedEvent += new PUC.ApplianceObject.EnableChangedHandler(this.EnableChanged);
                _onButton.Click += new EventHandler(_onButton_Click);
            }

            if (_offCommand != null)
            {
                doNotRenderObject(_offCommand);

                _offButton      = new Button();
                _offButton.Text = "Off";
                _offButton.Font = f;
                GetControl().Controls.Add(_offButton);

                _offCommand.EnableChangedEvent += new PUC.ApplianceObject.EnableChangedHandler(this.EnableChanged);
                _offButton.Click += new EventHandler(_offButton_Click);
            }

            GetControl().Resize += new EventHandler(this.Resized);
        }
Example #11
0
        /*
         * Constructor
         */

        public MediaControlsSmartCIO(GroupNode specSnippet)
            : base(new Panel(), specSnippet)
        {
            _mediaActions = new ArrayList();

            if (_specSnippet.IsObject())
            {
                // single state translations
                _playState = (ApplianceState)_objects[SINGLE_STATE];

                createButtonsFromState();
            }
            else
            {
                // multiple state translation

                _playState = (ApplianceState)_objects[MODE_STATE_LABEL];

                createButtonsFromState();

                IEnumerator objenum = _objects.Keys.GetEnumerator();
                while (objenum.MoveNext())
                {
                    string name = (string)objenum.Current;

                    try
                    {
                        ApplianceCommand cmd = (ApplianceCommand)_objects[name];

                        switch (name)
                        {
                        case PLAY_LABEL:
                            _playBtn = createImageButton(PLAY_IMG_NAME);
                            _mediaActions.Add(new MediaCommandAction(_playBtn, cmd));
                            doNotRenderObject(cmd);
                            break;

                        case STOP_LABEL:
                            _stopBtn = createImageButton(STOP_IMG_NAME);
                            _mediaActions.Add(new MediaCommandAction(_stopBtn, cmd));
                            doNotRenderObject(cmd);
                            break;

                        case PAUSE_LABEL:
                            _pauseBtn = createImageButton(PAUSE_IMG_NAME);
                            _mediaActions.Add(new MediaCommandAction(_pauseBtn, cmd));
                            doNotRenderObject(cmd);
                            break;

                        case REWIND_LABEL:
                            _rewindBtn = createImageButton(REWIND_IMG_NAME);
                            _mediaActions.Add(new MediaCommandAction(_rewindBtn, cmd));
                            doNotRenderObject(cmd);
                            break;

                        case FFWD_LABEL:
                            _fastFwdBtn = createImageButton(FFWD_IMG_NAME);
                            _mediaActions.Add(new MediaCommandAction(_fastFwdBtn, cmd));
                            doNotRenderObject(cmd);
                            break;

                        case RECORD_LABEL:
                            _recordBtn = createImageButton(RECORD_IMG_NAME);
                            _mediaActions.Add(new MediaCommandAction(_recordBtn, cmd));
                            doNotRenderObject(cmd);
                            break;

                        case NEXT_TRK_CMD_LABEL:
                            _nextTrackBtn = createImageButton(NEXTTRACK_IMG_NAME);
                            _mediaActions.Add(new MediaCommandAction(_nextTrackBtn, cmd));
                            doNotRenderObject(cmd);
                            break;

                        case PREV_TRK_CMD_LABEL:
                            _prevTrackBtn = createImageButton(PREVTRACK_IMG_NAME);
                            _mediaActions.Add(new MediaCommandAction(_prevTrackBtn, cmd));
                            doNotRenderObject(cmd);
                            break;
                        }
                    }
                    catch (Exception)
                    {
                        // probably a ClassCastException because the object wasn't a
                        // command ignore this case (because this high-level type
                        // doesn't recognize states besides Mode)
                    }
                }
            }

            // layout buttons
            layoutButtons();

            GetControl().Resize += new EventHandler(MediaControlsSmartCIO_Resize);
        }