mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-22 14:16:42 +00:00
added attribute tempOffset
git-svn-id: https://svn.fhem.de/fhem/trunk@2349 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
9aadb0c20a
commit
964ca01eb6
@ -28,7 +28,7 @@ sub GPIO4_Initialize($) {
|
|||||||
$hash->{DefFn} = "GPIO4_Define";
|
$hash->{DefFn} = "GPIO4_Define";
|
||||||
$hash->{UndefFn} = "GPIO4_Undef";
|
$hash->{UndefFn} = "GPIO4_Undef";
|
||||||
$hash->{GetFn} = "GPIO4_Get";
|
$hash->{GetFn} = "GPIO4_Get";
|
||||||
$hash->{AttrList} = "pollingInterval model loglevel:0,1,2,3,4,5,6";
|
$hash->{AttrList} = "tempOffset pollingInterval model loglevel:0,1,2,3,4,5,6";
|
||||||
}
|
}
|
||||||
|
|
||||||
sub GPIO4_Define($$) {
|
sub GPIO4_Define($$) {
|
||||||
@ -50,7 +50,10 @@ sub GPIO4_Define($$) {
|
|||||||
else {
|
else {
|
||||||
my ($family, $id) = split('-',$a[2]);
|
my ($family, $id) = split('-',$a[2]);
|
||||||
if ($family eq "28" || $family eq "10") {
|
if ($family eq "28" || $family eq "10") {
|
||||||
|
|
||||||
|
# reset failures counter
|
||||||
setReadingsVal($hash,'failures',0,TimeNow());
|
setReadingsVal($hash,'failures',0,TimeNow());
|
||||||
|
|
||||||
# start polling device after fhem.cfg completely loaded to ensure pollingInterval attribute is assigned (5s)
|
# start polling device after fhem.cfg completely loaded to ensure pollingInterval attribute is assigned (5s)
|
||||||
InternalTimer(gettimeofday()+5, "GPIO4_DeviceUpdateLoop", $hash, 0);
|
InternalTimer(gettimeofday()+5, "GPIO4_DeviceUpdateLoop", $hash, 0);
|
||||||
}
|
}
|
||||||
@ -112,6 +115,8 @@ sub GPIO_GetSlave($$) {
|
|||||||
$attr{"weblink_gpio4_$id"}{room} = $attr{autocreate}{weblink_room} || "GPIO4";
|
$attr{"weblink_gpio4_$id"}{room} = $attr{autocreate}{weblink_room} || "GPIO4";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# save fhem.cfg depending on autocreate autosave
|
||||||
|
CommandSave(undef, undef) if($attr{autocreate}{autosave});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,10 +135,14 @@ sub GPIO4_Get($) {
|
|||||||
open DATA, "/sys/bus/w1/devices/$hash->{DEF}/w1_slave";
|
open DATA, "/sys/bus/w1/devices/$hash->{DEF}/w1_slave";
|
||||||
if (<DATA> =~ /YES/) {
|
if (<DATA> =~ /YES/) {
|
||||||
<DATA> =~ /t=(\d+)/;
|
<DATA> =~ /t=(\d+)/;
|
||||||
my $temp = sprintf("%.1f", $1/1000.0);
|
my $temp = $1/1000.0;
|
||||||
|
if ($attr{$hash->{NAME}}{tempOffset}) {
|
||||||
|
$temp+=$attr{$hash->{NAME}}{tempOffset};
|
||||||
|
}
|
||||||
|
my $tempstr = sprintf("%.1f",$temp);
|
||||||
readingsBeginUpdate($hash);
|
readingsBeginUpdate($hash);
|
||||||
readingsBulkUpdate($hash,"state","T: $temp");
|
readingsBulkUpdate($hash,"state","T: $tempstr");
|
||||||
readingsBulkUpdate($hash,"temperature",$temp);
|
readingsBulkUpdate($hash,"temperature",$tempstr);
|
||||||
readingsEndUpdate($hash,1);
|
readingsEndUpdate($hash,1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user