Page 58 of 76

Re: Pass2PHP

Posted: Tuesday 05 November 2019 20:26
by Trigun
ropske wrote: Monday 04 November 2019 22:10 and when i want to open other php files for example /secure/domoticz_devices.php
it is downloading the php file instead of opening it

running /secure/phpinfo.php is working well then
??
realy strange things
I've had this issue before as well, have a look at the "how-to"i wrote.
its a permission thing

Re: Pass2PHP

Posted: Tuesday 05 November 2019 22:19
by ropske
is it possible to give me a link please? thank you

Re: Pass2PHP

Posted: Thursday 07 November 2019 12:52
by Trigun
ropske wrote: Tuesday 05 November 2019 22:19 is it possible to give me a link please? thank you
here is the link: https://www.domoticz.com/forum/viewtopi ... start=1020

just search for my name and you'll find the guide I made

Re: Pass2PHP

Posted: Thursday 07 November 2019 17:01
by Egregius
This is the direct link: https://www.domoticz.com/forum/viewtopi ... 20#p221232
I'll add it to the readme :)

Re: Pass2PHP

Posted: Friday 08 November 2019 12:26
by luc4s
Hello Guys,
I' try to configure Pass2PHP but I stopped here:
When I open http://myip/secure/_fetchdomoticz.php I have an error message :
Warning: require(/var/www/config.php): failed to open stream: No such file or directory in /var/www/html/secure/functions.php on line 13

Fatal error: require(): Failed opening required '/var/www/config.php' (include_path='.:/usr/share/php') in /var/www/html/secure/functions.php on line 13
In the folder /var/www/html I added config.php file and also changed the permissions to chmod 777. I don't know where is the problem.... :(

Re: Pass2PHP

Posted: Friday 08 November 2019 18:56
by Egregius
Look at the path. The file must be in/var/www

Re: Pass2PHP

Posted: Friday 08 November 2019 19:10
by luc4s
Oh of course :)
I puted config in html folder, now it works.

Re: Pass2PHP

Posted: Friday 08 November 2019 22:26
by luc4s
I've just read all pages of this topic (really :) ) and I do not know that can I switch on Domoticz scenes also?

What I want to achieve:

I have Ikea Tradfri motion sensor called 'motion_sensor', 5 ikea tradfri GU10 bulbs with the possilibity to set color of light and Xiaomi door detector.
If the time is between 6 and 23 switch on all bulbs (deconz group 'coridor') with 100% power and cold light temp. else switch on all bulb with 2% of power and warm light color.
Anytime if the door are open set all lights on with 100% power and cold light temp.

In domoticz I have a lua script that works, but the delay is sometimes even 10s. This scripts is based on two scenes. First, day light and second night light. Can i trigger this scenes with pass2php?

Re: Pass2PHP

Posted: Saturday 09 November 2019 16:49
by Egregius
I would suggest creating your scenes in php.
Have a look at my github, it’s full of examples.

Re: Pass2PHP

Posted: Saturday 04 January 2020 12:40
by sincze
Just started with a new project in Pass2PHP.
domoticz-bmw.JPG
domoticz-bmw.JPG (83.93 KiB) Viewed 3339 times
In addition I can also get the vehicle location. I guess it should be quite easy to extend the Pass2PHP Database with a few more columns? Or would a separate DB be a better idea? Maybe I can extract the data later and plot... my driven maps ?? ;-)

My first steps at @Egregius floorplans ... :lol:

Please submit your suggestions.

Re: Pass2PHP

Posted: Saturday 04 January 2020 12:57
by Egregius
I think the current database can do. Every door/window as separate device. Maybe use status and mode for the coordinates?

Once you’ve found your way in the floorplan you won’t want anything else :D

Re: Pass2PHP

Posted: Sunday 05 January 2020 11:19
by sincze
You are right.

I started with.

Code: Select all

