temp humidity optional, water level printing #24
@@ -5,7 +5,7 @@
|
||||
<img src="{{ bucket_image }}" class="img-responsive center-block" id="bucket_image" />
|
||||
<div class="text-center">
|
||||
{{controller_id}}:
|
||||
{{#with last_sensor_reading}} <strong> {{ temperatureValue }} °C, {{ humidityValue }} % </strong> {{/with}}
|
||||
{{#with last_sensor_reading}} <strong> temp: {{ temperatureValue }} °C, vlaga: {{ humidityValue }} % <br/>nivo vode: {{water_level}} </strong> {{/with}}
|
||||
</div>
|
||||
<div class="text-center">
|
||||
Automatsko zalijevanje:<br /> <strong>{{ pretty_days config.automaticDaysOfWeek }} {{ pretty_time config.automaticDaysOfWeek config.automaticTimeOfDay }}</strong> <button id="run_settings" class="btn btn-default"> <i class="fa fa-wrench"></i> </button>
|
||||
|
||||
@@ -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')) {
|
||||
|
||||
@@ -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
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user