Last active
February 8, 2018 01:55
-
-
Save ProxiBlue/e797f00735fbf0a06ddb55e837b9140a to your computer and use it in GitHub Desktop.
Record sensibo pod temperature. added in calculation for Feel like as used by sensibo Climate React and different Apparent calculation to allow comparisons
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$fp = fopen('/tmp/temp_monitor.csv', 'a'); | |
$curl = curl_init('https://home.sensibo.com/api/v2/pods/jFFZuNq6/measurements?apiKey=MxeORFfanBUJnCbd3HLmssEYJF2WbO'); | |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); | |
$curl_response = curl_exec($curl); | |
if ($curl_response === false) { | |
$info = curl_getinfo($curl); | |
curl_close($curl); | |
die('error occurred during curl exec. Additional info: ' . var_export($info)); | |
} | |
curl_close($curl); | |
$decoded = json_decode($curl_response); | |
if (isset($decoded->status) && $decoded->status == 'success') { | |
$temperature = $decoded->result[0]->temperature; | |
$humidity = $decoded->result[0]->humidity; | |
$vhumidity = $humidity / 100 * 6.105 * exp(17.27 * $temperature / (237.7 + $temperature)); | |
$apparent = round($temperature + 0.33 * $vhumidity - 0.70 * 0 - 4.00, 1); | |
$feelslike = -42.379 + 2.04901523*$temperature + 10.14333127*$humidity - .22475541*$temperature*$humidity - .00683783*$temperature*$temperature - .05481717*$humidity*$humidity + .00122874*$temperature*$temperature*$humidity + .00085282*$temperature*$humidity*$humidity - .00000199*$temperature*$temperature*$humidity*$humidity; | |
$dt = date('m/d/Y h:i:s a', time()); | |
fputcsv($fp, array($dt, $temperature, $humidity, $vhumidity, $feelslike, $apparent)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment