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)) {