<project version="4">
<component name="ChangeListManager">
<list default="true" id="352ce63a-b52a-41a2-979b-becda7920939" name="Default" comment=".">
+ <change afterPath="$PROJECT_DIR$/scripts/domoticz_status.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/js/home.js" beforeDir="false" afterPath="$PROJECT_DIR$/js/home.js" 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/domoticz_device_event.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/domoticz_device_event.php" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/scripts/lib/mediarasp.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/mediarasp.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/weatherstation.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/weatherstation.php" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<workItem from="1573629043706" duration="29000" />
<workItem from="1573629088225" duration="3531000" />
<workItem from="1574065436563" duration="754000" />
- <workItem from="1574066213679" duration="3460000" />
- </task>
- <task id="LOCAL-00195" summary=".">
- <created>1562739863351</created>
- <option name="number" value="00195" />
- <option name="presentableId" value="LOCAL-00195" />
- <option name="project" value="LOCAL" />
- <updated>1562739863351</updated>
+ <workItem from="1574066213679" duration="7326000" />
</task>
<task id="LOCAL-00196" summary=".">
<created>1562740088238</created>
<option name="project" value="LOCAL" />
<updated>1574066196695</updated>
</task>
- <option name="localTasksCounter" value="244" />
+ <task id="LOCAL-00244" summary=".">
+ <created>1574210671610</created>
+ <option name="number" value="00244" />
+ <option name="presentableId" value="LOCAL-00244" />
+ <option name="project" value="LOCAL" />
+ <updated>1574210671610</updated>
+ </task>
+ <option name="localTasksCounter" value="245" />
<servers />
</component>
<component name="TodoView">
w.find('.icon-day').html('<img src="https://vortex.accuweather.com/adc2010/images/slate/icons/' + data.dayIcon + '.svg" width="100" height="100" />');
w.find('.icon-night').html('<img src="https://vortex.accuweather.com/adc2010/images/slate/icons/' + data.nightIcon + '.svg" width="100" height="100" />');
w.find('.temp-max').text(data.max + '°C');
- w.find('.temp').text(data.temp + '°C');
+ w.find('.temp').text(data.outdoor_temp + '°C');
w.attr('data-init', 1);
resize();
});
if ($cronmin % 5 == 0) {
cronTraffic($cronmin, false);
cronVelib($cronmin);
+ cronWeather($cronmin);
cronBackyard($cronmin);
}
if ($cronmin % 10 == 0) {
- cronWeather($cronmin);
cronSqueezeFavorites($cronmin);
}
}
}
-function cronWeather($cronmin)
+function toNumber($val, $round = false)
{
+ $val = preg_replace('/[^0-9-.]/', '', $val);
+ $val = floatval($val);
+ if ($round) {
+ $val = round($val);
+ }
+ return $val;
+}
+function cronWeather($cronmin)
+{
$place = 2608449;
$cache = ROOT . '/cache/accuweather.json';
$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(12, 'zigate'),true);
+ $res['outdoor_humidity'] = toNumber(getDomoticzDeviceStatus(13, 'zigate'),true);
+ $res['outdoor_pressure'] = toNumber(getDomoticzDeviceStatus(14, 'zigate'),true);
+ $res['backyard_temp'] = toNumber(getDomoticzDeviceStatus(5, 'zigate'),true);
+ $res['backyard_humidity'] = toNumber(getDomoticzDeviceStatus(6, 'zigate'),true);
$res['pressure'] = round($weather['Pressure']['Metric']['Value']);
$res['pressureTendency'] = $weather['PressureTendency']['Code'];
$res['precipitations24'] = round($weather['PrecipitationSummary']['Past24Hours']['Metric']['Value']);
--- /dev/null
+<?php
+require_once "import.php";
+
+print_r(getDomoticzDeviceStatus($_GET['device'],$_GET['hardware']));
\ No newline at end of file
<?php
-function runDomoticzCommand($params)
+function runDomoticzCommand($params, $hardware = 'rflink')
{
$default = ['type' => 'command', 'passcode' => ''];
$params = array_merge($default, $params);
- return httpRequest('http://192.168.13.60:8084/json.htm', 'GET', $params);
+ if ($params['hardware'] == 'rflink') {
+ $ip = '192.168.13.60';
+ } else if ($params['hardware'] == 'zigate') {
+ $ip = '192.168.13.68';
+ }
+ unset($params['hardware']);
+
+ return httpRequest('http://' . $ip . ':8084/json.htm', 'GET', $params);
}
-function domoticzSwitch($device, $cmd, $type = 'light', $priority = false)
+function domoticzSwitch($device, $cmd, $type = 'light', $priority = false, $hardware = 'rflink')
{
- return domoticzCmd(['idx' => $device, 'switchcmd' => $cmd ? 'On' : 'Off', 'param' => 'switch' . $type, 'level' => '0'], $priority);
+ return domoticzCmd(['idx' => $device, 'switchcmd' => $cmd ? 'On' : 'Off', 'param' => 'switch' . $type, 'level' => '0', 'hardware' => $hardware], $priority);
}
function domoticzCmd($command, $priority = false)
if (!is_array($queue)) {
$queue = [];
}
- if($priority){
- array_unshift($queue,$command);
- }else{
- array_push($queue,$command);
+ if ($priority) {
+ array_unshift($queue, $command);
+ } else {
+ array_push($queue, $command);
}
$redis->igbset($queue_name, $queue);
$redis->publish('domoticz_event', 'handle_queue');
-}
\ No newline at end of file
+ return true;
+}
+
+function getDomoticzDeviceStatus($device, $hardware = 'rflink')
+{
+ $res = runDomoticzCommand(['type' => 'devices', 'rid' => $device, 'hardware' => $hardware]);
+ $res = json_decode($res->getBody(),true);
+
+ return $res['result'][0]['Data'];
+}
$res .= '</div>';
$res .= '<div class="temps">';
$res .= '<div class="temp-min">' . $weather['min'] . '°C</div>';
- $res .= '<div class="temp"> ' . $weather['temp'] . '°C</div>';
+ $res .= '<div class="temp"> ' . $weather['outdoor_temp'] . '°C <span style="font-size:20%;"> ' . $weather['temp'] . '°C</span></div>';
$res .= '<div class="temp-max">' . $weather['max'] . '°C</div>';
$res .= '</div>';
- $res .= '<div class="pp"><i class="fa fa-water"></i> ' . $weather['precipitations24'] . ' mm | ' . $weather['pressure'] . ' hPa <i class="fa fa-arrow-circle-' . $pressureTendency . '"></i></div>';
+ $res .= '<div class="pp">';
+ $res .= '<i class="fas fa-cloud-rain"></i> ' . $weather['precipitations24'] . ' mm | <i class="fas fa-tachometer-alt"></i> ' . $weather['outdoor_pressure'] . ' hPa <i class="fa fa-arrow-circle-' . $pressureTendency . '"></i> | <i class="fa fa-tint"></i> ' . $weather['outdoor_humidity'] . '%</br>';
+ $res .= '<i class="fas fa-leaf"></i> ' . $weather['backyard_temp'] . ' °C | <i class="fa fa-tint"></i> ' . $weather['backyard_humidity'] . '%';
+ $res .= '</div>';
$res .= '</div>';
$res .= '<div class="forecasts">';
foreach ($weather['forecasts'] as $forecast) {