mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-24 15:19: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->{DefFn} = "GasCalculator_Define";
|
||||
$hash->{UndefFn} = "GasCalculator_Undefine";
|
||||
$hash->{SetFn} = "GasCalculator_Set";
|
||||
$hash->{AttrFn} = "GasCalculator_Attr";
|
||||
$hash->{NotifyFn} = "GasCalculator_Notify";
|
||||
$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#####
|
||||
|
||||
###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####
|
||||
sub GasCalculator_Notify($$)
|
||||
@ -488,7 +512,6 @@ sub GasCalculator_Notify($$)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
###### Do calculations
|
||||
### Calculate DtCurrent (time difference) of previous and current timestamp / [s]
|
||||
|
Loading…
x
Reference in New Issue
Block a user