def sprinkler(actionName=""): if (isAuthNeed() == False): sprinkler = SprinklerClass.SprinklerClass() if len(actionName) == 0: return render_template( 'sprinkler.html', sprinklerElements=sprinkler.getSprinklerItems()) else: action = ActionClass.ActionClass() sprinklerName = request.args.get('param') action.performAction(actionName, sprinklerName) return render_template('events.html', events=action.getEvents( action.ActionEventGeneric))
def APIgetGardenSettings(self, json_req): obj = SprinklerClass.SprinklerClass() response = obj.getSettings() return json.dumps(response)
def restApi(): req = {} crypt = CryptClass.CryptClass() postData = crypt.Decode(request.data) postData = postData[:postData.rfind("}") + 1] req = json.loads(postData) if (req['action'] == "temperature"): obj = HeaterClass.HeaterClass() response = obj.getCurrentTemperatureInside() r = json.dumps(response) w = crypt.Encode(r) return w elif (req['action'] == "version"): response = {} response['name'] = "Home Control Center" response['version'] = "1.0" r = json.dumps(response) w = crypt.Encode(r) return w elif (req['action'] == "getMediaChannels"): obj = RadioClass.RadioClass() response = {} response = obj.getPVRStations() r = json.dumps(response) w = crypt.Encode(r) return w elif (req['action'] == "info"): infoObj = InfoClass.InfoClass() response = infoObj.getInfoData() r = json.dumps(response) w = crypt.Encode(r) return w elif (req['action'] == "weather"): obj = WeatherClass.WeatherClass() response = obj.getCurrentWeather() r = json.dumps(response) w = crypt.Encode(r) return w elif (req['action'] == "schedule"): obj = ScheduleClass.ScheduleClass() response = {} response['DirectionA'] = obj.getJsonFromKoleo('A', 0) response['DirectionB'] = obj.getJsonFromKoleo('B', 0) r = json.dumps(response) w = crypt.Encode(r) return w elif (req['action'] == "heaterCharts"): obj = HeaterClass.HeaterClass() response = {} response = obj.getCharts() r = json.dumps(response) w = crypt.Encode(r) return w elif (req['action'] == "getGardenSettings"): obj = SprinklerClass.SprinklerClass() response = {} response = obj.getSettings() r = json.dumps(response) w = crypt.Encode(r) return w elif (req['action'] == "playMediaChannel"): obj = RadioClass.RadioClass() response = {} response = obj.playPVRChannel(param) r = json.dumps(response) w = crypt.Encode(r) return w elif (req['action'] == "toggleCec"): obj = RadioClass.RadioClass() response = {} response = obj.toggleCEC() r = json.dumps(response) w = crypt.Encode(r) return w elif (req['action'] == "setGardenSettings"): response = {} config = ConfigClass.ConfigClass() config.saveSettingsData(2, req) response['state'] = "OK" r = json.dumps(response) w = crypt.Encode(r) return w elif (req['action'] == "setHeaterSettings"): response = {} config = ConfigClass.ConfigClass() config.saveSettingsData(1, req) response['state'] = "OK" r = json.dumps(response) w = crypt.Encode(r) return w elif (req['action'] == "setAlarmSettings"): response = {} config = ConfigClass.ConfigClass() config.saveSettingsData(0, req) response['state'] = "OK" r = json.dumps(response) w = crypt.Encode(r) return w else: duration = 0 param = "" if (req['action'] <> "events"): if (req['action'] == "VolumeSet"): param = req['volume'] if (req['action'] == "PlayPVR"): param = req['channel'] if (req['action'] == "SprinklerOn"): param = str(req['id']) if (req['action'] == "Gate"): param = str(req['id']) action = ActionClass.ActionClass() duration = action.performAction(req['action'], param) obj = ActionClass.ActionClass() events = obj.getEvents() response = {} resEvents = [] for event in events: row = {} row['eventType'] = event.id row['eventDesc'] = event.desc row['eventIcon'] = event.icon row['eventDate'] = event.date resEvents.append(row) response['events'] = resEvents response['eventDuration'] = duration r = json.dumps(response) w = crypt.Encode(r) return w
def __init__(self): self.__sprinkler = SprinklerClass.SprinklerClass() self.__config = ConfigClass.ConfigClass()
def actionOnSprinklerForceAuto(self, param=''): sprinkler = SprinklerClass.SprinklerClass() sprinkler.setSprinklerForceAuto() return 5
def actionOnSprinklerOff(self, param=''): sprinkler = SprinklerClass.SprinklerClass() sprinkler.setSprinklerOff() return 0