mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-25 03:39:21 +00:00
73_GasCalculator: Feature: Set command is manipulating readings now!
git-svn-id: https://svn.fhem.de/fhem/trunk@11669 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
ef32859dff
commit
d186f16e62
@ -53,6 +53,7 @@ sub GasCalculator_Initialize($)
|
|||||||
$hash->{STATE} = "Init";
|
$hash->{STATE} = "Init";
|
||||||
$hash->{DefFn} = "GasCalculator_Define";
|
$hash->{DefFn} = "GasCalculator_Define";
|
||||||
$hash->{UndefFn} = "GasCalculator_Undefine";
|
$hash->{UndefFn} = "GasCalculator_Undefine";
|
||||||
|
$hash->{SetFn} = "GasCalculator_Set";
|
||||||
$hash->{AttrFn} = "GasCalculator_Attr";
|
$hash->{AttrFn} = "GasCalculator_Attr";
|
||||||
$hash->{NotifyFn} = "GasCalculator_Notify";
|
$hash->{NotifyFn} = "GasCalculator_Notify";
|
||||||
$hash->{NotifyOrderPrefix} = "10-"; # Want to be called before the rest
|
$hash->{NotifyOrderPrefix} = "10-"; # Want to be called before the rest
|
||||||
@ -139,6 +140,29 @@ sub GasCalculator_Attr(@)
|
|||||||
}
|
}
|
||||||
####END####### Handle attributes after changes via fhem GUI ####################################################END#####
|
####END####### Handle attributes after changes via fhem GUI ####################################################END#####
|
||||||
|
|
||||||
|
###START###### Manipulate reading after "set" command by fhem #################################################START####
|
||||||
|
sub GasCalculator_Set($@)
|
||||||
|
{
|
||||||
|
my ( $hash, @a ) = @_;
|
||||||
|
|
||||||
|
### If not enough arguments have been provided
|
||||||
|
if ( @a < 2 )
|
||||||
|
{
|
||||||
|
return "\"set GasCalculator\" needs at least one argument";
|
||||||
|
}
|
||||||
|
|
||||||
|
my $name = shift @a;
|
||||||
|
my $reading = shift @a;
|
||||||
|
my $value = join(" ", @a);
|
||||||
|
my $ReturnMessage;
|
||||||
|
|
||||||
|
### Write current value
|
||||||
|
readingsSingleUpdate($hash, $reading, $value, 1);
|
||||||
|
|
||||||
|
|
||||||
|
return($ReturnMessage);
|
||||||
|
}
|
||||||
|
####END####### Manipulate reading after "set" command by fhem ##################################################END#####
|
||||||
|
|
||||||
###START###### Calculate gas meter values on changed events ###################################################START####
|
###START###### Calculate gas meter values on changed events ###################################################START####
|
||||||
sub GasCalculator_Notify($$)
|
sub GasCalculator_Notify($$)
|
||||||
@ -489,7 +513,6 @@ sub GasCalculator_Notify($$)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
###### Do calculations
|
###### Do calculations
|
||||||
### Calculate DtCurrent (time difference) of previous and current timestamp / [s]
|
### Calculate DtCurrent (time difference) of previous and current timestamp / [s]
|
||||||
my $GasCountReadingTimestampDelta = $GasCountReadingTimestampCurrentRelative - $GasCountReadingTimestampPreviousRelative;
|
my $GasCountReadingTimestampDelta = $GasCountReadingTimestampCurrentRelative - $GasCountReadingTimestampPreviousRelative;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user