-
-
Save jezinka/d3c2a8853ab4ac3ab538fc7e293604ce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RequestMapping(value = "/data.json", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) | |
@ResponseBody | |
JSONObject home() { | |
def data = ["hum_temp": "Temperatura (\u00b0C)", "hum_hum": "Wilgotno\u015b\u0107 (%)", "bar_pres_rel": "Ci\u015bnienie (hPa)", "lux": "Jasno\u015b\u0107 (lx)", "vbat": "Nap. baterii (V)", "vreg": "Nap. sensor\u00f3w (V)"] | |
def sensors = [:] | |
def readings = [:] | |
['Balkon', 'Salon', 'Biuro', 'Łazienka', 'Sypialnia', 'Piwnica'].eachWithIndex { String room, int idx -> | |
sensors << [(idx): ["label": room, "data": ["hum_temp", "hum_hum", "lux", "vbat", "vreg"]]] | |
readings << [(idx): ["id" : randomId, "stamp": timeStamp, "sensor_id": idx, "seq": randomId, "status": 0, | |
"flags" : randomId, "bar_temp": randomTemp, "bar_pres_abs": randomBarPress, | |
"bar_pres_rel": randomBarPress, "lux": randomLux, "hum_temp": randomTemp, | |
"hum_hum" : randomHumHum, "vbat": randomVBat, "vreg": randomVReg]] | |
} | |
["sensors": sensors, "readings": readings, "data": data] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment