diff --git a/app/client/state.html b/app/client/state.html
index 4ce0ca9..80c7664 100644
--- a/app/client/state.html
+++ b/app/client/state.html
@@ -5,7 +5,7 @@
{{controller_id}}:
- {{#with last_sensor_reading}} {{ temperatureValue }} °C, {{ humidityValue }} % {{/with}}
+ {{#with last_sensor_reading}} temp: {{ temperatureValue }} °C, vlaga: {{ humidityValue }} %
nivo vode: {{water_level}} {{/with}}
Automatsko zalijevanje:
{{ pretty_days config.automaticDaysOfWeek }} {{ pretty_time config.automaticDaysOfWeek config.automaticTimeOfDay }}
diff --git a/app/client/state.js b/app/client/state.js
index 17bbd67..835f7c6 100644
--- a/app/client/state.js
+++ b/app/client/state.js
@@ -69,6 +69,18 @@ Template.state.helpers({
last_sensor_reading: last_sensor_reading,
+ water_level: function() {
+ var sensor = last_sensor_reading();
+ if (sensor) {
+ if (parseInt(sensor.tankFull) === 1) return '100 %';
+ else if (parseInt(sensor.tankLevel4) === 1) return '80 %';
+ else if (parseInt(sensor.tankLevel3) === 1) return '60 %';
+ else if (parseInt(sensor.tankLevel2) === 1) return '40 %';
+ else if (parseInt(sensor.tankLevel1) === 1) return '20 %';
+ else '0 %'
+ }
+ },
+
water_now_button_class: function() {
var stateObject = controller_state();
if (stateObject.state && (stateObject.state.out_valve === 'open' || stateObject.state.out_valve === 'opening')) {
diff --git a/controller/sensors.py b/controller/sensors.py
index 9bfa85e..9c8ff9d 100644
--- a/controller/sensors.py
+++ b/controller/sensors.py
@@ -49,7 +49,7 @@ humidity, temperature = Adafruit_DHT.read_retry(SENSOR_TYPE, config.GPIO_PIN_DHT
# the results will be null (because Linux can't
# guarantee the timing of calls to read the sensor).
# If this happens try again!
-if temperature is not None and humidity is not None:
+if tankFull is not None:
response = requests.post(config.SENSORDATA_URL, json={"owner": owner, "temperatureValue": temperature, "humidityValue":humidity, "tankLevel0": "1" if tankLevel0 else "0","tankLevel1": "1" if tankLevel1 else "0","tankLevel2": "1" if tankLevel2 else "0","tankLevel3": "1" if tankLevel3 else "0", "tankLevel4": "1" if tankLevel4 else "0", "tankFull": "1" if tankFull else "0",
"startPumpingAt": startPumpingAt,"stopPumpingAt": stopPumpingAt,"controllerId": controller_id
})