Loading ...
Sorry, an error occurred while loading the content.

19672Re: [rest-discuss] RESTful Toggle

Expand Messages
  • Simpson, Robby (GE Energy Management)
    Jul 9, 2014
      Hi Nick,

      Happy to elaborate.

      I'm certainly not heading down a hypothetical route, though I must admit I am interested in sticking close to a principled, clean design.

      This particular issue has arisen in the design of home automation systems. Specifically, I'm working in a standards body (the ZigBee Alliance) that has classically used a binary protocol that does not really adhere to any true architectural design (IMHO). I've been engaged in work that started in ZigBee and has now moved to IEEE (2030.5) that (attempts to) rigidly stick to a RESTful HTTP design. One request that has come up is to port toggle switch capability to this standard. Home automation manufacturers have actually implemented toggle switches this way in the past (see http://zigbee.org/Products/ByStandard/ZigBeeHomeAutomation.aspx).

      So, in short, I myself am not manufacturing a specific toggle switch, but rather have been working in a standards body where others have requested the inclusion of toggle switch functionality. We also have some use cases for a simple button press, which I see as a similar problem.


      From: "Nick Gall nick.gall@...<mailto:nick.gall@...> [rest-discuss]" <rest-discuss-noreply@yahoogroups.com<mailto:rest-discuss-noreply@yahoogroups.com>>
      Reply-To: Nick Gall <nick.gall@...<mailto:nick.gall@...>>
      Date: Wednesday, July 9, 2014 at 11:14 AM
      Cc: Rest List <rest-discuss@yahoogroups.com<mailto:rest-discuss@yahoogroups.com>>
      Subject: Re: [rest-discuss] RESTful Toggle

      Robby, I'd like to know more about the real world need for such an API. Sure, mechanical light switches DID work this way, but do home automation systems really offer a "toggle"? I'm trying to imagine why I would ever want to simply change the state of the lighting in my room, without caring if the result was lights on or lights off. I can't.

      So are you programming a home automation system? If so, do you really need toggle, given my observation above?

      Or is this just a hypothetical question about the generic behavior of toggle and how it maps to REST? If so, then it kind of feels like the perennial, "Can REST do THIS?" questions that skeptics of REST would lob from time to time in the good old REST v WS-STAR WARS days. It kind of reminds me of the old chestnut, "How can I do two-phase commit in REST?"

      Or is your need for toggle behavior truly needed in some other actual domain? If so, could you please tell us a bit more about the domain and it's REAL need for toggle behavior. With such context in mind, we can perhaps help you better map it into a RESTful API.


      -- Nick

      Nick Gall
      Phone: +1.781.325.8370
      Other Contact Info: http://bit.ly/nickgall

      On Tue, Jul 8, 2014 at 5:28 PM, 'Simpson, Robby (GE Energy Management)' robby.simpson@...<mailto:robby.simpson@...> [rest-discuss] <rest-discuss-noreply@yahoogroups.com<mailto:rest-discuss-noreply@yahoogroups.com>> wrote:

      I've been scratching my head over this one for a while and am hoping I can
      get some help.

      Imagine a light switch with one simple resource: /state , where state can
      be "On" or "Off."

      One can PUT to /state , changing /state to either "On" or "Off."
      Similarly, a GET to /state will tell you if the light is currently "On" or

      Where I'm struggling is with a safe "Toggle" mechanism. That is, if
      /state is "On", change it to "Off" and vice versa.

      I understand that one solution would be to simply perform a GET on /state
      and then PUT the opposite. However, I am concerned with both the overhead
      and latency this entails as well as the potential for a race condition
      (what if /state changes between the GET and the PUT?).

      Any solution I've looked at thus far seems to violate RESTful principles,
      particularly regarding idempotency. In short, can one safely toggle?

      Any suggestions?


      Posted by: "Simpson, Robby (GE Energy Management)" <robby.simpson@...<mailto:robby.simpson@...>>


      Yahoo Groups Links
    • Show all 36 messages in this topic