<project version="4">
<component name="ChangeListManager">
<list default="true" id="352ce63a-b52a-41a2-979b-becda7920939" name="Default" comment=".">
+ <change afterPath="$PROJECT_DIR$/scripts/weather.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/config/rooms.php" beforeDir="false" afterPath="$PROJECT_DIR$/config/rooms.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/scripts/cron/cron.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/cron/cron.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/scripts/lib/domoticz.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/domoticz.php" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/scripts/lib/lib.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/lib.php" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/scripts/lib/scenes.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/scenes.php" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/scripts/lib/flowerpower.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/flowerpower.php" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/scripts/lib/weatherstation.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/weatherstation.php" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<workItem from="1643960682357" duration="593000" />
<workItem from="1644143547964" duration="594000" />
<workItem from="1644673539378" duration="1825000" />
- <workItem from="1644683361342" duration="3044000" />
- </task>
- <task id="LOCAL-00467" summary=".">
- <created>1618342660944</created>
- <option name="number" value="00467" />
- <option name="presentableId" value="LOCAL-00467" />
- <option name="project" value="LOCAL" />
- <updated>1618342660944</updated>
+ <workItem from="1644683361342" duration="8803000" />
</task>
<task id="LOCAL-00468" summary=".">
<created>1618426951296</created>
<option name="project" value="LOCAL" />
<updated>1642950622190</updated>
</task>
- <option name="localTasksCounter" value="516" />
+ <task id="LOCAL-00516" summary=".">
+ <created>1644750402613</created>
+ <option name="number" value="00516" />
+ <option name="presentableId" value="LOCAL-00516" />
+ <option name="project" value="LOCAL" />
+ <updated>1644750402613</updated>
+ </task>
+ <option name="localTasksCounter" value="517" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
function cronWeather($cronmin)
{
_logSection('Weather');
- $place = 2608449;
- $apikey = 'fM7z3yrWwnUuXuAPPYIM5EqTl2iBAGB6';
-
- $cache = ROOT . '/cache/accuweather.json';
- $limit = max(time() - 3600, 0);
-
- if (!file_exists($cache) || filemtime($cache) < $limit) {
- copy('http://dataservice.accuweather.com/currentconditions/v1/' . $place . '?apikey=' . $apikey . '&language=fr-FR&details=true', $cache);
- }
-
- $res = [];
- $weather = json_decode(file_get_contents($cache), true);
- $weather = $weather[0];
- $res['temp'] = round(($weather['Temperature']['Metric']['Value']/* + getState('airtemperature')*/));
- $res['outdoor_temp'] = toNumber(getDomoticzDeviceStatus(1467), 1);
- $res['outdoor_humidity'] = toNumber(getDomoticzDeviceStatus(1026), true);
- $res['outdoor_pressure'] = toNumber(getDomoticzDeviceStatus(1027), true);
- $res['backyard_temp'] = toNumber(getDomoticzDeviceStatus(1354), 1);
- $res['backyard_humidity'] = toNumber(getDomoticzDeviceStatus(1357), true);
- $res['backyard_pressure'] = toNumber(getDomoticzDeviceStatus(1358), true);
- $res['bathroom_temp'] = toNumber(getDomoticzDeviceStatus(1346), 1);
- $res['bathroom_humidity'] = toNumber(getDomoticzDeviceStatus(1347), true);
- $res['bedroom_temp'] = toNumber(getDomoticzDeviceStatus(6851), 1);
- $res['bedroom_humidity'] = toNumber(getDomoticzDeviceStatus(6852), true);
- $res['bedroom_airquality'] = toNumber(getDomoticzDeviceStatus(6853), true);
- $res['livingroom_temp'] = toNumber(getDomoticzDeviceStatus(6453), 1);
- $res['livingroom_humidity'] = toNumber(getDomoticzDeviceStatus(6454), true);
- $res['kitchen_temp'] = toNumber(getDomoticzDeviceStatus(1506), 1);
- $res['kitchen_humidity'] = toNumber(getDomoticzDeviceStatus(1507), true);
- $res['wc_temp'] = toNumber(getDomoticzDeviceStatus(1501), 1);
- $res['wc_humidity'] = toNumber(getDomoticzDeviceStatus(1502), true);
- $res['office_temp'] = toNumber(getDomoticzDeviceStatus(1496), 1);
- $res['office_humidity'] = toNumber(getDomoticzDeviceStatus(1497), true);
- $res['cellar_humidity'] = toNumber(getDomoticzDeviceStatus(4818), true);
- $res['cellar_temp'] = toNumber(getDomoticzDeviceStatus(4817), 1);
- $res['pressure'] = round($weather['Pressure']['Metric']['Value']);
- $res['pressureTendency'] = $weather['PressureTendency']['Code'];
- $res['precipitations24'] = round($weather['PrecipitationSummary']['Past24Hours']['Metric']['Value']);
- $res['cloudCover'] = $weather['CloudCover'];
- $res['ceiling'] = $weather['Ceiling']['Imperial']['Value'];
- $res['icon'] = $weather['WeatherIcon'];
- if ($res['icon'] < 10) {
- $res['icon'] = '0' . $res['icon'];
- }
-
- $cache = ROOT . '/cache/accuforecasts.json';
- if (!file_exists($cache) || filemtime($cache) < $limit) {
- copy('http://dataservice.accuweather.com/forecasts/v1/daily/5day/' . $place . '?apikey=' . $apikey . '&language=fr-FR&metric=true&details=true', $cache);
- }
- $forecasts = json_decode(file_get_contents($cache), true);
- $f = $forecasts['DailyForecasts'][0];
- $res['dayIcon'] = $f['Day']['Icon'];
-
- if ($res['dayIcon'] < 10) {
- $res['dayIcon'] = '0' . $res['dayIcon'];
- }
- $res['nightIcon'] = $f['Night']['Icon'];
- if ($res['nightIcon'] < 10) {
- $res['nightIcon'] = '0' . $res['nightIcon'];
- }
- $res['min'] = round($f['Temperature']['Minimum']['Value']);
- $res['max'] = round($f['Temperature']['Maximum']['Value']);
-
- $res['sunrise'] = $f['Sun']['EpochRise'];
- $res['sunset'] = $f['Sun']['EpochSet'];
- $res['moon'] = $f['Moon']['Phase'];
- $res['moonage'] = $f['Moon']['Age'];
- $res['moonrise'] = $f['Moon']['EpochRise'];
- $res['moonset'] = $f['Moon']['EpochSet'];
-
- $res['forecasts'] = [];
- $days = ['D', 'L', 'M', 'M', 'J', 'V', 'S'];
- for ($i = 1; $i <= 4; $i++) {
- $j = $i - 1;
- $res['forecasts'][$j] = [];
- $f = $forecasts['DailyForecasts'][$i];
- $res['forecasts'][$j]['dayIcon'] = $f['Day']['Icon'];
-
- if ($res['forecasts'][$j]['dayIcon'] < 10) {
- $res['forecasts'][$j]['dayIcon'] = '0' . $res['forecasts'][$j]['dayIcon'];
- }
- $res['forecasts'][$j]['nightIcon'] = $f['Night']['Icon'];
- if ($res['forecasts'][$j]['nightIcon'] < 10) {
- $res['forecasts'][$j]['nightIcon'] = '0' . $res['forecasts'][$j]['nightIcon'];
- }
- $res['forecasts'][$j]['min'] = round($f['Temperature']['Minimum']['Value']);
- $res['forecasts'][$j]['max'] = round($f['Temperature']['Maximum']['Value']);
- $res['forecasts'][$j]['day'] = $days[date('w', $f['EpochDate'])];
- }
-
- file_put_contents(ROOT . '/cache/weather.json', json_encode($res));
+ getWeather();
}
function cronVelib($cronmin)
//echo ':)';
$res = runDomoticzCommand(['type' => 'devices', 'rid' => $device]);
$res = json_decode($res->getBody(), true);
+ if(null===$res || !isset($res['result']) || !count($res['result'])){
+ echo 'Error getting status of device '.$device."\n".print_r($res,true);
+ return null;
+ }
try {
+
$update = new DateTime($res['result'][0]['LastUpdate']);
$now = new DateTime();
if (!$force && $update->diff($now)->days > 0) {
<?php
function updateFlowerPower()
{
- $device = getState('device_salon_awake') ? 'salon' : 'bureausun';
+ $devices = getState('device_salon_awake') ? ['bureausun', 'salon'] : ['bureausun'];
+ shuffle($devices);
+ $device = array_pop($devices);
$res = sshRunCommand('timeout -k 10 1m /usr/local/bin/flowerpower', $device, true, true);
$fp = explode("\n", $res['output']);
$map = [1 => 1467, 0 => 1468];
<?php
+
+function getWeather()
+{
+ $place = 623;
+ $apikey = 'fM7z3yrWwnUuXuAPPYIM5EqTl2iBAGB6';
+
+ $cache = ROOT . '/cache/accuweather.json';
+ $limit = max(time() - 3600, 0);
+
+ if (!file_exists($cache) || filemtime($cache) < $limit) {
+ copy('http://dataservice.accuweather.com/currentconditions/v1/' . $place . '?apikey=' . $apikey . '&language=fr-FR&details=true', $cache);
+ }
+
+ $res = [];
+ $weather = json_decode(file_get_contents($cache), true);
+ $weather = $weather[0];
+ $res['temp'] = round(($weather['Temperature']['Metric']['Value']/* + getState('airtemperature')*/));
+ $res['outdoor_temp'] = toNumber(getDomoticzDeviceStatus(1467), 1);
+ $res['outdoor_humidity'] = toNumber($weather['RelativeHumidity'], true);
+ $res['outdoor_pressure'] = toNumber(getDomoticzDeviceStatus(1358), true);
+ $res['backyard_temp'] = toNumber(getDomoticzDeviceStatus(1354), 1);
+ $res['backyard_humidity'] = toNumber(getDomoticzDeviceStatus(1357), true);
+ $res['backyard_pressure'] = toNumber(getDomoticzDeviceStatus(1358), true);
+ $res['bathroom_temp'] = toNumber(getDomoticzDeviceStatus(1346), 1);
+ $res['bathroom_humidity'] = toNumber(getDomoticzDeviceStatus(1347), true);
+ $res['bedroom_temp'] = toNumber(getDomoticzDeviceStatus(6851), 1);
+ $res['bedroom_humidity'] = toNumber(getDomoticzDeviceStatus(6852), true);
+ $res['bedroom_airquality'] = toNumber(getDomoticzDeviceStatus(6853), true);
+ $res['livingroom_temp'] = toNumber(getDomoticzDeviceStatus(6453), 1);
+ $res['livingroom_humidity'] = toNumber(getDomoticzDeviceStatus(6454), true);
+ $res['kitchen_temp'] = toNumber(getDomoticzDeviceStatus(1506), 1);
+ $res['kitchen_humidity'] = toNumber(getDomoticzDeviceStatus(1507), true);
+ $res['wc_temp'] = toNumber(getDomoticzDeviceStatus(1501), 1);
+ $res['wc_humidity'] = toNumber(getDomoticzDeviceStatus(1502), true);
+ $res['office_temp'] = toNumber(getDomoticzDeviceStatus(1496), 1);
+ $res['office_humidity'] = toNumber(getDomoticzDeviceStatus(1497), true);
+ $res['cellar_humidity'] = toNumber(getDomoticzDeviceStatus(4818), true);
+ $res['cellar_temp'] = toNumber(getDomoticzDeviceStatus(4817), 1);
+ $res['pressure'] = round($weather['Pressure']['Metric']['Value']);
+ $res['pressureTendency'] = $weather['PressureTendency']['Code'];
+ $res['precipitations24'] = round($weather['PrecipitationSummary']['Past24Hours']['Metric']['Value']);
+ $res['cloudCover'] = $weather['CloudCover'];
+ $res['ceiling'] = $weather['Ceiling']['Imperial']['Value'];
+ $res['icon'] = $weather['WeatherIcon'];
+ if ($res['icon'] < 10) {
+ $res['icon'] = '0' . $res['icon'];
+ }
+
+ $cache = ROOT . '/cache/accuforecasts.json';
+ if (!file_exists($cache) || filemtime($cache) < $limit) {
+ copy('http://dataservice.accuweather.com/forecasts/v1/daily/5day/' . $place . '?apikey=' . $apikey . '&language=fr-FR&metric=true&details=true', $cache);
+ }
+ $forecasts = json_decode(file_get_contents($cache), true);
+ $f = $forecasts['DailyForecasts'][0];
+ $res['dayIcon'] = $f['Day']['Icon'];
+
+ if ($res['dayIcon'] < 10) {
+ $res['dayIcon'] = '0' . $res['dayIcon'];
+ }
+ $res['nightIcon'] = $f['Night']['Icon'];
+ if ($res['nightIcon'] < 10) {
+ $res['nightIcon'] = '0' . $res['nightIcon'];
+ }
+ $res['min'] = round($f['Temperature']['Minimum']['Value']);
+ $res['max'] = round($f['Temperature']['Maximum']['Value']);
+
+ $res['sunrise'] = $f['Sun']['EpochRise'];
+ $res['sunset'] = $f['Sun']['EpochSet'];
+ $res['moon'] = $f['Moon']['Phase'];
+ $res['moonage'] = $f['Moon']['Age'];
+ $res['moonrise'] = $f['Moon']['EpochRise'];
+ $res['moonset'] = $f['Moon']['EpochSet'];
+
+ $res['forecasts'] = [];
+ $days = ['D', 'L', 'M', 'M', 'J', 'V', 'S'];
+ for ($i = 1; $i <= 4; $i++) {
+ $j = $i - 1;
+ $res['forecasts'][$j] = [];
+ $f = $forecasts['DailyForecasts'][$i];
+ $res['forecasts'][$j]['dayIcon'] = $f['Day']['Icon'];
+
+ if ($res['forecasts'][$j]['dayIcon'] < 10) {
+ $res['forecasts'][$j]['dayIcon'] = '0' . $res['forecasts'][$j]['dayIcon'];
+ }
+ $res['forecasts'][$j]['nightIcon'] = $f['Night']['Icon'];
+ if ($res['forecasts'][$j]['nightIcon'] < 10) {
+ $res['forecasts'][$j]['nightIcon'] = '0' . $res['forecasts'][$j]['nightIcon'];
+ }
+ $res['forecasts'][$j]['min'] = round($f['Temperature']['Minimum']['Value']);
+ $res['forecasts'][$j]['max'] = round($f['Temperature']['Maximum']['Value']);
+ $res['forecasts'][$j]['day'] = $days[date('w', $f['EpochDate'])];
+ }
+
+ file_put_contents(ROOT . '/cache/weather.json', json_encode($res));
+ return $res;
+}
+
function weatherStationScreenSaver()
{
$weather = json_decode(file_get_contents(ROOT . '/cache/weather.json'), true);
--- /dev/null
+<?php
+include "import.php";
+header('Content-type: text/plain');
+print_r(json_decode(file_get_contents(ROOT . '/cache/accuweather.json')));
+print_r(json_decode(file_get_contents(ROOT . '/cache/accuforecasts.json')));
+print_r(getWeather());