Pass2PHP
Moderator: leecollings
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Pass2PHP
sl = set level.
So that is:
sl('Dimmer', 50);
So that is:
sl('Dimmer', 50);
-
- Posts: 390
- Joined: Wednesday 30 November 2016 11:58
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10717
- Contact:
Re: Pass2PHP
Nice!! thnx 

-
- Posts: 390
- Joined: Wednesday 30 November 2016 11:58
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10717
- Contact:
Re: Pass2PHP
Hi Guys,
I have a PIR in my bathroom so when I enter the bathroom at night the light is only at 30% instead of the full 100%.
I have the following script to do so:
Device script:
_cron60 script:
for some reason it keeps triggering the set level to 0 which causes my logfile to fill up with these requests.
I have more PIR's in my hous and they don't act this way.
the only difference is that the light in the bathroom is a dimmer and not a switch.
is there a chance you can help me out to prevent this from happening?
thnx!
I have a PIR in my bathroom so when I enter the bathroom at night the light is only at 30% instead of the full 100%.
I have the following script to do so:
Device script:
Code: Select all
<?php
if($status=='On'&&TIME>=strtotime('T20:00')){
sl('Badkamer', 30, true);
}
Code: Select all
if ($d['Badkamer']['s']>='1'&&$d['Auto']['s']=='Off'&&$d['PIR_Badkamer']['s']=='Off'&&past('Badkamer')>60) {
sl('Badkamer', 0);
}
I have more PIR's in my hous and they don't act this way.
the only difference is that the light in the bathroom is a dimmer and not a switch.
is there a chance you can help me out to prevent this from happening?
thnx!
- sincze
- Posts: 1302
- Joined: Monday 02 June 2014 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Location: Netherlands / Breda Area
- Contact:
Re: Pass2PHP
quick fix:
if not off after 60 sec... $d['Badkamer']['s']!='Off' and the rest of the requirements is true...
sw('Badkamer', ' Off');
should do the trick
if not off after 60 sec... $d['Badkamer']['s']!='Off' and the rest of the requirements is true...
sw('Badkamer', ' Off');
should do the trick
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: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Pass2PHP
Your cron60 has an error:
That should be:
Remove the quotes around numbers. With quotes numbers are treated as string and can't be evaluated with >=
Code: Select all
if ($d['Badkamer']['s']>='1'&&$d['Auto']['s']=='Off'&&$d['PIR_Badkamer']['s']=='Off'&&past('Badkamer')>60) {
sl('Badkamer', 0);
}
Code: Select all
if ($d['Badkamer']['s']>=1&&$d['Auto']['s']=='Off'&&$d['PIR_Badkamer']['s']=='Off'&&past('Badkamer')>60) {
sl('Badkamer', 0);
}
-
- Posts: 390
- Joined: Wednesday 30 November 2016 11:58
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10717
- Contact:
Re: Pass2PHP
I can't seem to get my head around it.
the script is as following:
Code: Select all
<?php
if($status=='On'/*&&TIME<=strtotime('T08:00')&&TIME>=strtotime('T19:00')*/){
sl('Badkamer', 30, true);
}
Elseif($status=='On'&&TIME>=strtotime('T08:00')&&TIME<=strtotime('T19:00')){
sl('Badkamer', 90, true);
}
Code: Select all
if ($d['Badkamer']['s']>=1&&$d['PIR_Badkamer']['s']=='Off'&&past('Badkamer')>60) {
sl('Badkamer', 0);
}
What did I mis?

- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Pass2PHP
Look in the database for the exact names and values. Code looks good.
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Pass2PHP
Or add a lg function just in front of it and keep the logfile open in tail:
Code: Select all
lg('Badkamer='.$d['Badkamer']['s'].', PIR='.$d['PIR_Badkamer']['s'].', past='.past('Badkamer'));
-
- Posts: 390
- Joined: Wednesday 30 November 2016 11:58
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10717
- Contact:
Re: Pass2PHP
ive added the lg function which works good and it gives me the values as expected but the cron doesnt work(for the others it works ok though)
i checked the database, the name is correct but the value in the database says: ”Set Level: 57 %” instead of just 57.
could this be the reason?
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Pass2PHP
Then it doesn't give values as expected.
The logfile should be something like this then:
Badkamer = Set Level: 57 %... instead of Badkamer = 57.
You must check what version of Pass2php you're using:
In older versions there was a array in the pass2php file that had to be filled with the names of dimmers.
In the latest versions that's handled in the sql database, the dt field should be 'dimmer'.
For the dimmer devices this is done:
the filter_var strips all characters that aren't numeric.
The logfile should be something like this then:
Badkamer = Set Level: 57 %... instead of Badkamer = 57.
You must check what version of Pass2php you're using:
In older versions there was a array in the pass2php file that had to be filled with the names of dimmers.
In the latest versions that's handled in the sql database, the dt field should be 'dimmer'.
For the dimmer devices this is done:
Code: Select all
if ($d[$device]['dt']=='dimmer'||$d[$device]['dt']=='rollers'||$d[$device]['dt']=='luifel') {
if ($status=='Off'||$status=='Open') {
$status=0;
} elseif ($status=='On'||$status=='Closed') {
$status=100;
} else {
$status=filter_var($status, FILTER_SANITIZE_NUMBER_INT);
}
}
-
- Posts: 390
- Joined: Wednesday 30 November 2016 11:58
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10717
- Contact:
Pass2PHP
I have php version 7.0.33-0 which is the latest right?
You are right! The log file says: Badkamer = Set Level: 57 %
I really need it to numeric as it is much easier to work with instead of set level etc etc
BTW. If I quote the value like this: >'1'
Code: Select all
if ($d['Badkamer']['s']>'1'/*&&$d['PIR_Badkamer']['s']=='Off'*/&&past('Badkamer')>60){
sl('Badkamer', 20);
}


What is going on?? Haha
Sent from my iPhone using Tapatalk
-
- Posts: 390
- Joined: Wednesday 30 November 2016 11:58
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10717
- Contact:
Re: Pass2PHP
the code of the pass2php.php file is as following(You mean this file right?:
Code: Select all
<?php
/**
* Pass2PHP
* php version 7.3.3-1
*
* @category Home_Automation
* @package Pass2PHP
* @author Guy Verschuere <[email protected]>
* @license GNU GPLv3
* @link https://egregius.be
**/
require '/var/www/config.php';
require 'functions.php';
$device=$_REQUEST['d'];
$status=$_REQUEST['s'];
$username='Domoticz';
if (endswith($device, '_Temperature')) {
die('Nothing to do');
} elseif (endswith($device, '_Utility')) {
die('Nothing to do');
}
if (in_array(
$device, array(
'PIR-Bijkeuken',
'zithoek',
'kamer',
'tobi',
'alex',
'terras',
'lichtbadkamer',
'Xvol',
'Rliving',
'Rbureel',
'RkeukenL',
'RkeukenR',
'RkamerL',
'RkamerR',
'Rtobi',
'Ralex',
'luifel'
)
)
) {
if ($status=='Off'||$status=='Open') {
store($device, 0);
} elseif ($status=='On'||$status=='Closed') {
store($device, 100);
} else {
$status=filter_var($status, FILTER_SANITIZE_NUMBER_INT);
store($device, $status);
}
} elseif (in_array($device, array('badkamer_temp'))) {
$status=explode(';', $status);
$status=$status[0];
store($device, $status);
} elseif ($device=='achterdeur') {
if ($status=='Open') {
$status='Closed';
} else {
$status='Open';
}
store($device, $status);
} else {
store($device, $status);
}
lgsql('Domoticz',$device,$status);
lg($device.' = '.$status);
@include 'pass2php/'.$device.'.php';
-
- Posts: 390
- Joined: Wednesday 30 November 2016 11:58
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10717
- Contact:
Re: Pass2PHP
I saw that more values within the database are not broken down in separate values.
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Pass2PHP
Either you update to the latest pass2php version where devicetypes are stored in the dt column of the database or you fill the array with your own devices:
PIR-Bijkeuken shouldn't be in there. That array holds the devices of wich the data has to be filtered to numbers.
For the other devices you'll have to make something like I did for my badkamer_temp:
explode splits a string into a array.
Code: Select all
$device, array(
'PIR-Bijkeuken',
'zithoek',
'kamer',
'tobi',
'alex',
'terras',
'lichtbadkamer',
'Xvol',
'Rliving',
'Rbureel',
'RkeukenL',
'RkeukenR',
'RkamerL',
'RkamerR',
'Rtobi',
'Ralex',
'luifel'
)
For the other devices you'll have to make something like I did for my badkamer_temp:
Code: Select all
elseif (in_array($device, array('badkamer_temp'))) {
$status=explode(';', $status);
$status=$status[0];
store($device, $status);
}
-
- Posts: 390
- Joined: Wednesday 30 November 2016 11:58
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10717
- Contact:
Re: Pass2PHP
What is the latest PHP version?
If I do a regular apt-get update and upgrade, it says everything is up to date?
Sent from my iPhone using Tapatalk
If I do a regular apt-get update and upgrade, it says everything is up to date?
Sent from my iPhone using Tapatalk
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Pass2PHP
I didn't wrote the last php version, but the last pass2php version.
That's always on my Github.
That's always on my Github.
-
- Posts: 390
- Joined: Wednesday 30 November 2016 11:58
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10717
- Contact:
Re: Pass2PHP
I only see a reference to php 7.0 based on the pass2php topic. Is there another topic or a link to share?Egregius wrote:I didn't wrote the last php version, but the last pass2php version.
That's always on my Github.
Sent from my iPhone using Tapatalk
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Pass2PHP
Please read my previous reply carefully.
-
- Posts: 390
- Joined: Wednesday 30 November 2016 11:58
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10717
- Contact:
Re: Pass2PHP
Of course I can enter all the device in the array but I would rather have the latest PHP version. I checked your github pageEgregius wrote:Please read my previous reply carefully.

Sent from my iPhone using Tapatalk
Who is online
Users browsing this forum: No registered users and 1 guest