Example #1
0
class Plug:
    exposed = True
     
    def __init__(self):
      self.states = [
          1,
          0
      ]
      self.elro = Elro();
    
    
    @jsonify
    def GET(self, id=-1):
        return self.states
    
    @jsonify
    def POST(self, body):
        id = int(body["id"]);
        newState = bool(body["switchOn"]);
        #newState= (self.states[id] -1) * -1;
        print("switching plug " + str(id+1) + " to state " + str(newState));
        self.elro.switch(id, newState);
        self.states[id] = newState;
        return newState
Example #2
0
 def __init__(self):
   self.states = [
       1,
       0
   ]
   self.elro = Elro();