Xtrusion Domotica Project

Put a link of your Home Automation, Domotica website here.

Re: Xtrusion Domotica Project

Postby Dylantje » Sun Jan 26, 2014 8:06 pm

I have a dummy switch working with some options from PLi, great...[ in Domoticz ]
How did you maken a volume up and down option?
And do you scenes in combination with a TV? [ pli on, tv on, on channel x, with sound on x ]

Is there a list from different hardware, witch api acces?

Or is open remote a better option?
Dylantje
Member
Member
 
Posts: 173
Joined: January 2013

Re: Xtrusion Domotica Project

Postby 123unlock » Tue Jan 28, 2014 12:04 pm

Dylantje wrote:I have a dummy switch working with some options from PLi, great...[ in Domoticz ]
How did you maken a volume up and down option?
And do you scenes in combination with a TV? [ pli on, tv on, on channel x, with sound on x ]

Is there a list from different hardware, witch api acces?

Or is open remote a better option?


as television i have an LG 3D LED tv, this tv has an network connection, and there is an open port at 8080
the protocol on this port is LG HDCP, i reversed the authentication on the tv so i can emulate the remote control buttons over network

for example command 8 = power button
command 2 = volume up
command 3 = volume down
and command 206 = HDMI1 (Switch tv to hdmi1 to connect to openpli box)

i know there are different ways to send commands (example IR blaster, but i didnt want an additional box in the livingroom just to send IR signals

simple php script to send remote commands to my tv (the $lgcommand contains the command value (ex 8))

Code: Select all
$fp2 = fsockopen("192.168.0.126", 8080, $errno, $errstr, 2);
if (!$fp) {
   echo "$errstr ($errno)<br />\n";
} else {

   $send = '<?xml version="1.0" encoding="utf-8"?><command><session>'.$session.'</session><type>HandleKeyInput</type><value>'.$lgcommand.'</value></command>\r\n';   

   $out = "POST /hdcp/api/dtv_wifirc HTTP/1.1\r\n";
   $out .= "Host: 192.168.0.126:8080\r\n";
   $out .= "Content-Type: application/atom+xml\r\n";
   $out .= "Content-Length: ".strlen($send)."\r\n";
   $out .= "Connection: Keep-Alive\r\n\r\n";
   $out .= $send;
   fwrite($fp2, $out);
   fclose($fp2);
}
Xtrusion Digital Home Automation Project
User avatar
123unlock
Member
Member
 
Posts: 86
Joined: June 2012
Location: Apeldoorn / Netherlands

Re: Xtrusion Domotica Project

Postby 123unlock » Thu Feb 06, 2014 7:05 pm

some News about the project

AEON HEM2 calibrated, I saw there was a difference between readed value and the value from the plugwise system, now they are more in sync
the strange part is the HEM2 was giving much higher values than plugwise, even with load it was always 22% higher :) so now the system logs $hem2 = ($hem2 * 0.78)

GeoFence
as I'm using the bTrace app for some time now it only displayed my location on the site and home panel, but how cool would it be to make some use of it :)
so I start coding a new php plugin, this plugin creates a geofence around our home, as soon as I enter the fence the system perform actions

for example if I come back from work, and I'm less than 3km away from my home it will send an NMA to my wife that I'm on the way home..
that way she can prepare me a drink :) nice homecoming hehe (**glad she does not read this lol **)

but also stuff like turn on the heating when no-body is home etc. lots of possibilities..
also nice is combining the gps coordinates with google api to generate address based on coordinates

some sample code for geofence in php

Code: Select all
function distance($lat1, $lon1, $lat2, $lon2) {
  $theta = $lon1 - $lon2;
  $dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) +  cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
  $dist = acos($dist);
  $dist = rad2deg($dist);
  $miles = $dist * 60 * 1.1515;
  $km = $miles * 1.609344;

  return $km;
}


and function for latitude / longitude to address conversion based on google api

Code: Select all
function geo2address($lat,$long) {
    $url = "http://maps.googleapis.com/maps/api/geocode/json?latlng=$lat,$long&sensor=false";
    $adrData=file_get_contents(    $url);
    $address = json_decode($adrData);
    $a=$address->results[0];
    $adr = explode(",",$a->formatted_address);
    return $adr[0] . $adr[1];
}
Xtrusion Digital Home Automation Project
User avatar
123unlock
Member
Member
 
Posts: 86
Joined: June 2012
Location: Apeldoorn / Netherlands

Re: Xtrusion Domotica Project

Postby Erikwout » Tue Oct 14, 2014 3:12 pm

Hi
This is looking very nice, I have a question, I am looking to buy/build the opentherm gateway and have it controlled via PHP, can i please ask you what parameters werre you able to pass into the gateway and how did you do this within PHP
Thanks for your help

Erik
Erikwout
Starting Member
Starting Member
 
Posts: 5
Joined: November 2012

Re: Xtrusion Domotica Project

Postby 123unlock » Sat Oct 18, 2014 7:04 pm

for opentherm I also have an usb to wifi controller connected, this will create a socket on the network
so my php code is just connecting to the socket, it receives all commands, and handle them in the database, and of Course you can send command to the TCPIP socket
this way I'm able to inject the outside temp (it will be displayed on my remeha iSense thermostat) or change the temperature automatically or remotely when I'm not home

it needs a bit of analyse and reverse to understand the commands in the protocol, but it's easy to understand
Xtrusion Digital Home Automation Project
User avatar
123unlock
Member
Member
 
Posts: 86
Joined: June 2012
Location: Apeldoorn / Netherlands

Re: Xtrusion Domotica Project

Postby Erikwout » Tue Oct 21, 2014 9:49 pm

Hi
Thanks for the answer, so if I understand correct you are talking directly to the Gateway and not to the otmonitor ?,
can i ask you to please share a piece of code so i have an example to work with ?, i am just starting with PHP and this will be my first big project.
thanks for the help
Erik
Erikwout
Starting Member
Starting Member
 
Posts: 5
Joined: November 2012

Re: Xtrusion Domotica Project

Postby 123unlock » Thu Nov 13, 2014 9:53 am

i made you some sample code just to read directly from the OTGW in php over tcpip socket

Code: Select all
function strtohex($string)
{
   $string = str_split($string);
   foreach($string as &$char)
   $char = "".dechex(ord($char));
   return implode('',$string);
}

function updatedb($field,$value, $otdev)
{
   /// Do something with the data you receive from the OTGW
}

$fp = fsockopen("192.168.0.112", 1001, $errno, $errstr, 30);
if (!$fp) {
   echo("Failed connecting to stream..\n");   
} else {
   //enable ID28
   fwrite($fp, "AA=28".chr(13));   

   while (!feof($fp)) {   

      $data = fread($fp, 1);
      $data2 .= $data;   

      if (eregi(chr(10),$data))
      {
         $data2 = substr($data2,0,9);
         $otdev = substr($data2,0,1);
         $msgid = substr($data2,3,2);
         $msgval = substr($data2,5,4);
         $decmsg = round((hexdec($msgval) / 256),2);
         $binmsg = decbin(hexdec($msgval));
         $info="";

         if ($msgid == "00") { $info="Status = ".$binmsg; $tt=updatedb("status",$msgval, $otdev);}
         if ($msgid == "01") { $info="Control Setpoint = ".$decmsg; }
         if ($msgid == "02") { $info="Master configuration = ".$decmsg; }
         if ($msgid == "03") { $info="Slave configuration = ".$decmsg; }
         if ($msgid == "05") { $info="Application-specific flags = ".$decmsg; }
         if ($msgid == "0E") { $info="Maximum relative modulation level = ".$decmsg; $tt=updatedb("maxrelativemodulation",$decmsg, $otdev); }
         if ($msgid == "10") { $info="Room Setpoint = ".$decmsg; $tt=updatedb("roomsetpoint",$decmsg, $otdev);}
         if ($msgid == "11") { $info="Relative Modulation = ".$decmsg; $tt=updatedb("relativemodulation",$decmsg, $otdev);}
         if ($msgid == "12") { $info="CH Pressure = ".$decmsg; $tt=updatedb("chwaterpressure",$decmsg, $otdev);}
         if ($msgid == "18") { $info="Room Temperature = ".$decmsg; $tt=updatedb("roomtemp",$decmsg, $otdev);}
         if ($msgid == "19") { $info="Boiler Flow Water Temperature = ".$decmsg; $tt=updatedb("boilerwatertemp",$decmsg, $otdev);}
         if ($msgid == "1A") { $info="DHW Temperature = ".$decmsg; }
         if ($msgid == "1B") { $info="Outside Temperature = ".$decmsg; }
         if ($msgid == "1C") { $info="Return Water Temperature = ".$decmsg; $tt=updatedb("returnwatertemp",$decmsg, $otdev);}
         if ($msgid == "1D") { $info="Solar Storage Temperature = ".$decmsg; }
         if ($msgid == "30") { $info="DHW setpoint boundaries = ".$decmsg; }
         if ($msgid == "31") { $info="Max CH setpoint boundaries = ".$decmsg; }
         if ($msgid == "38") { $info="DHW setpoint = ".$decmsg; }
         if ($msgid == "39") { $info="Max CH water setpoint = ".$decmsg; }
         if ($msgid == "74") { $info="CH Burner Starts = ".$decmsg; }
         if ($msgid == "75") { $info="CH Pomp Starts = ".$decmsg; }
         if ($msgid == "76") { $info="DHW pump/valve starts = ".$decmsg; }
         if ($msgid == "77") { $info="DHW Burner Starts = ".$decmsg; }
         if ($msgid == "78") { $info="Burner operation hours = ".$decmsg; }
         if ($msgid == "79") { $info="CH pump operation hours = ".$decmsg; }
         if ($msgid == "7A") { $info="DHW pump/valve operation hours = ".$decmsg; }
         if ($msgid == "7B") { $info="DHW burner operation hours = ".$decmsg; }
         
         echo date("Y-m-d H:i:s"). " ".$data2 . " * ".$info. "\n";
         $data2="";
      }
   }

   fclose($fp);
}
echo "**** ERROR: Stream Stopped -> Restart TPLink **** \n";

