From 4ce133e404a5dfd80d8a895a29d731106b9175d6 Mon Sep 17 00:00:00 2001 From: rsgrinko Date: Wed, 22 Dec 2021 21:39:10 +0300 Subject: [PATCH] =?UTF-8?q?[*]=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=20=D1=87=D0=B5?= =?UTF-8?q?=D0=BB=D0=BE=D0=B2=D0=B5=D0=BA=D0=BE=D0=BF=D0=BE=D0=BD=D1=8F?= =?UTF-8?q?=D1=82=D0=BD=D0=BE=D0=B3=D0=BE=20=D0=BD=D0=B0=D0=B7=D0=B2=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F=20=D0=B4=D0=B0=D1=82=D1=87=D0=B8=D0=BA=D0=BE?= =?UTF-8?q?=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/lib/CIoT.class.php | 26 +++++++++++++++++++++++++- index.php | 20 +++----------------- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/inc/lib/CIoT.class.php b/inc/lib/CIoT.class.php index d937caa..d50e564 100644 --- a/inc/lib/CIoT.class.php +++ b/inc/lib/CIoT.class.php @@ -210,7 +210,7 @@ class CIoT { } /** - * Получаем показания со всех 10 датчиков DS18B20 + * Получаем показания со всех 10 датчиков * * @param $deviceId * @return array @@ -259,6 +259,30 @@ class CIoT { } } + /** + * Получение человеческого имени по типу датчика + * + * @param $sensor + * @return string[] + */ + public static function getHumanSensorName($sensor):array { + $result = []; + + if (stristr($sensor, 'dht_h')) { + $result = ['name' => 'Датчик влажности', 'unit' => '%', 'icon' => 'fa fa-flask']; + } elseif (stristr($sensor, 'dht_t')) { + $result = ['name' => 'Датчик температуры', 'unit' => '%', 'icon' => 'ion-thermometer']; + } elseif (stristr($sensor, 'ds')) { + $result = ['name' => 'Датчик температуры', 'unit' => 'C', 'icon' => 'ion-thermometer']; + } elseif (stristr($sensor, 'analog')) { + $result = ['name' => 'Аналоговый датчик', 'unit' => 'ед.', 'icon' => 'fa fa-bar-chart']; + } else { + $result = ['name' => 'Датчик', 'unit' => 'ед. ', 'icon' => 'ion-thermometer']; + } + + return $result; + } + /** * Задать выбранное устройство * diff --git a/index.php b/index.php index 475373a..f79dc00 100644 --- a/index.php +++ b/index.php @@ -30,17 +30,9 @@ if(CCache::check($cacheId)) {
-

- - Датчик - - Датчик ANALOG +

+

-