Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
didinau authored Apr 24, 2024
1 parent 1054573 commit 4c85aba
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 85 deletions.
2 changes: 1 addition & 1 deletion lib/sensors/sensor.DS18B20.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,4 @@ public function query()
}
}

?>
?>
2 changes: 1 addition & 1 deletion lib/sensors/sensor.cangrowattgbli6532.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,4 +237,4 @@ public function query()
}
}

?>
?>
55 changes: 36 additions & 19 deletions lib/sensors/sensor.mbPZEM-017.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
<?php

/* 240416
*
*
* Copyright 2024 Dieter Naujoks <dnaujoks@naujoks.homeip.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*
*/

/*
Shunt-Wert einstellen:
Expand All @@ -10,7 +33,7 @@
01 06 00 03 00 04 78 09 10A (interner Shunt)
$res=$modbus->modbusQuery(1,6,3,array(0,1),true,false);
$res = $modbus->modbusQuery(1, 6, 3, array(0, 1), true, false);
//*/

Expand Down Expand Up @@ -62,10 +85,9 @@ private function setShunt($_wert)

if( $res["request"] != $res["response"] )
{
new LogMsg(0, __class__."::".__function__, "Error set shunt (".$_wert.")\nRequ:".$res["request"]."\nResp:".$res["response"]);
new LogMsg(0, __class__ . "::" . __function__, "Error set shunt (" . $_wert . ")\nRequ:" . $res["request"] . "\nResp:" . $res["response"]);
}else{
if( $this->debug )
new LogMsg(0, __class__."::".__function__, "set shunt ".$_wert);
if( $this->debug ) new LogMsg(0, __class__ . "::".__function__, "set shunt " . $_wert);
}

}
Expand All @@ -91,19 +113,14 @@ public function query()
if( $this->mbOpen() )
{

if( isset($this->opt["shunt"]) )
$this->setShunt($this->opt["shunt"]);
if( isset($this->opt["shunt"]) ) $this->setShunt($this->opt["shunt"]);

$mbA = $this->mbReadInputReg(0,8);

if(
! $mbA["err"]
and
count($mbA["regs"]) == 8
)
if(! $mbA["err"] and count($mbA["regs"]) == 8 )
{

$this->result["publishP"] = true;
$this->result["publishP"] = true;

$this->result["i"] = floatval($mbA["regs"][1]/100);

Expand All @@ -113,13 +130,13 @@ public function query()
$this->result["tpv"] = floatval($mbA["regs"][4]/1000);
$this->result["ppv"] = floatval($mbA["regs"][2]/10);

foreach( array("i","u") as $op )
foreach( array("i", "u") as $op )
{

if( isset($this->opt["adjust.".$op]) )
$this->result["r".$op] = $this->result[$op] + floatval($this->opt["adjust.".$op]);
if( isset($this->opt["adjust." . $op]) )
$this->result["r" . $op] = $this->result[$op] + floatval($this->opt["adjust." . $op]);
else
$this->result["r".$op] = $this->result[$op];
$this->result["r" . $op] = $this->result[$op];
}

$this->result["ppv1"] = floatval($this->result["ri"] * $this->result["ru"]);
Expand All @@ -128,16 +145,16 @@ public function query()

}else{

$this->log_NoResponse(__class__."::".__function__, $this->port);
$this->log_NoResponse(__class__ . "::".__function__, $this->port);

}
}else{

new LogMsg(0, __class__."::".__function__, "error open port /dev/".$this->port);
new LogMsg(0, __class__ . "::".__function__, "error open port /dev/" . $this->port);

}
return sensor::RET_NODATA;
}
}

?>
?>
34 changes: 30 additions & 4 deletions lib/sensors/sensor.mbgrowattSPH.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
<?php


/* 240416
*
*
* Copyright 2024 Dieter Naujoks <dnaujoks@naujoks.homeip.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*
*/

class mbgrowattSPH extends sensor
{
public $MinSOCRegister = array(
Expand Down Expand Up @@ -38,15 +62,15 @@ public function query()
if( $wrdatum != $this->result["D"] )
{

new LogMsg(0, __class__."::".__function__, "WR-Datum entspricht nicht dem Query-Datum");
new LogMsg(0, __class__ . "::" . __function__, "WR-Datum entspricht nicht dem Query-Datum");

return sensor::RET_NODATA;

}

}else{

$this->log_NoResponse(__class__."::".__function__, $this->port);
$this->log_NoResponse(__class__ . "::" . __function__, $this->port);

return sensor::RET_NODATA;

Expand Down Expand Up @@ -94,6 +118,7 @@ public function query()
//>>>>>>>>>>> Tests
//$this->result["more"]["ExportLimitApparentPower"] = $this->ulng32($mbC["data"], $mbC["reg2idx"]->idx(1064), 10); //R 1048+1049
#$this->result["more"]["AC Charge Power"] = $this->ulng32($mbD["data"], $mbD["reg2idx"]->idx(1128), 10); //R 1128+1129

$this->result["paccharge"] = $this->ulng32($mbD["data"], $mbD["reg2idx"]->idx(1128), 10); //R 1128+1129

//********* Output power
Expand Down Expand Up @@ -133,6 +158,7 @@ public function query()
//oder

$this->result["dgridcharge"] = $this->ulng32($mbD["data"], $mbD["reg2idx"]->idx(1124), 10); //R 1124+1125

// $this->result["dmore"]["tgridcharge"] = $this->ulng32($mbD["data"], $mbD["reg2idx"]->idx(1126), 10); //R 1126+1127

$this->result["tgridcharge"] = $this->ulng32($mbD["data"], $mbD["reg2idx"]->idx(1126), 10); //R 1126+1127
Expand Down Expand Up @@ -199,7 +225,7 @@ public function query()
if( $this->result["dload"] == 0 )
{

new LogMsg(0, __class__."::".__function__, "WR-Load=0");
new LogMsg(0, __class__ . "::" . __function__, "WR-Load=0");

return sensor::RET_ERROR;

Expand Down Expand Up @@ -304,4 +330,4 @@ public function query()

}

?>
?>
Loading

0 comments on commit 4c85aba

Please # to comment.