if (!empty($data['attributesMap']['gps_lat'])) 
{
	if (cget('BMW_GPS_LAT') != $gps_lat) cset('BMW_GPS_LAT',$gps_lat);
}
if (!empty($data['attributesMap']['gps_lng'])) 
{
	if (cget('BMW_GPS_LON') != $gps_lon) cset('BMW_GPS_LON',$gps_lon);
}	
This creates 2 entries in the Pass2PHP database log table. BMW_GPS_LAT_mode and BMW_GPS_LON_mode.
Maybe change that later to only one device to avoid flooding the log :lol:

Code: Select all

if (!empty($data['attributesMap']['gps_lat']) && !empty($data['attributesMap']['gps_lng']))  
{
	$coordinates=$gps_lat';'$gps_lon;
	if (cget('BMW_GPS') != $gps_lat) cset('BMW_GPS',$coordinates);
}		
The Database contains the timestamp and the location.

Code: Select all

('2020-01-04 12:01:26', 'BMW_GPS_LAT_mode', '50.48331'),
('2020-01-04 12:01:26', 'BMW_GPS_LON_mode', '5,3696233'),
('2020-01-04 12:02:17', 'BMW_GPS_LAT_mode', '52.57511'),
('2020-01-04 12:02:17', 'BMW_GPS_LON_mode', '5,3696233'),
('2020-01-04 12:03:13', 'BMW_GPS_LAT_mode', '52.57511'),
('2020-01-04 12:03:13', 'BMW_GPS_LON_mode', '5,3696233'),
('2020-01-04 12:04:17', 'BMW_GPS_LAT_mode', '52.57511'),
('2020-01-04 12:04:17', 'BMW_GPS_LON_mode', '5,3696233'),
('2020-01-04 12:05:15', 'BMW_GPS_LAT_mode', '52.57511'),
('2020-01-04 12:05:15', 'BMW_GPS_LON_mode', '5,369623');
That needs a nice MSQL query to have 1 line with 1 GPS coordinate..... for 1 day. I use the existing Pass2PHP db connection. takes aroud 60 sec.... to complete... on a raspberry Pi. Any query takes quite some time even an ordinary select. CPU usage spikes :lol:

Code: Select all

select timestamp, group_concat(`device` separator ',') as `GPS`
from
(
  select timestamp, 
  group_concat(`status` separator ',') as `device`
  from log
  WHERE `device` in ('BMW_GPS_LAT_mode','BMW_GPS_LON_mode') and DATE(`timestamp`) = CURDATE()
  group by timestamp, `device`
) tbl
group by timestamp;
Will give some output we can work with..

Code: Select all

('2020-01-04 12:01:26', '52.57511,5,3696233'),
('2020-01-04 12:02:17', '52.57511,5,3696233'),
('2020-01-04 12:03:13', '52.57511,5,3696233'),
('2020-01-04 12:04:17', '52.57511,5,3696233'),
('2020-01-04 12:05:15', '52.57511,5,369623');
These can be plotted on a map. Now to find out how to do it for free. Google requires me to signup at lease with valid credit card and obtain a free $200 credit per month. However I don't feel like signing up.

Re: Pass2PHP

Posted: Sunday 05 January 2020 12:01
by Egregius
What do you want to do with the coordinates?
Google ‘leaflet’, I use that to combine Google Mymaps, Google location history and Gurumaps tracks.
F7AD4C1A-6215-4B55-8D3C-F04F4A819E55.jpeg
F7AD4C1A-6215-4B55-8D3C-F04F4A819E55.jpeg (388.8 KiB) Viewed 3308 times

Re: Pass2PHP

Posted: Sunday 05 January 2020 13:30
by sincze
The idea, draw some daily picture about where the car was, or where it is now.
As not all famlily members will have the BMW app installed. :D

Current location can be plotted easily with Telegram (bot) and Google Maps for free.

Excellent suggestion indeed: https://www.endpoint.com/blog/2019/03/2 ... ps-leaflet
I noticed the payment program with google, as it will only be used for fun no need to hand over my creditcard details. :D

Re: Pass2PHP

Posted: Monday 06 January 2020 17:24
by Egregius
A totally different approach than I ;-)
I only want to see a combined history of places where I've been. Therefor in my MySQL table for the Google Location history I only have lat, lon as columns with a primary key on both. Without a timestamp or any other information. Each location that I receive is rounded to about 30 meters to avoid lot's of points.
For your case I would suggest a separate table and some functions to store and retrieve the data.

Re: Pass2PHP

Posted: Sunday 12 January 2020 22:09
by sincze
Created a separate DB and indeed. Query now done in 0,014 seconds in stead of 30 :lol:
To store the GPS I created this function.

Code: Select all

function storegps($timestamp,$lat,$lon)		
{
    global $geo;
    $geo->query("INSERT INTO location (Geotime,Latitude,Longitude) VALUES ('$timestamp','$lat','$lon');");
    lg('BMW: storing: Timestamp '.$timestamp.' Latitude:'.$lat.' Longitude: '.$lon);
}

Re: Pass2PHP

Posted: Thursday 30 January 2020 11:26
by McMelloW
Hi Pass2PHP gurus.

You have done a great job with it so far. I am thinking of implementing it on my RPi 3B+ to use it with Domoticz. After digging in to this topic and other stuff on Pass2PHP, I have some newby questions.

What happens with my default /home/pi/domoticz/domoticz.db?
Can I copy all historical data from /home/pi/domoticz/domoticz.db to the new domotica.db?

There is already a maria.db and phpMyAdmin running on my RPi for other purposes. Can this be configured and used together with Pass2PHP?
What is the benefit and/or need of a phpMyAdmin secure install on a local RPi

Re: Pass2PHP

Posted: Thursday 30 January 2020 11:31
by Egregius
Hi McMelloW,

Welcome to the club ;)

Pass2PHP doesn't change anything on the domoticz.db SQLlite database.
With the LUA script statusses are sent to PHP for further processing.

Yes, you can just create a second (or more) database on the same mariadb server. PHPmyadmin running means that you already have php enabled and you should be good to go. Should be easy to get it up and running.
A small warning nevertheless: it is very addictive :lol:

Re: Pass2PHP

Posted: Thursday 30 January 2020 15:40
by McMelloW
Egregius wrote: Thursday 30 January 2020 11:31 Hi McMelloW,

Welcome to the club ;)

Pass2PHP doesn't change anything on the domoticz.db SQLlite database.
With the LUA script statusses are sent to PHP for further processing.

Yes, you can just create a second (or more) database on the same mariadb server. PHPmyadmin running means that you already have php enabled and you should be good to go. Should be easy to get it up and running.
A small warning nevertheless: it is very addictive :lol:
Thanks for your welcome, yes it is addictive :lol:
But at this moment, it is more frustrating. It seems nothing happens, don't see any records appearing in the database. :cry: :cry:
Rebooted the RPi already.
How do I get my devices in the database?

Re: Pass2PHP

Posted: Thursday 30 January 2020 15:47
by Trigun
McMelloW wrote:
Egregius wrote: Thursday 30 January 2020 11:31 Hi McMelloW,

Welcome to the club ;)

Pass2PHP doesn't change anything on the domoticz.db SQLlite database.
With the LUA script statusses are sent to PHP for further processing.

Yes, you can just create a second (or more) database on the same mariadb server. PHPmyadmin running means that you already have php enabled and you should be good to go. Should be easy to get it up and running.
A small warning nevertheless: it is very addictive :lol:
Thanks for your welcome, yes it is addictive :lol:
But at this moment, it is more frustrating. It seems nothing happens, don't see any records appearing in the database. :cry: :cry:
Rebooted the RPi already.
How do I get my devices in the database?
Hi McMellow, good to know there is a how to file in this threat, a few pages back. Also have a look at the info from ergegius which is very thorough. Your issue is probably due to the symlink. Check the how to, it’s definitely stated in thereImage


Sent from my iPhone using Tapatalk