Xtrusion Domotica Project
Re: Xtrusion Domotica Project
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?
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?
-
- Member
- Posts: 86
- Joined: Sun Jun 03, 2012 3:08 pm
- Location: Apeldoorn / Netherlands
- Contact:
Re: Xtrusion Domotica Project
as television i have an LG 3D LED tv, this tv has an network connection, and there is an open port at 8080Dylantje 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?
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

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
-
- Member
- Posts: 86
- Joined: Sun Jun 03, 2012 3:08 pm
- Location: Apeldoorn / Netherlands
- Contact:
Re: Xtrusion Domotica Project
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
and function for latitude / longitude to address conversion based on google api
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

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

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;
}
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
Re: Xtrusion Domotica Project
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
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
-
- Member
- Posts: 86
- Joined: Sun Jun 03, 2012 3:08 pm
- Location: Apeldoorn / Netherlands
- Contact:
Re: Xtrusion Domotica Project
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
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
Re: Xtrusion Domotica Project
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
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
-
- Member
- Posts: 86
- Joined: Sun Jun 03, 2012 3:08 pm
- Location: Apeldoorn / Netherlands
- Contact:
Re: Xtrusion Domotica Project
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
Re: Xtrusion Domotica Project
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
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
-
- Member
- Posts: 86
- Joined: Sun Jun 03, 2012 3:08 pm
- Location: Apeldoorn / Netherlands
- Contact:
Re: Xtrusion Domotica Project
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
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

Xtrusion Digital Home Automation Project
Re: Xtrusion Domotica Project
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?
-
- Member
- Posts: 86
- Joined: Sun Jun 03, 2012 3:08 pm
- Location: Apeldoorn / Netherlands
- Contact:
Re: Xtrusion Domotica Project
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
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
Re: Xtrusion Domotica Project
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?
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?
-
- Member
- Posts: 86
- Joined: Sun Jun 03, 2012 3:08 pm
- Location: Apeldoorn / Netherlands
- Contact:
Re: Xtrusion Domotica Project
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
Re: Xtrusion Domotica Project
Thanks, it's working.
Re: Xtrusion Domotica Project
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?
I've ordered two 100 meter usb 4.0 dongles to see if the range is better. What is your experience regarding range?