Open Raftanel opened 1 year ago
Hello, I never used Github, I don't know how to propose new content. Thank you for your simple API.
I added 2 new function to splNetatmoAPI.php, it's mostly copy&paste but it can spare a few Minutes to someone:
public function getWeatherHumidity() { if (is_null($this->_weatherDatas)) $this->getWeatherDatas(); $modules = $this->_weatherDatas['body']['devices'][0]['modules']; $jsonDatas = array(); foreach ($modules as $module) { if (!isset($module['dashboard_data']['Humidity'])) continue; $name = $module['module_name']; $humidity = $module['dashboard_data']['Humidity']; $jsonDatas[$name] = $humidity; } //add main station: $jsonDatas[ $this->_weatherDatas['body']['devices'][0]['station_name'] ] = $this->_weatherDatas['body']['devices'][0]['dashboard_data']['Humidity']; return $jsonDatas; } public function getWeatherCO2() { if (is_null($this->_weatherDatas)) $this->getWeatherDatas(); $modules = $this->_weatherDatas['body']['devices'][0]['modules']; $jsonDatas = array(); foreach ($modules as $module) { if (!isset($module['dashboard_data']['CO2'])) continue; $name = $module['module_name']; $co2 = $module['dashboard_data']['CO2']; $jsonDatas[$name] = $co2; } //add main station: $jsonDatas[ $this->_weatherDatas['body']['devices'][0]['station_name'] ] = $this->_weatherDatas['body']['devices'][0]['dashboard_data']['CO2']; return $jsonDatas; }
and you can use it easily with:
$getWeatherHumudity = $_splNetatmo->getWeatherHumidity(); echo "Humidity:".str_replace('"','',json_encode($getWeatherHumudity, JSON_PRETTY_PRINT)); $getWeatherCO2 = $_splNetatmo->getWeatherCO2(); echo "CO2:".str_replace('"','',json_encode($getWeatherCO2, JSON_PRETTY_PRINT));
Hello, and for the Pressure? Do you know how we can have it, please?
Hello, I never used Github, I don't know how to propose new content. Thank you for your simple API.
I added 2 new function to splNetatmoAPI.php, it's mostly copy&paste but it can spare a few Minutes to someone:
and you can use it easily with: