2014-09-27

Give your home a REST

OpenNetHome have always had a TCP/IP interface for integration in the TCPCommandPort-Item. But it is time to add a more modern interface to my home. I have now implemented a REST-interface with json encoding to OpenNetHome which exposes HomeItems as REST-resources. Since basically everything in OpenNetHome is HomeItems (lamps, thermometers, timers, web-server and so on) this means that most of the features in the server can be reached via this interface. The URL to turn off the lamp in my bedroom window is for example:

POST http://ssgserver2:8020/rest/items/108/actions/off/invoke

and to get the temperature on the balcony i do a get on the URL:

GET http://ssgserver2:8020/rest/items/52

The "108" and "52" are the identities of the corresponding HomeItems, and you can get the identities by listing all HomeItems in the server with:

GET http://ssgserver2:8020/rest/items

This kind of interface works well with modern WEB-frameworks like ember.js and AngularJS but also for integration with phone apps and other home control systems.

The full documentation of the interface is available here on the OpenNethome-site. The implementation is as usual available in the nightly build. Note that details of the interface my still change and feedback on the interface is welcome!

6 comments:

  1. This is really good stuff!
    I look forward to a nice Android app for nethome :)
    I'm amazed how fast the response times are when using the tellstick duo and rasberry. Your protocol encoders are way better than telldus original!

    ReplyDelete
  2. Awesome work again Stefan. Thanks

    ReplyDelete
  3. Ser väldigt bra ut. Men tyvärr har jag övergett tellstick. Det skulle vara bra med stöd för z-wave hemautomationsboxar också. Många går över från tellstick till zipabox www.zipato.com. De har REST API som liknar ditt väldigt mycket. Tror att du skulle få många nya användare då och säkert en hel del med utveckling också.

    http://www.byggahus.se/forum/villalarm-hemautomation/225675-zipabox.html

    Skriv gärna i forumet om du är intresserad av mera info.

    ReplyDelete
  4. Har kört Nethome-server ett tag nu och är riktigt nöjd. En fundering dock: Jag klurar på att bygga en enkel webbapp för att göra ett "mobilvänligt UI" (AngularJS + bootstrap). Hur vore det att sätta "access-control-allow-origin:* " för jetty-servern? Då slipper man bygga ett separat backend för att nå Nethoms API.

    ReplyDelete
    Replies
    1. Good comment, I will look in to adding an access-control-allow-origin filter for the rest servlet

      Delete
  5. This comment has been removed by a blog administrator.

    ReplyDelete