mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-05 18:16:44 +00:00
git-svn-id: https://svn.fhem.de/fhem/trunk@4895 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
b93d6c5fc0
commit
5f8820ca10
@ -76,7 +76,7 @@ use strict;
|
|||||||
use warnings;
|
use warnings;
|
||||||
sub Log($$);
|
sub Log($$);
|
||||||
|
|
||||||
my $owx_version="5.03";
|
my $owx_version="5.04";
|
||||||
#-- fixed raw channel name, flexible channel name
|
#-- fixed raw channel name, flexible channel name
|
||||||
my @owg_fixed = ("A","B","C","D");
|
my @owg_fixed = ("A","B","C","D");
|
||||||
my @owg_channel = ("A","B","C","D");
|
my @owg_channel = ("A","B","C","D");
|
||||||
@ -591,7 +591,7 @@ sub OWAD_Get($@) {
|
|||||||
return "OWAD: Could not get values from device $name for ".$hash->{ERRCOUNT}." times, reason $ret";
|
return "OWAD: Could not get values from device $name for ".$hash->{ERRCOUNT}." times, reason $ret";
|
||||||
}
|
}
|
||||||
$hash->{PRESENT} = 1;
|
$hash->{PRESENT} = 1;
|
||||||
return "OWAD: $name.reading => ".OWAD_FormatValues($hash);
|
return "OWAD: $name.reading => ".$hash->{READINGS}{"state"}{VAL};
|
||||||
}
|
}
|
||||||
|
|
||||||
#-- get alarm values according to interface type
|
#-- get alarm values according to interface type
|
||||||
@ -616,7 +616,6 @@ sub OWAD_Get($@) {
|
|||||||
return "OWAD: Could not get values from device $name for ".$hash->{ERRCOUNT}." times, reason $ret";
|
return "OWAD: Could not get values from device $name for ".$hash->{ERRCOUNT}." times, reason $ret";
|
||||||
}
|
}
|
||||||
$hash->{PRESENT} = 1;
|
$hash->{PRESENT} = 1;
|
||||||
OWAD_FormatValues($hash);
|
|
||||||
|
|
||||||
#-- assemble ouput string
|
#-- assemble ouput string
|
||||||
$value = "";
|
$value = "";
|
||||||
@ -650,7 +649,6 @@ sub OWAD_Get($@) {
|
|||||||
return "OWAD: Could not get values from device $name for ".$hash->{ERRCOUNT}." times, reason $ret";
|
return "OWAD: Could not get values from device $name for ".$hash->{ERRCOUNT}." times, reason $ret";
|
||||||
}
|
}
|
||||||
$hash->{PRESENT} = 1;
|
$hash->{PRESENT} = 1;
|
||||||
OWAD_FormatValues($hash);
|
|
||||||
|
|
||||||
#-- assemble output string
|
#-- assemble output string
|
||||||
$value = "\n";
|
$value = "\n";
|
||||||
@ -748,9 +746,6 @@ sub OWAD_GetValues($) {
|
|||||||
}
|
}
|
||||||
$hash->{PRESENT} = 1;
|
$hash->{PRESENT} = 1;
|
||||||
|
|
||||||
$value=OWAD_FormatValues($hash);
|
|
||||||
Log 5, $value;
|
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -993,7 +988,6 @@ sub OWAD_Set($@) {
|
|||||||
#-- process results - we have to reread the device
|
#-- process results - we have to reread the device
|
||||||
$hash->{PRESENT} = 1;
|
$hash->{PRESENT} = 1;
|
||||||
OWAD_GetValues($hash);
|
OWAD_GetValues($hash);
|
||||||
OWAD_FormatValues($hash);
|
|
||||||
Log 4, "OWAD: Set $hash->{NAME} $key $value";
|
Log 4, "OWAD: Set $hash->{NAME} $key $value";
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
@ -1156,6 +1150,9 @@ sub OWFSAD_GetPage($$) {
|
|||||||
$hash->{owg_shigh}->[$i] = $an;
|
$hash->{owg_shigh}->[$i] = $an;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#-- and now from raw to formatted values
|
||||||
|
my $value = OWAD_FormatValues($hash);
|
||||||
|
Log 5, $value;
|
||||||
return undef
|
return undef
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1310,6 +1307,7 @@ sub OWXAD_BinValues($$$$$$$$) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#-- and now from raw to formatted values
|
||||||
my $value = OWAD_FormatValues($hash);
|
my $value = OWAD_FormatValues($hash);
|
||||||
Log 5, $value;
|
Log 5, $value;
|
||||||
return undef
|
return undef
|
||||||
|
@ -84,7 +84,7 @@ use strict;
|
|||||||
use warnings;
|
use warnings;
|
||||||
sub Log($$);
|
sub Log($$);
|
||||||
|
|
||||||
my $owx_version="5.03";
|
my $owx_version="5.04";
|
||||||
#-- fixed raw channel name, flexible channel name
|
#-- fixed raw channel name, flexible channel name
|
||||||
my @owg_fixed = ("A","B");
|
my @owg_fixed = ("A","B");
|
||||||
my @owg_channel = ("A","B");
|
my @owg_channel = ("A","B");
|
||||||
@ -735,7 +735,6 @@ sub OWCOUNT_Get($@) {
|
|||||||
}
|
}
|
||||||
$hash->{PRESENT} = 1;
|
$hash->{PRESENT} = 1;
|
||||||
#-- only one counter will be returned
|
#-- only one counter will be returned
|
||||||
OWCOUNT_FormatValues($hash);
|
|
||||||
return "OWCOUNT: $name.raw $a[2] => ".$hash->{owg_val}->[$page-14];
|
return "OWCOUNT: $name.raw $a[2] => ".$hash->{owg_val}->[$page-14];
|
||||||
|
|
||||||
#-- check syntax for getting counters
|
#-- check syntax for getting counters
|
||||||
@ -755,7 +754,7 @@ sub OWCOUNT_Get($@) {
|
|||||||
}
|
}
|
||||||
$hash->{PRESENT} = 1;
|
$hash->{PRESENT} = 1;
|
||||||
#-- both counters will be returned
|
#-- both counters will be returned
|
||||||
return "OWCOUNT: $name.counters => ".OWCOUNT_FormatValues($hash);
|
return "OWCOUNT: $name.counters => ".$hash->{READINGS}{"state"}{VAL};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1064,9 +1063,6 @@ sub OWCOUNT_GetValues($) {
|
|||||||
}
|
}
|
||||||
$hash->{PRESENT} = 1;
|
$hash->{PRESENT} = 1;
|
||||||
|
|
||||||
$value=OWCOUNT_FormatValues($hash);
|
|
||||||
Log 5, $value;
|
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1243,7 +1239,6 @@ sub OWCOUNT_Set($@) {
|
|||||||
#-- process results - we have to reread the device
|
#-- process results - we have to reread the device
|
||||||
$hash->{PRESENT} = 1;
|
$hash->{PRESENT} = 1;
|
||||||
OWCOUNT_GetValues($hash);
|
OWCOUNT_GetValues($hash);
|
||||||
OWCOUNT_FormatValues($hash);
|
|
||||||
Log 4, "OWCOUNT: Set $hash->{NAME} $key $value";
|
Log 4, "OWCOUNT: Set $hash->{NAME} $key $value";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1435,7 +1430,10 @@ sub OWFSCOUNT_GetPage($$) {
|
|||||||
if( $strval eq "" );
|
if( $strval eq "" );
|
||||||
$hash->{owg_str}->[$page] = $strval;
|
$hash->{owg_str}->[$page] = $strval;
|
||||||
}
|
}
|
||||||
return undef
|
#-- and now from raw to formatted values
|
||||||
|
my $value = OWCOUNT_FormatValues($hash);
|
||||||
|
Log 5, $value;
|
||||||
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
########################################################################################
|
########################################################################################
|
||||||
@ -1595,7 +1593,9 @@ sub OWXCOUNT_BinValues($$$$$$$$) {
|
|||||||
$hash->{owg_midnight}->[1] = $strval;
|
$hash->{owg_midnight}->[1] = $strval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#-- and now from raw to formatted values
|
||||||
|
my $value = OWCOUNT_FormatValues($hash);
|
||||||
|
Log 5, $value;
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ use strict;
|
|||||||
use warnings;
|
use warnings;
|
||||||
sub Log($$);
|
sub Log($$);
|
||||||
|
|
||||||
my $owx_version="5.03";
|
my $owx_version="5.04";
|
||||||
#-- declare variables
|
#-- declare variables
|
||||||
my %gets = (
|
my %gets = (
|
||||||
"present" => "",
|
"present" => "",
|
||||||
|
@ -70,7 +70,7 @@ use strict;
|
|||||||
use warnings;
|
use warnings;
|
||||||
sub Log($$);
|
sub Log($$);
|
||||||
|
|
||||||
my $owx_version="5.03";
|
my $owx_version="5.04";
|
||||||
#-- flexible channel name
|
#-- flexible channel name
|
||||||
my $owg_channel;
|
my $owg_channel;
|
||||||
|
|
||||||
@ -100,14 +100,17 @@ my %updates = (
|
|||||||
#
|
#
|
||||||
# Prefix = OWMULTI
|
# Prefix = OWMULTI
|
||||||
#
|
#
|
||||||
########################################################################################
|
##
|
||||||
|
# Parameters:
|
||||||
|
# hash - hash of device addressed
|
||||||
#
|
#
|
||||||
# OWMULTI_Initialize
|
# Called By:
|
||||||
|
# FHEM - Main Loop
|
||||||
|
# Gargelmargel - dunno where
|
||||||
#
|
#
|
||||||
# Parameter hash = hash of device addressed
|
#Calling:
|
||||||
#
|
# None
|
||||||
########################################################################################
|
##
|
||||||
|
|
||||||
sub OWMULTI_Initialize ($) {
|
sub OWMULTI_Initialize ($) {
|
||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
|
|
||||||
@ -323,7 +326,7 @@ sub OWMULTI_ChannelNames($) {
|
|||||||
$tfactor = 1.8;
|
$tfactor = 1.8;
|
||||||
} else {
|
} else {
|
||||||
$tabbr="?";
|
$tabbr="?";
|
||||||
Log 1, "OWMULTI_FormatValues: unknown unit $tunit";
|
Log 1, "OWMULTI_ChannelNames: unknown unit $tunit";
|
||||||
}
|
}
|
||||||
|
|
||||||
#-- these values are rather complex to obtain, therefore save them in the hash
|
#-- these values are rather complex to obtain, therefore save them in the hash
|
||||||
@ -463,6 +466,7 @@ sub OWMULTI_Get($@) {
|
|||||||
if( $interface eq "OWX" ){
|
if( $interface eq "OWX" ){
|
||||||
#-- not different from getting all values ..
|
#-- not different from getting all values ..
|
||||||
$ret = OWXMULTI_GetValues($hash);
|
$ret = OWXMULTI_GetValues($hash);
|
||||||
|
#ASYNC: Need to wait for some return
|
||||||
#-- OWFS interface not yet implemented
|
#-- OWFS interface not yet implemented
|
||||||
}elsif( $interface eq "OWServer" ){
|
}elsif( $interface eq "OWServer" ){
|
||||||
$ret = OWFSMULTI_GetValues($hash);
|
$ret = OWFSMULTI_GetValues($hash);
|
||||||
@ -479,7 +483,7 @@ sub OWMULTI_Get($@) {
|
|||||||
|
|
||||||
#-- return the special reading
|
#-- return the special reading
|
||||||
if ($reading eq "reading") {
|
if ($reading eq "reading") {
|
||||||
return "OWMULTI: $name.reading => ".OWMULTI_FormatValues($hash);
|
return "OWMULTI: $name.reading => ".$hash->{READINGS}{"state"}{VAL};
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($reading eq "temperature") {
|
if ($reading eq "temperature") {
|
||||||
@ -529,6 +533,7 @@ sub OWMULTI_GetValues($@) {
|
|||||||
#-- max 3 tries
|
#-- max 3 tries
|
||||||
for(my $try=0; $try<3; $try++){
|
for(my $try=0; $try<3; $try++){
|
||||||
$ret = OWXMULTI_GetValues($hash);
|
$ret = OWXMULTI_GetValues($hash);
|
||||||
|
#ASYNC: Need to wait for some result
|
||||||
return if( !defined($ret) );
|
return if( !defined($ret) );
|
||||||
}
|
}
|
||||||
}elsif( $interface eq "OWServer" ){
|
}elsif( $interface eq "OWServer" ){
|
||||||
@ -543,9 +548,6 @@ sub OWMULTI_GetValues($@) {
|
|||||||
}
|
}
|
||||||
$hash->{PRESENT} = 1;
|
$hash->{PRESENT} = 1;
|
||||||
|
|
||||||
$value=OWMULTI_FormatValues($hash);
|
|
||||||
Log 5, $value;
|
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -642,7 +644,7 @@ sub OWMULTI_Set($@) {
|
|||||||
#-- process results - we have to reread the device
|
#-- process results - we have to reread the device
|
||||||
$hash->{PRESENT} = 1;
|
$hash->{PRESENT} = 1;
|
||||||
OWMULTI_GetValues($hash);
|
OWMULTI_GetValues($hash);
|
||||||
OWMULTI_FormatValues($hash);
|
|
||||||
Log 4, "OWMULTI: Set $hash->{NAME} $key $value";
|
Log 4, "OWMULTI: Set $hash->{NAME} $key $value";
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
@ -699,6 +701,9 @@ sub OWFSMULTI_GetValues($) {
|
|||||||
return "empty return from OWServer"
|
return "empty return from OWServer"
|
||||||
if( ($hash->{owg_val}->[0] eq "") || ($hash->{owg_val}->[1] eq "") || ($hash->{owg_val}->[2] eq "") );
|
if( ($hash->{owg_val}->[0] eq "") || ($hash->{owg_val}->[1] eq "") || ($hash->{owg_val}->[2] eq "") );
|
||||||
|
|
||||||
|
#-- and now from raw to formatted values
|
||||||
|
my $value = OWMULTI_FormatValues($hash);
|
||||||
|
Log 5, $value;
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -790,6 +795,8 @@ sub OWXMULTI_BinValues($$$$$$$$) {
|
|||||||
|
|
||||||
#-- external voltage
|
#-- external voltage
|
||||||
$hash->{owg_val}->[2] = ($msb*256+ $lsb)/100;
|
$hash->{owg_val}->[2] = ($msb*256+ $lsb)/100;
|
||||||
|
|
||||||
|
#-- and now from raw to formatted values
|
||||||
my $value = OWMULTI_FormatValues($hash);
|
my $value = OWMULTI_FormatValues($hash);
|
||||||
Log 5, $value;
|
Log 5, $value;
|
||||||
};
|
};
|
||||||
|
@ -76,7 +76,7 @@ use strict;
|
|||||||
use warnings;
|
use warnings;
|
||||||
sub Log($$);
|
sub Log($$);
|
||||||
|
|
||||||
my $owx_version="5.03";
|
my $owx_version="5.04";
|
||||||
#-- fixed raw channel name, flexible channel name
|
#-- fixed raw channel name, flexible channel name
|
||||||
my @owg_fixed = ("A","B","C","D","E","F","G","H");
|
my @owg_fixed = ("A","B","C","D","E","F","G","H");
|
||||||
my @owg_channel = ("A","B","C","D","E","F","G","H");
|
my @owg_channel = ("A","B","C","D","E","F","G","H");
|
||||||
@ -348,7 +348,7 @@ sub OWSWITCH_ChannelNames($) {
|
|||||||
#
|
#
|
||||||
# OWSWITCH_FormatValues - put together various format strings
|
# OWSWITCH_FormatValues - put together various format strings
|
||||||
#
|
#
|
||||||
# CalledBy: OWSWITCH_FormatValues, OWSWITCH_Get, OWSWITCH_Set
|
# CalledBy: OWSWITCH_Get, OWSWITCH_Set
|
||||||
# Calling: --
|
# Calling: --
|
||||||
# Parameter; hash = hash of device addressed, fs = format string
|
# Parameter; hash = hash of device addressed, fs = format string
|
||||||
#
|
#
|
||||||
@ -486,7 +486,7 @@ sub OWSWITCH_Get($@) {
|
|||||||
#-- OWX interface
|
#-- OWX interface
|
||||||
if( $interface eq "OWX" ){
|
if( $interface eq "OWX" ){
|
||||||
$ret = OWXSWITCH_GetState($hash);
|
$ret = OWXSWITCH_GetState($hash);
|
||||||
#OWXSWITCH_AwaitGetState($hash);
|
#ASYNC OWXSWITCH_AwaitGetState($hash);
|
||||||
#-- OWFS interface
|
#-- OWFS interface
|
||||||
}elsif( $interface eq "OWFS" ){
|
}elsif( $interface eq "OWFS" ){
|
||||||
$ret = OWFSSWITCH_GetState($hash);
|
$ret = OWFSSWITCH_GetState($hash);
|
||||||
@ -495,7 +495,6 @@ sub OWSWITCH_Get($@) {
|
|||||||
return "OWSWITCH: Get with wrong IODev type $interface";
|
return "OWSWITCH: Get with wrong IODev type $interface";
|
||||||
}
|
}
|
||||||
#-- process results
|
#-- process results
|
||||||
OWSWITCH_FormatValues($hash);
|
|
||||||
$hash->{PRESENT} = 1;
|
$hash->{PRESENT} = 1;
|
||||||
return $name.".".$a[2]." => ".$hash->{READINGS}{$owg_channel[$fnd]}{VAL};
|
return $name.".".$a[2]." => ".$hash->{READINGS}{$owg_channel[$fnd]}{VAL};
|
||||||
|
|
||||||
@ -506,7 +505,7 @@ sub OWSWITCH_Get($@) {
|
|||||||
|
|
||||||
if( $interface eq "OWX" ){
|
if( $interface eq "OWX" ){
|
||||||
$ret = OWXSWITCH_GetState($hash);
|
$ret = OWXSWITCH_GetState($hash);
|
||||||
#OWXSWITCH_AwaitGetState($hash);
|
#ASYNC OWXSWITCH_AwaitGetState($hash);
|
||||||
}elsif( $interface eq "OWServer" ){
|
}elsif( $interface eq "OWServer" ){
|
||||||
$ret = OWFSSWITCH_GetState($hash);
|
$ret = OWFSSWITCH_GetState($hash);
|
||||||
}else{
|
}else{
|
||||||
@ -517,7 +516,7 @@ sub OWSWITCH_Get($@) {
|
|||||||
return "OWSWITCH: Could not get values from device $name, reason $ret";
|
return "OWSWITCH: Could not get values from device $name, reason $ret";
|
||||||
}
|
}
|
||||||
$hash->{PRESENT} = 1;
|
$hash->{PRESENT} = 1;
|
||||||
return "OWSWITCH: $name.$reading => ".OWSWITCH_FormatValues($hash);
|
return "OWSWITCH: $name.$reading => ".$hash->{READINGS}{"state"}{VAL};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -574,9 +573,6 @@ sub OWSWITCH_GetValues($) {
|
|||||||
}
|
}
|
||||||
$hash->{PRESENT} = 1;
|
$hash->{PRESENT} = 1;
|
||||||
|
|
||||||
$value = OWSWITCH_FormatValues($hash);
|
|
||||||
Log 5, $value;
|
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -771,9 +767,7 @@ sub OWSWITCH_Set($@) {
|
|||||||
#-- process results - we have to reread the device
|
#-- process results - we have to reread the device
|
||||||
$hash->{PRESENT} = 1;
|
$hash->{PRESENT} = 1;
|
||||||
OWSWITCH_GetValues($hash);
|
OWSWITCH_GetValues($hash);
|
||||||
#OWSWITCH_FormatValues($hash);
|
|
||||||
Log 4, "OWSWITCH: Set $hash->{NAME} $key $value";
|
Log 4, "OWSWITCH: Set $hash->{NAME} $key $value";
|
||||||
#$hash->{CHANGED}[0] = $value;
|
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -860,7 +854,11 @@ sub OWFSSWITCH_GetState($) {
|
|||||||
} else {
|
} else {
|
||||||
return "unknown device family $hash->{OW_FAMILY}\n";
|
return "unknown device family $hash->{OW_FAMILY}\n";
|
||||||
}
|
}
|
||||||
return undef
|
|
||||||
|
#-- and now from raw to formatted values
|
||||||
|
my $value = OWSWITCH_FormatValues($hash);
|
||||||
|
Log 5, $value;
|
||||||
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
########################################################################################
|
########################################################################################
|
||||||
@ -1058,7 +1056,7 @@ sub OWXSWITCH_BinValues($$$$$$$$) {
|
|||||||
return "unknown context in OWXSWITCH_BinValues";
|
return "unknown context in OWXSWITCH_BinValues";
|
||||||
}
|
}
|
||||||
|
|
||||||
#-- put into real readings
|
#-- and now from raw to formatted values
|
||||||
my $value = OWSWITCH_FormatValues($hash);
|
my $value = OWSWITCH_FormatValues($hash);
|
||||||
Log 5, $value;
|
Log 5, $value;
|
||||||
return undef;
|
return undef;
|
||||||
|
@ -75,7 +75,7 @@ use warnings;
|
|||||||
sub Log($$);
|
sub Log($$);
|
||||||
sub AttrVal($$$);
|
sub AttrVal($$$);
|
||||||
|
|
||||||
my $owx_version="5.03";
|
my $owx_version="5.04";
|
||||||
|
|
||||||
my %gets = (
|
my %gets = (
|
||||||
"id" => "",
|
"id" => "",
|
||||||
@ -228,9 +228,9 @@ sub OWTHERM_Define ($$) {
|
|||||||
$hash->{ASYNC} = 0; #-- false for now
|
$hash->{ASYNC} = 0; #-- false for now
|
||||||
|
|
||||||
#-- temperature globals - always the raw values from/for the device
|
#-- temperature globals - always the raw values from/for the device
|
||||||
$hash->{".owg_temp"} = "";
|
$hash->{owg_temp} = "";
|
||||||
$hash->{".owg_th"} = "";
|
$hash->{owg_th} = "";
|
||||||
$hash->{".owg_tl"} = "";
|
$hash->{owg_tl} = "";
|
||||||
|
|
||||||
#-- Couple to I/O device, exit if not possible
|
#-- Couple to I/O device, exit if not possible
|
||||||
AssignIoPort($hash);
|
AssignIoPort($hash);
|
||||||
@ -279,7 +279,7 @@ sub OWTHERM_Attr(@) {
|
|||||||
};
|
};
|
||||||
#-- resolution modified at runtime
|
#-- resolution modified at runtime
|
||||||
$key eq "resolution" and do {
|
$key eq "resolution" and do {
|
||||||
$hash->{".owg_cf"} = $value;
|
$hash->{owg_cf} = $value;
|
||||||
last;
|
last;
|
||||||
};
|
};
|
||||||
#-- alarm settings modified at runtime
|
#-- alarm settings modified at runtime
|
||||||
@ -337,12 +337,12 @@ sub OWTHERM_FormatValues($) {
|
|||||||
$hash->{tempf}{factor} = $factor;
|
$hash->{tempf}{factor} = $factor;
|
||||||
|
|
||||||
#-- no change in any value if invalid reading
|
#-- no change in any value if invalid reading
|
||||||
return if( $hash->{".owg_temp"} eq "");
|
return if( $hash->{owg_temp} eq "");
|
||||||
|
|
||||||
#-- correct values for proper offset, factor
|
#-- correct values for proper offset, factor
|
||||||
$vval = ($hash->{".owg_temp"} + $offset)*$factor;
|
$vval = ($hash->{owg_temp} + $offset)*$factor;
|
||||||
$vlow = floor(($hash->{".owg_tl"} + $offset)*$factor+0.5);
|
$vlow = floor(($hash->{owg_tl} + $offset)*$factor+0.5);
|
||||||
$vhigh = floor(($hash->{".owg_th"} + $offset)*$factor+0.5);
|
$vhigh = floor(($hash->{owg_th} + $offset)*$factor+0.5);
|
||||||
|
|
||||||
$main::attr{$name}{"tempLow"} = $vlow;
|
$main::attr{$name}{"tempLow"} = $vlow;
|
||||||
$main::attr{$name}{"tempHigh"} = $vhigh;
|
$main::attr{$name}{"tempHigh"} = $vhigh;
|
||||||
@ -439,6 +439,7 @@ sub OWTHERM_Get($@) {
|
|||||||
if( $interface eq "OWX" ){
|
if( $interface eq "OWX" ){
|
||||||
#-- not different from getting all values ..
|
#-- not different from getting all values ..
|
||||||
$ret = OWXTHERM_GetValues($hash);
|
$ret = OWXTHERM_GetValues($hash);
|
||||||
|
#ASYNC: NEED TO WAIT UNTIL DATA IS THERE
|
||||||
#-- OWFS interface
|
#-- OWFS interface
|
||||||
}elsif( $interface eq "OWServer" ){
|
}elsif( $interface eq "OWServer" ){
|
||||||
$ret = OWFSTHERM_GetValues($hash);
|
$ret = OWFSTHERM_GetValues($hash);
|
||||||
@ -452,7 +453,6 @@ sub OWTHERM_Get($@) {
|
|||||||
return "OWTHERM: Could not get values from device $name, return was $ret";
|
return "OWTHERM: Could not get values from device $name, return was $ret";
|
||||||
}
|
}
|
||||||
$hash->{PRESENT} = 1;
|
$hash->{PRESENT} = 1;
|
||||||
OWTHERM_FormatValues($hash);
|
|
||||||
|
|
||||||
#-- return the special reading
|
#-- return the special reading
|
||||||
if ($reading eq "temperature") {
|
if ($reading eq "temperature") {
|
||||||
@ -480,6 +480,12 @@ sub OWTHERM_GetValues($@) {
|
|||||||
my $value = "";
|
my $value = "";
|
||||||
my $ret = "";
|
my $ret = "";
|
||||||
|
|
||||||
|
#-- check if device needs to be initialized
|
||||||
|
if( $hash->{READINGS}{"state"}{VAL} eq "defined"){
|
||||||
|
OWTHERM_InitializeDevice($hash);
|
||||||
|
OWTHERM_FormatValues($hash);
|
||||||
|
}
|
||||||
|
|
||||||
#-- restart timer for updates
|
#-- restart timer for updates
|
||||||
RemoveInternalTimer($hash);
|
RemoveInternalTimer($hash);
|
||||||
InternalTimer(time()+$hash->{INTERVAL}, "OWTHERM_GetValues", $hash, 1);
|
InternalTimer(time()+$hash->{INTERVAL}, "OWTHERM_GetValues", $hash, 1);
|
||||||
@ -513,13 +519,6 @@ sub OWTHERM_GetValues($@) {
|
|||||||
}
|
}
|
||||||
$hash->{PRESENT} = 1;
|
$hash->{PRESENT} = 1;
|
||||||
|
|
||||||
#-- check if device needs to be initialized
|
|
||||||
OWTHERM_InitializeDevice($hash)
|
|
||||||
if( $hash->{READINGS}{"state"}{VAL} eq "defined");
|
|
||||||
|
|
||||||
$value=OWTHERM_FormatValues($hash);
|
|
||||||
Log 5, $value;
|
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -555,7 +554,7 @@ sub OWTHERM_InitializeDevice($) {
|
|||||||
$factor = 1.8;
|
$factor = 1.8;
|
||||||
} else {
|
} else {
|
||||||
$abbr="?";
|
$abbr="?";
|
||||||
Log 3, "OWTHERM_FormatValues: unknown unit $unit";
|
Log 3, "OWTHERM_InitializeDevice: unknown unit $unit";
|
||||||
}
|
}
|
||||||
#-- these values are rather complex to obtain, therefore save them in the hash
|
#-- these values are rather complex to obtain, therefore save them in the hash
|
||||||
$hash->{READINGS}{"temperature"}{TYPE} = "temperature";
|
$hash->{READINGS}{"temperature"}{TYPE} = "temperature";
|
||||||
@ -663,8 +662,8 @@ sub OWTHERM_Set($@) {
|
|||||||
$value = floor($value+0.5);
|
$value = floor($value+0.5);
|
||||||
|
|
||||||
#-- First we have to read the current data, because alarms may not be set independently
|
#-- First we have to read the current data, because alarms may not be set independently
|
||||||
$hash->{".owg_tl"} = floor($main::attr{$name}{"tempLow"}/$factor-$offset+0.5);
|
$hash->{owg_tl} = floor($main::attr{$name}{"tempLow"}/$factor-$offset+0.5);
|
||||||
$hash->{".owg_th"} = floor($main::attr{$name}{"tempHigh"}/$factor-$offset+0.5);
|
$hash->{owg_th} = floor($main::attr{$name}{"tempHigh"}/$factor-$offset+0.5);
|
||||||
|
|
||||||
#-- find upper and lower boundaries for given offset/factor
|
#-- find upper and lower boundaries for given offset/factor
|
||||||
my $mmin = floor((-55+$offset)*$factor+0.5);
|
my $mmin = floor((-55+$offset)*$factor+0.5);
|
||||||
@ -753,23 +752,26 @@ sub OWFSTHERM_GetValues($) {
|
|||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
|
|
||||||
#-- resolution (set by Attribute 'resolution' on OWFS)
|
#-- resolution (set by Attribute 'resolution' on OWFS)
|
||||||
my $resolution = defined $hash->{".owg_cf"} ? $hash->{".owg_cf"} : "";
|
my $resolution = defined $hash->{owg_cf} ? $hash->{owg_cf} : "";
|
||||||
#-- get values - or should we rather get the uncached ones ?
|
#-- get values - or should we rather get the uncached ones ?
|
||||||
$hash->{".owg_temp"} = OWServer_Read($master,"/$owx_add/temperature$resolution");
|
$hash->{owg_temp} = OWServer_Read($master,"/$owx_add/temperature$resolution");
|
||||||
|
|
||||||
my $ow_thn = OWServer_Read($master,"/$owx_add/temphigh");
|
my $ow_thn = OWServer_Read($master,"/$owx_add/temphigh");
|
||||||
my $ow_tln = OWServer_Read($master,"/$owx_add/templow");
|
my $ow_tln = OWServer_Read($master,"/$owx_add/templow");
|
||||||
|
|
||||||
return "no return from OWServer"
|
return "no return from OWServer"
|
||||||
if( (!defined($hash->{".owg_temp"})) || (!defined($ow_thn)) || (!defined($ow_tln)) );
|
if( (!defined($hash->{owg_temp})) || (!defined($ow_thn)) || (!defined($ow_tln)) );
|
||||||
return "empty return from OWServer"
|
return "empty return from OWServer"
|
||||||
if( ($hash->{".owg_temp"} eq "") || ($ow_thn eq "") || ($ow_tln eq "") );
|
if( ($hash->{owg_temp} eq "") || ($ow_thn eq "") || ($ow_tln eq "") );
|
||||||
|
|
||||||
#-- process alarm settings
|
#-- process alarm settings
|
||||||
$hash->{".owg_tl"} = $ow_tln;
|
$hash->{owg_tl} = $ow_tln;
|
||||||
$hash->{".owg_th"} = $ow_thn;
|
$hash->{owg_th} = $ow_thn;
|
||||||
|
|
||||||
return undef
|
#-- and now from raw to formatted values
|
||||||
|
my $value = OWTHERM_FormatValues($hash);
|
||||||
|
Log 5, $value;
|
||||||
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
########################################################################################
|
########################################################################################
|
||||||
@ -795,11 +797,11 @@ sub OWFSTHERM_SetValues($$) {
|
|||||||
my $value = $args->{$key};
|
my $value = $args->{$key};
|
||||||
next unless (defined $value and $value ne "");
|
next unless (defined $value and $value ne "");
|
||||||
if( lc($key) eq "templow") {
|
if( lc($key) eq "templow") {
|
||||||
$hash->{".owg_tl"} = $value;
|
$hash->{owg_tl} = $value;
|
||||||
} elsif( lc($key) eq "temphigh") {
|
} elsif( lc($key) eq "temphigh") {
|
||||||
$hash->{".owg_th"} = $value;
|
$hash->{owg_th} = $value;
|
||||||
} elsif( lc($key) eq "resolution") {
|
} elsif( lc($key) eq "resolution") {
|
||||||
$hash->{".owg_cf"} = $value;
|
$hash->{owg_cf} = $value;
|
||||||
next;
|
next;
|
||||||
} else {
|
} else {
|
||||||
next;
|
next;
|
||||||
@ -869,9 +871,9 @@ sub OWXTHERM_BinValues($$$$$$$$) {
|
|||||||
#$delta = 0;
|
#$delta = 0;
|
||||||
|
|
||||||
#-- 2's complement form = signed bytes
|
#-- 2's complement form = signed bytes
|
||||||
$hash->{".owg_temp"} = int($lsb/2) + $delta;
|
$hash->{owg_temp} = int($lsb/2) + $delta;
|
||||||
if( $sign !=0 ){
|
if( $sign !=0 ){
|
||||||
$hash->{".owg_temp"} = -128+$hash->{".owg_temp"};
|
$hash->{owg_temp} = -128+$hash->{owg_temp};
|
||||||
}
|
}
|
||||||
|
|
||||||
$ow_thn = ord($data[2]) > 127 ? 128-ord($data[2]) : ord($data[2]);
|
$ow_thn = ord($data[2]) > 127 ? 128-ord($data[2]) : ord($data[2]);
|
||||||
@ -889,9 +891,9 @@ sub OWXTHERM_BinValues($$$$$$$$) {
|
|||||||
#$msb = 7;
|
#$msb = 7;
|
||||||
|
|
||||||
#-- 2's complement form = signed bytes
|
#-- 2's complement form = signed bytes
|
||||||
$hash->{".owg_temp"} = $msb*16+ $lsb/16;
|
$hash->{owg_temp} = $msb*16+ $lsb/16;
|
||||||
if( $sign !=0 ){
|
if( $sign !=0 ){
|
||||||
$hash->{".owg_temp"} = -128+$hash->{".owg_temp"};
|
$hash->{owg_temp} = -128+$hash->{owg_temp};
|
||||||
}
|
}
|
||||||
$ow_thn = ord($data[2]) > 127 ? 128-ord($data[2]) : ord($data[2]);
|
$ow_thn = ord($data[2]) > 127 ? 128-ord($data[2]) : ord($data[2]);
|
||||||
$ow_tln = ord($data[3]) > 127 ? 128-ord($data[3]) : ord($data[3]);
|
$ow_tln = ord($data[3]) > 127 ? 128-ord($data[3]) : ord($data[3]);
|
||||||
@ -901,11 +903,12 @@ sub OWXTHERM_BinValues($$$$$$$$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#-- process alarm settings
|
#-- process alarm settings
|
||||||
$hash->{".owg_tl"} = $ow_tln;
|
$hash->{owg_tl} = $ow_tln;
|
||||||
$hash->{".owg_th"} = $ow_thn;
|
$hash->{owg_th} = $ow_thn;
|
||||||
|
|
||||||
#-- and now from raw to formatted values
|
#-- and now from raw to formatted values
|
||||||
OWTHERM_FormatValues($hash);
|
my $value = OWTHERM_FormatValues($hash);
|
||||||
|
Log 5, $value;
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -993,16 +996,16 @@ sub OWXTHERM_SetValues($$) {
|
|||||||
|
|
||||||
#-- $owg_tl and $owg_th are preset and may be changed here
|
#-- $owg_tl and $owg_th are preset and may be changed here
|
||||||
foreach my $key (keys %$args) {
|
foreach my $key (keys %$args) {
|
||||||
$hash->{".owg_tl"} = $args->{$key} if( lc($key) eq "templow");
|
$hash->{owg_tl} = $args->{$key} if( lc($key) eq "templow");
|
||||||
$hash->{".owg_th"} = $args->{$key} if( lc($key) eq "temphigh");
|
$hash->{owg_th} = $args->{$key} if( lc($key) eq "temphigh");
|
||||||
$hash->{".owg_cf"} = $args->{$key} if( lc($key) eq "resolution");
|
$hash->{owg_cf} = $args->{$key} if( lc($key) eq "resolution");
|
||||||
}
|
}
|
||||||
|
|
||||||
#-- put into 2's complement formed (signed byte)
|
#-- put into 2's complement formed (signed byte)
|
||||||
my $tlp = $hash->{".owg_tl"} < 0 ? 128 - $hash->{".owg_tl"} : $hash->{".owg_tl"};
|
my $tlp = $hash->{owg_tl} < 0 ? 128 - $hash->{owg_tl} : $hash->{owg_tl};
|
||||||
my $thp = $hash->{".owg_th"} < 0 ? 128 - $hash->{".owg_th"} : $hash->{".owg_th"};
|
my $thp = $hash->{owg_th} < 0 ? 128 - $hash->{owg_th} : $hash->{owg_th};
|
||||||
#-- resolution is defined in bits 5+6 of configuration register
|
#-- resolution is defined in bits 5+6 of configuration register
|
||||||
my $cfg = defined $hash->{".owg_cf"} ? (($hash->{".owg_cf"}-9) << 5) | 0x1f : 0x7f;
|
my $cfg = defined $hash->{owg_cf} ? (($hash->{owg_cf}-9) << 5) | 0x1f : 0x7f;
|
||||||
|
|
||||||
OWX_Reset($master);
|
OWX_Reset($master);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user