Skip to content

Commit

Permalink
Connect update, Devices fix
Browse files Browse the repository at this point in the history
* Connect: new CloudSync client (based on MQTT)
* Simple Devices: motion sensor fix
  • Loading branch information
sergejey committed Nov 22, 2017
1 parent 1e48b6e commit 4567db8
Show file tree
Hide file tree
Showing 4 changed files with 190 additions and 337 deletions.
28 changes: 28 additions & 0 deletions modules/connect/connect.class.php
Expand Up @@ -301,6 +301,34 @@ function admin(&$out) {

}

function sendMenuItems($items) {
// POST TO SERVER
$url = 'http://connect.smartliving.ru/upload/';
$fields = array('force_data'=>1,'menu_items'=>1, 'items' => urlencode(serialize($items)));

//url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');

//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch,CURLOPT_TIMEOUT, 30);


curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC ) ;
curl_setopt($ch, CURLOPT_USERPWD, $this->config['CONNECT_USERNAME'].":".$this->config['CONNECT_PASSWORD']);

//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
}
/**
* Title
*
Expand Down
2 changes: 1 addition & 1 deletion modules/devices/SMotions_motionDetected.php
@@ -1,5 +1,6 @@
<?php

$ot=$this->object_title;
if (!isset($params['statusUpdated'])) {
setTimeout($ot.'_motion_timer_status', '', 3);
}
Expand All @@ -10,7 +11,6 @@
}

$motion_timeout=20; // seconds timeout
$ot=$this->object_title;
$nobodysHome=getGlobal('NobodyHomeMode.active');

if (!isset($params['statusUpdated'])) {
Expand Down
2 changes: 1 addition & 1 deletion modules/devices/SOpenClose_statusUpdated.php
Expand Up @@ -18,7 +18,7 @@
if ($this->getProperty('isActivity')) {
$linked_room=$this->getProperty('linkedRoom');
if (getGlobal('NobodyHomeMode.active')) {
callMethodSafe('NobodyHomeMode.deactivate');
callMethodSafe('NobodyHomeMode.deactivate',array('sensor'=>$ot, 'room'=>$linked_room));
}
ClearTimeOut("nobodyHome");
SetTimeOut("nobodyHome","callMethodSafe('NobodyHomeMode.activate');", 1*60*60);
Expand Down

0 comments on commit 4567db8

Please sign in to comment.