Pass2PHP
Moderator: leecollings
-
- Posts: 483
- Joined: Tuesday 12 August 2014 5:37
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V3_8394
- Location: Rumbeke,Belgium
- Contact:
Re: Pass2PHP
got a stupid question, i need to install something more?
is mysqli standard included in php? or do i need to install this extra?
is mysqli standard included in php? or do i need to install this extra?
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Pass2PHP
Correct, 4th is name of database.
Think you'll need a extra package like php-mysql or something. Google 'enable mysqli php'
Think you'll need a extra package like php-mysql or something. Google 'enable mysqli php'
-
- Posts: 483
- Joined: Tuesday 12 August 2014 5:37
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V3_8394
- Location: Rumbeke,Belgium
- Contact:
Re: Pass2PHP
ok, will search for this.
so Domitica is your databank and temperature is a tabel?l?
so Domitica is your databank and temperature is a tabel?l?
-
- Posts: 483
- Joined: Tuesday 12 August 2014 5:37
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V3_8394
- Location: Rumbeke,Belgium
- Contact:
Re: Pass2PHP
strange, mysqli is installed now on my raspberry pi when i check phpinfo()
my mysql server is running on my nas 192.168.1.163
and when i make a php file on my raspberry pi with this:
then i get this error:
Failed to connect to MySQL: Can't connect to MySQL server on '192.168.1.163' (111)
my mysql server is running on my nas 192.168.1.163
and when i make a php file on my raspberry pi with this:
Code: Select all
<?php
$con = mysqli_connect("192.168.1.163","username","password","tabel");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
Failed to connect to MySQL: Can't connect to MySQL server on '192.168.1.163' (111)
-
- Posts: 483
- Joined: Tuesday 12 August 2014 5:37
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V3_8394
- Location: Rumbeke,Belgium
- Contact:
Re: Pass2PHP
i have also added a new user in my phpmyadmin configuration as you caan see in picture attached
and it has my raspberry pi as machine configured
don't know why it's not working to access my mysql database on my nas from a 'remote' computer inside my own network
and it has my raspberry pi as machine configured
don't know why it's not working to access my mysql database on my nas from a 'remote' computer inside my own network
- Attachments
-
- Naamloos.jpg (151.38 KiB) Viewed 2934 times
-
- Posts: 2
- Joined: Thursday 16 June 2016 22:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Pass2PHP
Look at your NAS ( I have a QNAP) if "activate TCP/IP networking" is enabled with port 3306 by your SQL server settings.
-
- Posts: 483
- Joined: Tuesday 12 August 2014 5:37
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V3_8394
- Location: Rumbeke,Belgium
- Contact:
Re: Pass2PHP
Hi, thank you for your response.
You mean in 'phpMyAdmin setup' at my nas ?
or somewhere in nas settings?
Thank you
You mean in 'phpMyAdmin setup' at my nas ?
or somewhere in nas settings?
Thank you
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Pass2PHP
Leave the machine empty/open for testing, first get it working, then secure it.
-
- Posts: 2
- Joined: Thursday 16 June 2016 22:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Pass2PHP
Somewhere in NAS setting like PHP Server.
MyPhpAdmin is only a tool for databases and has nothing to do with setup and accessing databases, because phpmyadmin uses localhost.
MyPhpAdmin is only a tool for databases and has nothing to do with setup and accessing databases, because phpmyadmin uses localhost.
-
- Posts: 483
- Joined: Tuesday 12 August 2014 5:37
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V3_8394
- Location: Rumbeke,Belgium
- Contact:
Re: Pass2PHP
Finally got it working, pheww
needed to find the 'configuration' file where i can comment the bind 127.0.0.1
but didn't know where to begin searching this 'configuration file' on my nas as Zyxell nas540 is sooo documented (not!)
for other people wo are also interested, it's located here:
/i-data/0e4bb2e1/.PKG/PHP-MySQL-phpMyAdmin/etc/init.d/PHP-MySQL-phpMyAdmin
and when you open this file, you will find somewhere this:
#nice -n ${NICE_VALUE} ./bin/mysqld_safe --user=mysql --bind-address=127.0.0.1 &
nice -n ${NICE_VALUE} ./bin/mysqld_safe --user=mysql &
just comment the first one and add it again and delete the --bind-address=127.0.0.1
then reboot your nas540 and all is working
needed to find the 'configuration' file where i can comment the bind 127.0.0.1
but didn't know where to begin searching this 'configuration file' on my nas as Zyxell nas540 is sooo documented (not!)
for other people wo are also interested, it's located here:
/i-data/0e4bb2e1/.PKG/PHP-MySQL-phpMyAdmin/etc/init.d/PHP-MySQL-phpMyAdmin
and when you open this file, you will find somewhere this:
#nice -n ${NICE_VALUE} ./bin/mysqld_safe --user=mysql --bind-address=127.0.0.1 &
nice -n ${NICE_VALUE} ./bin/mysqld_safe --user=mysql &
just comment the first one and add it again and delete the --bind-address=127.0.0.1
then reboot your nas540 and all is working
-
- Posts: 483
- Joined: Tuesday 12 August 2014 5:37
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V3_8394
- Location: Rumbeke,Belgium
- Contact:
Re: Pass2PHP
@Egregius: you are using this temperature data and state of 'brander' to chech the heating script?
Are you putting this data is some kind of a chart to have a better visual of the heating script?
Can this be found somewhere?
Thank you.
Are you putting this data is some kind of a chart to have a better visual of the heating script?
Can this be found somewhere?
Thank you.
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Pass2PHP
Should be this file: https://github.com/Egregius/PHP-Custom- ... r/temp.php
Temps are stored in 1 table every minute, each temp sensor is a column. Temps are stored with my cron script.
Temps are stored in 1 table every minute, each temp sensor is a column. Temps are stored with my cron script.
- sincze
- Posts: 1299
- Joined: Monday 02 June 2014 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Location: Netherlands / Breda Area
- Contact:
Re: Pass2PHP
Hi @Robske and @Egregius.
Just created 2 new functions for kodi integration
Maybe you can use them as well.
The first will send a notification to a Kodi machine. (notify_kodi)
The second will start a specific plugin in Kodi. In my case securitycam (kodi_addon)
I had to use the curl function because file_get_contents was waiting for an answer or so from kodi... Executed fine however did take a long time to complete. I used your old curl function and that was spot on.
I also bought some zwave powerplugs so I can monitor some power usage. @robske, tnx for inspiration. Now let's see what @Egregius already has in place for zwave in pass2php.
My girlriend uses NMA..
A well as you can see this is still work in progress.
Just created 2 new functions for kodi integration
Maybe you can use them as well.
The first will send a notification to a Kodi machine. (notify_kodi)
The second will start a specific plugin in Kodi. In my case securitycam (kodi_addon)
Code: Select all
function notify_kodi($destination,$port,$subject,$msg)
{
//EXAMPLE: kodi_notify("192.168.1.10","8080","dit is het onderwerp","dit is het bericht");
$params = array ('title'=> $subject, 'message'=> $msg);
$string = array ('jsonrpc'=> "2.0",'method' => 'GUI.ShowNotification','params' => $params,'id' => "1");
$params = json_encode($string);
curl('http://'.$destination.':'.$port.'/jsonrpc?request='.urlencode($params));
}
function kodi_addon($destination,$port,$addon)
{
//EXAMPLE: kodi_addon("192.168.1.10","8080","script.securitycam");
$params = array ('addonid' => $addon);
$string = array ('jsonrpc'=> "2.0",'method' => 'Addons.ExecuteAddon','params' => $params,'id' => "1");
$params = json_encode($string);
curl('http://'.$destination.':'.$port.'/jsonrpc?request='.urlencode($params));
}
I also bought some zwave powerplugs so I can monitor some power usage. @robske, tnx for inspiration. Now let's see what @Egregius already has in place for zwave in pass2php.
My girlriend uses NMA..
Code: Select all
function nma($event,$description)
{
$postdata = http_build_query(
array(
'apikey' => 'your_api_key_here',
'application' => 'Pass2PHP',
'event' => $event,
'description' => $description
)
);
$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $postdata
)
);
$context = stream_context_create($opts);
$result = file_get_contents('https://www.notifymyandroid.com/publicapi/notify?', false, $context);
lg('NMA Notification'.$result);
}
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Pass2PHP
Nice to see new functions! Thanks for sharing them here
What do you mean by 'let's see what Egregius has in place for zwave'?
My newest addition is Smappee wich gives me realtime (every 5 sec) total power usage and solar radiation:
For some reason the notify_kodi works fine with file_get_contents here, you could simplify the code to a one liner:
What do you mean by 'let's see what Egregius has in place for zwave'?
My newest addition is Smappee wich gives me realtime (every 5 sec) total power usage and solar radiation:
Code: Select all
$data_array = json_decode(file_get_contents('http://smappee.local/gateway/apipublic/reportInstantaneousValues'));
$unformatted = $data_array->report;
preg_match_all("/ activePower=(\\d*.\\d*)/", $unformatted, $matches);
if(!empty($matches[1][1])){
$zon=round($matches[1][1],0);
apcu_store('zon',$zon);
if(!empty($matches[1][2])){
$consumption=round($matches[1][2],0);
apcu_store('consumption',$consumption);
$timestamp=strftime("%Y-%m-%d %H:%M:%S",time);
$query="INSERT INTO `smappee` (`timestamp`,`consumption`,`solar`) VALUES ('$timestamp','$consumption','$zon');";
$db=new mysqli('localhost','kodi','kodi','domotica');if($db->connect_errno>0)die('Unable to connect to database [' . $db->connect_error . ']');if(!$result=$db->query($query))die('There was an error running the query ['.$query .' - ' . $db->error . ']');$db->close();
}
}
Code: Select all
function notify_kodi($subject,$msg){file_get_contents('http://192.168.2.7:1597/jsonrpc?request='.urlencode(json_encode(array('jsonrpc'=>"2.0",'method'=>'GUI.ShowNotification','params'=>array('title'=>$subject,'message'=>$msg),'id'=>"1"))));}
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Pass2PHP
Another variation of the notify_kodi could be this:
Function only needs 1 argument, the message. When the message is longer than 28 characters (maximum for subject without scrolling) the string is split into subject/message using wordwrap.
Code: Select all
function notify_kodi($msg){
if(strlen($msg)>28){
$chunks=explode('\n',wordwrap($msg,28,'\n',true));
$length=strlen($chunks[0]);
$subject=$chunks[0];
$message=trim(substr($msg,$length));
}else{
$subject=$msg;
}
file_get_contents('http://192.168.2.7:1597/jsonrpc?request='.urlencode(json_encode(array('jsonrpc'=>"2.0",'method'=>'GUI.ShowNotification','params'=>array('title'=>$subject,'message'=>$message,'displaytime'=>60000),'id'=>"1"))));
}
- sincze
- Posts: 1299
- Joined: Monday 02 June 2014 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Location: Netherlands / Breda Area
- Contact:
Re: Pass2PHP
Aha really nice indeed. Thanks for sharing.Egregius wrote:Another variation of the notify_kodi could be this:Function only needs 1 argument, the message. When the message is longer than 28 characters (maximum for subject without scrolling) the string is split into subject/message using wordwrap.Code: Select all
function notify_kodi($msg){ if(strlen($msg)>28){ $chunks=explode('\n',wordwrap($msg,28,'\n',true)); $length=strlen($chunks[0]); $subject=$chunks[0]; $message=trim(substr($msg,$length)); }else{ $subject=$msg; } file_get_contents('http://192.168.2.7:1597/jsonrpc?request='.urlencode(json_encode(array('jsonrpc'=>"2.0",'method'=>'GUI.ShowNotification','params'=>array('title'=>$subject,'message'=>$message,'displaytime'=>60000),'id'=>"1")))); }
I have to modify mine or yours a bit so it will send messages to all kodi machines that are switched on in the house.
So maybe something with
Code: Select all
Items = Array('woonkamer','keuken','slaapkamer','studeerkamer'');
for each item = items[...]..
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
- sincze
- Posts: 1299
- Joined: Monday 02 June 2014 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Location: Netherlands / Breda Area
- Contact:
Re: Pass2PHP
If I remember correctly there were some zwave functions in the original pass2php. I commented them out as I did not have zwave.Egregius wrote:Nice to see new functions! Thanks for sharing them here
What do you mean by 'let's see what Egregius has in place for zwave'?
When helping @Robske setup pass2php he showed me nice features of notifications if for example the washingmachine was ready (using zwave and smart plugs.) So I thought... why not give it a try and buy some.
Now I have to uncomment the zwave functions and see what they can do for me.
Smappee.. ?? that is a new oen, well Some more googling for me I think.
Still looking for the possibility to insert data into influxdb using pass2php.
Now it it done from within domoticz (http-link). Works pretty okay.
Last edited by sincze on Monday 27 February 2017 9:28, edited 1 time in total.
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
-
- Posts: 483
- Joined: Tuesday 12 August 2014 5:37
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V3_8394
- Location: Rumbeke,Belgium
- Contact:
Re: Pass2PHP
Code: Select all
#region Wasmachine Script
$wasmachine_status_var = cget('swasmachine_status_var');
$wasmachine_counter_var = cget('swasmachine_counter_var');
$wasmachine_manuallyEnd_var = cget('swasmachine_manuallyEnd_uservar');
$wasmachine_energy_consumption = cget('sVerbruik_Wasmachine');
$idle_minutes = 5;
$consumption_upper = 20;
$consumption_lower = 3;
$consumption_standby = 1;
$wasmachinecurrentPowerUsage = cget('sVerbruik_Wasmachine');
//Virtual switch is off, but consumption is higher than configured level, so washing has started
if(($wasmachinecurrentPowerUsage>$consumption_upper)&&($wasmachine_status_var==0)){
cset('swasmachine_status_var',1);
cset('twasmachine_status_var',time);
cset('swasmachine_manuallyEnd_uservar',0);
lg('Huidig verbruik wasmachine ('.$wasmachinecurrentPowerUsage.'W) is boven ingestelde waarde ('.$consumption_upper.'W), dus wasmachine is gestart!');
cset('swasmachine_counter_var',$idle_minutes);
sw(cget('iStatus_Wasmachine'),'Set%20Level&level=10','Set Status wasmachine on Werkend');
}
//Washing machine is not using a lot of energy, check the counter
if(($wasmachinecurrentPowerUsage<$consumption_lower)&&($wasmachine_status_var==1)){
cset('swasmachine_counter_var',$wasmachine_counter_var-1);
$wasmachine_counter_var = cget('swasmachine_counter_var');
lg('Huidig verbruik wasmachine ('.$wasmachinecurrentPowerUsage.'W) is lager dan idle waarde ('.$consumption_lower.'W), wasmachine is klaar of bijna klaar');
lg('Herbereken teller, oude waarde: '.$wasmachine_counter_var.' minuten');
}
else{
if(($wasmachine_counter_var!=$idle_minutes)&&$wasmachine_status_var==1){
cset('swasmachine_counter_var',$idle_minutes);
lg('Resetting wasmachine timer');
}
}
//Washingmachine is done
if($wasmachine_status_var==1&&$wasmachine_counter_var==0){
//lg('wasmachine is klaar');
//lg('Huidig verbruik wasmachine '.$wasmachine_energy_consumption.'W');
$wasmachine_tijdsduur=(time-cget('twasmachine_status_var'));
lg('Wasmachine is klaar, gelieve deze te ledigen! Tijdsduur bedraagt: '.($wasmachine_tijdsduur/60).' minuten');
cset('swasmachine_status_var',0);
sw(cget('iStatus_Wasmachine'),'Set%20Level&level=20','Set Status wasmachine on klaar');
$msg='Wasmachine is klaar met werken! Tijdsduur bedraagt: '.($wasmachine_tijdsduur/60).' minuten';
telegram($msg,true);
}
//wasmachine is switched off (manually)
if(($wasmachinecurrentPowerUsage<$consumption_standby)&&($wasmachine_status_var==0)&&($wasmachine_manuallyEnd_var==0)){
sw(cget('iStatus_Wasmachine'),'Set%20Level&level=0','Set Status wasmachine on Off');
cset('swasmachine_manuallyEnd_uservar',1);
}
#end
got the same running for droogkast and vaatwas :p
- sincze
- Posts: 1299
- Joined: Monday 02 June 2014 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Location: Netherlands / Breda Area
- Contact:
Re: Pass2PHP
Tnx @Robske really appreciated. Completely migrated to pass2php ??? Once it is running it keeps on going.ropske wrote:@sincze: here's an example for my 'wasmachine' :pCode: Select all
#region Wasmachine Script $wasmachine_status_var = cget('swasmachine_status_var'); $wasmachine_counter_var = cget('swasmachine_counter_var'); $wasmachine_manuallyEnd_var = cget('swasmachine_manuallyEnd_uservar'); $wasmachine_energy_consumption = cget('sVerbruik_Wasmachine'); $idle_minutes = 5; $consumption_upper = 20; $consumption_lower = 3; $consumption_standby = 1; $wasmachinecurrentPowerUsage = cget('sVerbruik_Wasmachine'); //Virtual switch is off, but consumption is higher than configured level, so washing has started if(($wasmachinecurrentPowerUsage>$consumption_upper)&&($wasmachine_status_var==0)){ cset('swasmachine_status_var',1); cset('twasmachine_status_var',time); cset('swasmachine_manuallyEnd_uservar',0); lg('Huidig verbruik wasmachine ('.$wasmachinecurrentPowerUsage.'W) is boven ingestelde waarde ('.$consumption_upper.'W), dus wasmachine is gestart!'); cset('swasmachine_counter_var',$idle_minutes); sw(cget('iStatus_Wasmachine'),'Set%20Level&level=10','Set Status wasmachine on Werkend'); } //Washing machine is not using a lot of energy, check the counter if(($wasmachinecurrentPowerUsage<$consumption_lower)&&($wasmachine_status_var==1)){ cset('swasmachine_counter_var',$wasmachine_counter_var-1); $wasmachine_counter_var = cget('swasmachine_counter_var'); lg('Huidig verbruik wasmachine ('.$wasmachinecurrentPowerUsage.'W) is lager dan idle waarde ('.$consumption_lower.'W), wasmachine is klaar of bijna klaar'); lg('Herbereken teller, oude waarde: '.$wasmachine_counter_var.' minuten'); } else{ if(($wasmachine_counter_var!=$idle_minutes)&&$wasmachine_status_var==1){ cset('swasmachine_counter_var',$idle_minutes); lg('Resetting wasmachine timer'); } } //Washingmachine is done if($wasmachine_status_var==1&&$wasmachine_counter_var==0){ //lg('wasmachine is klaar'); //lg('Huidig verbruik wasmachine '.$wasmachine_energy_consumption.'W'); $wasmachine_tijdsduur=(time-cget('twasmachine_status_var')); lg('Wasmachine is klaar, gelieve deze te ledigen! Tijdsduur bedraagt: '.($wasmachine_tijdsduur/60).' minuten'); cset('swasmachine_status_var',0); sw(cget('iStatus_Wasmachine'),'Set%20Level&level=20','Set Status wasmachine on klaar'); $msg='Wasmachine is klaar met werken! Tijdsduur bedraagt: '.($wasmachine_tijdsduur/60).' minuten'; telegram($msg,true); } //wasmachine is switched off (manually) if(($wasmachinecurrentPowerUsage<$consumption_standby)&&($wasmachine_status_var==0)&&($wasmachine_manuallyEnd_var==0)){ sw(cget('iStatus_Wasmachine'),'Set%20Level&level=0','Set Status wasmachine on Off'); cset('swasmachine_manuallyEnd_uservar',1); } #end
got the same running for droogkast and vaatwas :p
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Pass2PHP
I have these functions specifically for zwave (these are all commands from OZWCP):sincze wrote:If I remember correctly there were some zwave functions in the original pass2php.
RefreshZwave: refreshes the status of a device, used for the wrong status of Qubino double relays.
Within the refreshZwave a check is made for dead nodes and tried to wake them up again.
ZwaveCommand:Sends a command to the controller
ControllerBusy:checks if the controller is busy with a previous command
Zwavecancelaction: cancels the current actions. Some action seems to never stop.
Smappee is a energy monitor that gets installed with a ampere meter on the fases of the counter and on those of the solar inverter. They claim to 'read the dna' of every device and can assign that so you know with one meter all appliances in the house.
About influxdb: can't you do anything with the MySQL examples? If a http poller can do it, it must be possible.
For your multiple kodi's:
You could try it simply by this:
Code: Select all
function notify_kodi($msg){
if(strlen($msg)>28){
$chunks=explode('\n',wordwrap($msg,28,'\n',true));
$length=strlen($chunks[0]);
$subject=trim(substr($msg,0,$length));
$message=trim(substr($msg,$length));
}else{
$subject=$msg;
}
$ctx=stream_context_create(array('http'=>array('timeout'=>1)));
file_get_contents('http://192.168.2.7:1597/jsonrpc?request='.urlencode(json_encode(array('jsonrpc'=>"2.0",'method'=>'GUI.ShowNotification','params'=>array('title'=>$subject,'message'=>$message,'displaytime'=>60000),'id'=>"1"))),false,$ctx);
file_get_contents('http://192.168.2.8:1597/jsonrpc?request='.urlencode(json_encode(array('jsonrpc'=>"2.0",'method'=>'GUI.ShowNotification','params'=>array('title'=>$subject,'message'=>$message,'displaytime'=>60000),'id'=>"1"))),false,$ctx);
file_get_contents('http://192.168.2.9:1597/jsonrpc?request='.urlencode(json_encode(array('jsonrpc'=>"2.0",'method'=>'GUI.ShowNotification','params'=>array('title'=>$subject,'message'=>$message,'displaytime'=>60000),'id'=>"1"))),false,$ctx);
file_get_contents('http://192.168.2.10:1597/jsonrpc?request='.urlencode(json_encode(array('jsonrpc'=>"2.0",'method'=>'GUI.ShowNotification','params'=>array('title'=>$subject,'message'=>$message,'displaytime'=>60000),'id'=>"1"))),false,$ctx);
}
Or with a array:
Code: Select all
function notify_kodi($msg){
if(strlen($msg)>28){
$chunks=explode('\n',wordwrap($msg,28,'\n',true));
$length=strlen($chunks[0]);
$subject=trim(substr($msg,0,$length));
$message=trim(substr($msg,$length));
}else{
$subject=$msg;
}
$ctx=stream_context_create(array('http'=>array('timeout'=>3)));
$kodis=array('kodi1'=>'192.168.2.7','kodi2'=>'192.168.2.8');
foreach($kodis as $name=>$ip){
if(apcu_fetch('s'.$name)=='On')file_get_contents('http://'.$ip.':1597/jsonrpc?request='.urlencode(json_encode(array('jsonrpc'=>"2.0",'method'=>'GUI.ShowNotification','params'=>array('title'=>$subject,'message'=>$message,'displaytime'=>60000),'id'=>"1"))),false,$ctx);
}
}
Who is online
Users browsing this forum: No registered users and 1 guest