Added verification when sensors are offline

This commit is contained in:
Luis Aleixo 2022-09-22 10:39:30 +02:00
parent b487f5272f
commit ba956bc045
2 changed files with 9 additions and 1 deletions

View file

@ -315,8 +315,15 @@ function show_sensors_data(url) {
if (result.length == 0) return; // If the ARVE credentials were not defined, we don't have a valid result.
DATA_FROM_SENSORS = result;
result.map(room => {
if (room['Details']['Online'] == false) return; // If the sensor is offline, it should not be added to the list.
$("#sensors").append(`<option id=${room.RoomId} value=${room.RoomId}>Sensor ${room.RoomId}</option>`);
});
if ($('#sensors > option').length == 0) {
$('#offline_sensors').show();
$('#DIVsensors_data').hide();
$('#arve_sensor_yes').prop('disabled', true)
return; // All sensors are offline
}
populate_temp_hum_values(result, 0);
if (url.searchParams.has('sensor_in_use')) {
$("#sensors").val(url.searchParams.get('sensor_in_use'));

View file

@ -14,7 +14,8 @@
<label for="arve_sensor_yes">Yes</label>
</div>
</div>
<div id="DIVsensors_data" style="display:none">
<p id="offline_sensors" class="red_text mb-2" style="display: none">All sensors are offline.</p>
<div id="DIVsensors_data" class="mb-1" style="display:none">
<div class="form-group row mb-0">
<div class="col-sm-4"><label class="col-form-label">Sensor:</label></div>
<div class="col-sm-6">