This project is read-only.

How to: Create an App

Applications expose device functionality to users through a user interface. This is where users can interact with and control the device. This tutorial will show you how to create your own HomeOS app by using the "dummy" example app as a starting point.

Note: Prior to beginning this tutorial you'll need to:
- Get the source code and configure your development environment
- Complete the How to: Create a Scout tutorial
- Complete the How to: Create a Driver tutorial

Create a New Project for your App

  1. Open core.sln in Visual Studio.
  2. Right click the Apps folder and select Add, New Project.
  3. In the left pane select Visual C#, then choose Class Library from the list.
  4. Under Location click Browse.
  5. Click the Apps folder, then click Select Folder.
  6. Under Name call the new project Dummy2.
  7. Click OK to create the project.

Use Dummy App as a Starting Point

  1. In Solution Explorer, expand the Apps\Dummy folder.
  2. Copy the Styles folder, and then paste it into the Dummy2 project.
  3. Copy the following files from Apps\Dummy and paste them into the Dummy2 project.

    • App.config
    • Dummy.cs
    • DummyService.cs
    • icon.png
    • IDummyContract.cs
    • index.html
  4. In Solution Explorer right-click Dummy2\Class1.cs and select Delete. Click OK when prompted to permanently delete the file.

Add references

  1. In Solution Explorer right-click the Dummy2 project and select Add Reference....
  2. In Reference Manager, click Browse. The assemblies can be found in \Hub\output\binaries\Platform.
  3. Select the following assemblies:

    • HomeOS.Hub.Common.dll
    • HomeOS.Hub.Common.Bolt.DataStore.dll
    • HomeOS.Hub.Platform.Views.dll
    • HomeOS.Shared.dll
  4. Click Add, then click OK to add the references.

  5. In Solution Explorer, right-click the reference for HomeOS.Hub.Platform.Views and select Properties.
  6. Set the Copy Local property to False. This will prevent the Views assembly from being output since doing that would prevent the project from running properly.
  7. In Solution Explorer right-click the Dummy2 project and select Add Reference... one more time.
  8. In the left pane click Assemblies, then click Framework and select the following item:

    • System.AddIn
    • System.ServiceModel
    • System.ServiceModel.Web
  9. Click OK to add the references.

Refactor Names

  1. Open Dummy2\Dummy.cs and make the following changes:
    • Rename the namespace to HomeOS.Hub.Apps.Dummy2. Do not use Visual Studio's automatic refactoring feature, as this will result in unwanted refactoring throughout the solution.
    • Above the main class declaration, rename the driver to [System.AddIn.AddIn("HomeOS.Hub.Apps.Dummy2")].
    • Rename the main class to Dummy2 (it derives from ModuleBase).
  2. Within Dummy2\Dummy.cs use search and replace to rename all instances of RoleDummy to RoleDummy2.
  3. Open Dummy2\DummyService.cs and make the following changes:

    • Rename the namespace to HomeOS.Hub.Apps.Dummy2. Do not use Visual Studio's automatic refactoring feature, as this will result in unwanted refactoring throughout the solution.
    • In the DummyService class, change Dummy to Dummy2 as shown here:

      protected VLogger logger;
      Dummy2 Dummy;
      
      public DummyService(VLogger logger, Dummy2 Dummy)
      {
          this.logger = logger;
          this.Dummy = Dummy;
      }   
      ...
      

Set Project Properties

  1. In Solution Explorer right-click the Dummy2 project and select Properties.
  2. Click the Application tab and change the Assembly name and Default namespace values to HomeOS.Hub.Apps.Dummy2.
  3. Click the Build tab and update the Output path property to ..\..\output\binaries\Pipeline\AddIns\HomeOS.Hub.Apps.Dummy2\.
  4. Right-click the Apps\Dummy2 project and select Build.
  5. Verify that the correct output was generated by navigating to Hub\output\binaries\pipeline\AddIns. You should see the output folder for your new driver HomeOS.Hub.Apps.Dummy2.

Add the Dummy2 App and Role to the Catalog

  1. In Solution Explorer, expand the Platform folder, then expand the HomeStore folder.
  2. Open RoleDb.xml.
  3. Directly below the entry for dummy, add an entry for dummy2:

    <Role Name=":dummy2:"/>
    
  4. Open ModuleDb.xml.

  5. Locate the entry for AppDummy, and add a new entry for AppDummy2 directly beneath: <Module AppName="AppDummy2" BinaryName="HomeOS.Hub.Apps.Dummy2" Description="Example basic application 2" Rating="5"> <RoleList> <Role Name=":dummy2:"/> </RoleList> </Module>

Test Your App

  1. Navigate to the Hub\Output folder.
  2. Right-click the Configs folder and click Delete.
  3. In Solution Explorer, right-click the Platform project and click Rebuild.
  4. Right-click the Platform project once more and select Debug, Start new instance.
  5. Open a browser and go to http://localhost:51430/Guiweb/.
  6. Click Add Devices. In the list of devices, click dummy2device.
  7. On the Final Device Setup page, give the new device a name.
  8. Under Install these applications, check AppDummy2.
  9. Click Done.
  10. On the main dashboard page you should see an entry for the AppDummy2 app. Click this, and on the app page click Update to see the messages received by the app. Pat yourself on the back, you're now ready to go and develop your own HomeOS apps!

Last edited Jan 15, 2014 at 9:07 PM by willum070, version 2

Comments

willum070 Aug 22, 2014 at 8:45 PM 
Check out the OpenWeatherMap scout, driver, and app. It does precisely that!

cbo90 May 29, 2014 at 5:09 AM 
Is it also possible to add an application which is independent from devices but is responsible for visualizing data saved in the cloud?