Skip to content
Permalink
Browse files

freedomotic draft implementation

  • Loading branch information...
soif committed Apr 28, 2017
1 parent f682df6 commit 33f01417f8ae28e5a2559b5676c97b12621d8c40
@@ -11,7 +11,7 @@ phpMyDomo is an open-source Web Application aimed to provide a clean, robust, cu
With todays chinese phones and tablets starting as low as $50, it becomes a cheap and powerfull way to build remotes to control anything smartly in your house. phpMyDomo wants to be the ultimate WebApp that works as well on these devices, as on any computer browser.
phpMyDomo don't aim to replace the cool domotic's software you're currently using, but rather to add a convenient web interface to it.

Currently supported software include __Domoticz__, __Domotiga__, __OpenHab__ and __Domogik__. (+ pilight draft)
Currently supported software include __Domoticz__, __Domotiga__, __OpenHab__ and __Domogik__. (+ Pilight & Freedomotic drafts)

This is a Work In Progress: Depending on the chosen server API, some features might not be fully working at this time.

@@ -0,0 +1,140 @@
<?php
/*
phpMyDomo : Home Automation Web Interface
http://www.phpmydomo.org
----------------------------------------------
Copyright (C) 2013 Francois Dechery
LICENCE: ###########################################################
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
#####################################################################
*/
/*
#########################################################################################
FreeDomotic API ############################################################################
#########################################################################################
Proof of Concept : Only Switches and Temperatures sensor MIGHT work
*/
class PMD_ApiClient extends PMD_Root_ApiClient{
//----------------------------------------------------------------------------------
function ApiListInfos(){
//TODO
/*
if($this->ApiFetch('list','info')){
$info = $this->api_response;
//$this->infos['sunset_time'] =strtotime(date('m/d/Y ').$info['Sunset']);
//$this->infos['sunrise_time'] =strtotime(date('m/d/Y ').$info['Sunrise']);
//$this->infos['server_time'] =strtotime($info['ServerTime']);
}
*/
//$this->Debug('Info',$this->infos);
}
//----------------------------------------------------------------------------------
function ApiListDevices(){
if($this->ApiFetch('list','device')){
$devices = $this->GetResult();
$i=0;
foreach($devices as $d){
$raw=$d['raw'];
if($raw['type']=='EnvObject.ElectricDevice.Light'){
$d['class'] ='command';
$d['type'] ='switch';
if($behavior=$this->_extractBehaviorbyName($raw['behaviors'],'powered')){
$d['raw_value1']=$behavior['value'];
}
}
/*
elseif($raw['type']=='EnvObject.ElectricDevice'){
$d['class'] ='scene';
$d['type'] ='scene';
if($behavior=$this->_extractBehaviorbyName($raw['behaviors'],'powered')){
$d['raw_value1']=$behavior['value'];
}
}
*/
elseif($raw['type']=='EnvObject.Gate'){
$d['class'] ='sensor';
$d['type'] ='door';
if($behavior=$this->_extractBehaviorbyName($raw['behaviors'],'open')){
$d['raw_value1']=$behavior['value'];
}
}
elseif($raw['type']=='EnvObject.Thermometer'){
$d['class'] ='sensor';
$d['type'] ='temp';
if($behavior=$this->_extractBehaviorbyName($raw['behaviors'],'temperature')){
$d['value']=$behavior['value'] / $behavior['scale'] ;
}
}
//TODO other types
$this->RegisterDevice($d);
}
//uncomment this to show the whole devices array
//$this->Debug('Devices',$this->devices);
}
else{
if($this->debug){
$this->o_kernel->PageError('500',"Failed to contact server at {$this->api_url} ");
}
}
/*
// get Cameras ------------------------
if($this->ApiFetch('list','camera')){
$cameras = $this->GetResult();
foreach($cameras as $cam){
$raw=$cam['raw'];
if($raw['Enabled'] !='true'){continue;}
$cam['url'] =$this->_MakeCameraUrl($raw);
$cam['class'] ="camera";
$cam['type'] ="cam_ip";
$this->RegisterDevice($cam);
}
}
else{
if($this->debug){
$this->o_kernel->PageError('500',"Failed to contact server at {$this->api_url} ");
}
}
*/
}
// ---------------------------------------------------------------
private function _extractBehaviorbyName($behaviors,$name){
if(is_array($behaviors)){
foreach($behaviors as $b){
if($b['name']==$name){
return $b;
}
}
}
return false;
}
}
?>
@@ -0,0 +1,135 @@
<?php
//#############################################################################
// REQUIRED #################################################################
//#############################################################################
$api['method']='json_mixed'; //api method : json_get | json_rpc2
//api URL ----------------------------------------------------------------
$api['urls']['api'] =$this->conf['urls']['host'].':9111';
$api['urls']['www'] =$this->conf['urls']['host'].':8090';
$api['dir_admin'] ='/';
// Set Commands Values -------------------------------------------------------
// Values used when Sending a command
$api['set']['switch']['on'] ='true';
$api['set']['switch']['off'] ='false';
//$api['set']['push']['on'] ='true';
//$api['set']['push']['off'] ='false';
//$api['set']['scene']['on'] ='true';
//$api['set']['scene']['off'] ='false';
//$api['set']['group']['on'] ='true';
//$api['set']['group']['off'] ='false';
//$api['set']['dimmer']['on'] ='On';
//$api['set']['dimmer']['off'] ='false';
//$api['set']['dimmer']['min'] =1;
//$api['set']['dimmer']['max'] =16;
//$api['set']['blinds']['off'] ='true';
//$api['set']['blinds']['on'] ='false';
// Actions URLs -------------------------------------------------------------------
//$api['actions']['set']['switch'] ='/things/{address}/behaviorchange/powered/{state}';
$api['actions']['set']['switch'] =array(
'url' => '/v3/things/{address}/behaviorchange/powered/{state}',
'method' => 'post'
);
/*
$api['actions']['set']['scene'] =array(
'url' => '/v3/things/{address}/behaviorchange/powered/{state}',
'method' => 'post'
);
*/
//$api['actions']['set']['push'] ='/json.htm?type=command&param=switchlight&idx={address}&switchcmd={state}';
//$api['actions']['set']['dimmer'] ='/json.htm?type=command&param=switchlight&idx={address}&switchcmd={state}';
//$api['actions']['set']['blinds'] ='/json.htm?type=command&param=switchlight&idx={address}&switchcmd={state}&level=0';
//$api['actions']['set']['dim_level'] ='/json.htm?type=command&param=switchlight&idx={address}&switchcmd=Set+Level&level={state}';
//$api['actions']['set']['group'] ='/json.htm?type=command&param=switchscene&idx={address}&switchcmd={state}';
//$api['actions']['set']['selector'] ='/json.htm?type=command&param=switchlight&idx={address}&switchcmd=Set+Level&level={state}';
//#############################################################################
// CUSTOM api_client ##########################################################
//#############################################################################
// List actions URLS -------------------------------------
$api['actions']['list']['device'] =array(
'url' => '/v3/things',
'method' => 'get',
);
/*
//where can we get time infos (server time, sunset and sunrise times
$api['actions']['list']['info'] =array(
'url' => '/info_page',
'method' => 'get',
);
//where can we get the list of amera if any
$api['actions']['list']['info'] =array(
'url' => '/cam_page',
'method' => 'get',
);
*/
// RECEIVED States values (auto formatted when defined) ---------------------------------------
$api['states']['command']['switch'][false] ='off';
$api['states']['command']['switch'][true] ='on';
$api['states']['sensor']['door'][false] ='off';
$api['states']['sensor']['door'][true] ='on';
/*
$api['states']['scene']['scene'][false] ='off';
$api['states']['scene']['scene'][true] ='on';
//$api['states']['scene']['scene']['Mixed'] ='mixed';
$api['states']['command']['push']['Off'] ='off';
$api['states']['command']['push']['On'] ='on';
$api['states']['command']['dimmer']['Off'] ='off';
$api['states']['command']['dimmer']['On'] ='on';
$api['states']['command']['blinds']['Open'] ='off';
$api['states']['command']['blinds']['Closed'] ='on';
$api['states']['scene']['scene']['Off'] ='off';
$api['states']['scene']['scene']['On'] ='on';
$api['states']['scene']['scene']['Mixed'] ='mixed';
$api['states']['scene']['group']['Off'] ='off';
$api['states']['scene']['group']['On'] ='on';
$api['states']['scene']['group']['Mixed'] ='mixed';
$api['states']['sensor']['pir']['Off'] ='off';
$api['states']['sensor']['pir']['On'] ='on';
$api['states']['sensor']['bool']['Open'] ='off';
$api['states']['sensor']['bool']['Closed'] ='on';
*/
// json definition (auto formatted if defined) -------------------------------
// fields from the 'result' rows
$api['fields']['address'] ="uuid";
$api['fields']['name'] ="name";
//$api['fields']['battery_level'] ="BatteryLevel";
//$api['fields']['signal_level'] ="SignalLevel";
//json_get definition ----------------------------------------------------------
//$api['json']['status']="status"; //field with the Status of the response
//$api['json']['result']="result"; //field with the list of devices
// json received statuts value in the "status" field
//$api['json_status']['ok'] ='OK';
//$api['json_status']['err'] ='ERR';
?>
@@ -6,7 +6,7 @@
// ##############################################################################
// Minimal Configuration #######################################################
// ##############################################################################
//api to use : domoticz | domogik | domotiga | openhab
//api to use : 'domoticz' | 'domogik' | 'domotiga' | 'openhab' . ALPHAS : 'pilight' | 'freedomotic'
$conf['app']['api'] ="openhab";
// Personalize the name of your Home
@@ -57,6 +57,7 @@
//$conf['urls']['server_domogik'] ="http://10.1.100.152:40405";
//$conf['urls']['server_domotiga'] ="http://10.1.100.153:9090";
//$conf['urls']['server_pilight'] ="http://10.1.100.153:5000";
//$conf['urls']['server_freedomotic'] ="http://admin:admin@93.186.254.203:9111";
// Server Website, the normal GUI of your domotic server -----------------
// Format : http://hostname_or_ip:port(/subdir)
@@ -66,6 +67,7 @@
//$conf['urls']['www_domogik'] ="http://10.1.100.152:40404";
//$conf['urls']['www_domotiga'] ="http://10.1.100.153:9090";
//$conf['urls']['www_pilight'] ="http://10.1.100.153:5000";
//$conf['urls']['www_freedomotic'] ="http://93.186.254.203:8090";
Binary file not shown.

0 comments on commit 33f0141

Please sign in to comment.
You can’t perform that action at this time.