goto beginloop;

Xtrusion Digital Home Automation Project
User avatar
123unlock
Member
Member
 
Posts: 86
Joined: June 2012
Location: Apeldoorn / Netherlands

Re: Xtrusion Domotica Project

Postby tschombe » Thu Jan 22, 2015 10:10 am

very impressive

i see you also connect a youw8 scale
I also want to integrate a youw8 scale into my solution.
Do you get the data from the youw8 website or do you use the API
or do you directly connect to your local gateway?

would be nice to get some insight
you can also contact me by email at tschombe76@web.de
Thanks in advance
tschombe
Starting Member
Starting Member
 
Posts: 1
Joined: January 2015

Re: Xtrusion Domotica Project

Postby 123unlock » Mon Feb 02, 2015 4:10 pm

I'm connecting directly to the bridge it's internal IP address and grab the weight and the impadance from the webif
base on this the system can auto detect who is stepping on it, and calculated also values like fat/body water/ etc etc

it's connecting to the bridge every 30 seconds :) to check is there is new data
Xtrusion Digital Home Automation Project
User avatar
123unlock
Member
Member
 
Posts: 86
Joined: June 2012
Location: Apeldoorn / Netherlands

Re: Xtrusion Domotica Project

Postby XanderF » Sat Apr 11, 2015 11:30 am

What software are you using to track your sticknfind tags? Did you convert them to ibeacons? Do you track them with hcitool? Or a custom python script?
XanderF
Starting Member
Starting Member
 
Posts: 9
Joined: January 2015

Re: Xtrusion Domotica Project

Postby 123unlock » Tue Apr 14, 2015 12:45 pm

i created a nodejs script running on an rPI, this script is doing an HCITOOL LESCAN, and returns the "in range" mac addresses of the stickNfind tags
the nodeJS is setting up a websocket on the pi, so i can query it for data from my other applications
Xtrusion Digital Home Automation Project
User avatar
123unlock
Member
Member
 
Posts: 86
Joined: June 2012
Location: Apeldoorn / Netherlands

Re: Xtrusion Domotica Project

Postby XanderF » Tue Apr 14, 2015 9:28 pm

Thank you for the clarification.

I ran a hcitool lescan and retrieved the mac address of the sticknfind. But when I try to connect with hcitool cc <mac address> to check rssi it fails to connect. Are you doing it differently?
XanderF
Starting Member
Starting Member
 
Posts: 9
Joined: January 2015

Re: Xtrusion Domotica Project

Postby 123unlock » Fri Apr 17, 2015 7:47 pm

use a second thread with the HCIDUMP command, in this you can find the published BLE strings, including the RSSI levels
Xtrusion Digital Home Automation Project
User avatar
123unlock
Member
Member
 
Posts: 86
Joined: June 2012
Location: Apeldoorn / Netherlands

Re: Xtrusion Domotica Project

Postby XanderF » Fri Apr 17, 2015 7:54 pm

Thanks, it's working.
XanderF
Starting Member
Starting Member
 
Posts: 9
Joined: January 2015

Re: Xtrusion Domotica Project

Postby XanderF » Sun Apr 19, 2015 8:00 pm

The range is a little disappointing. I'm using a csr bluetooth 4.0 usb dongle and two stickNfinds. The bluetooth dongle has a range of 20 meter, but the stickNfind is not detected anymore when I'm 10 meters away from the raspberry pi. there are 2 doors between the stickNfind and the raspberry pi.

I've ordered two 100 meter usb 4.0 dongles to see if the range is better. What is your experience regarding range?
XanderF
Starting Member
Starting Member
 
Posts: 9
Joined: January 2015

PreviousNext

Return to Who has a realtime website

Who is online

Users browsing this forum: No registered users and 1 guest