mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-09 20:57:11 +00:00
53_GHoma: energy to kWh
git-svn-id: https://svn.fhem.de/fhem/trunk@16234 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
00c5ddfeb5
commit
d7f5239e1b
@ -1,5 +1,7 @@
|
|||||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
||||||
# Do not insert empty lines here, update check depends on it.
|
# Do not insert empty lines here, update check depends on it.
|
||||||
|
- change: 53_GHoma: plugs with energy measurement implemented
|
||||||
|
reading energy now in kWh / SetExtensions / DbLog_splitFn
|
||||||
- change: 93_DbRep: commandref revised
|
- change: 93_DbRep: commandref revised
|
||||||
- change: 93_DbLog: V3.8.5, Parse Event for Zwave changed
|
- change: 93_DbLog: V3.8.5, Parse Event for Zwave changed
|
||||||
- feature: 00_MQTT: new attribute "client-id"
|
- feature: 00_MQTT: new attribute "client-id"
|
||||||
|
@ -105,9 +105,10 @@ sub GHoma_Initialize($) { #
|
|||||||
$hash->{AttrFn} = "GHoma_Attr";
|
$hash->{AttrFn} = "GHoma_Attr";
|
||||||
$hash->{StateFn} = "GHoma_State";
|
$hash->{StateFn} = "GHoma_State";
|
||||||
$hash->{AttrList} = "restoreOnStartup:last,on,off restoreOnReinit:last,on,off blocklocal:yes,no ".
|
$hash->{AttrList} = "restoreOnStartup:last,on,off restoreOnReinit:last,on,off blocklocal:yes,no ".
|
||||||
"allowfrom connectTimeout connectInterval";
|
"allowfrom connectTimeout connectInterval $readingFnAttributes";
|
||||||
$hash->{noAutocreatedFilelog} = 1; # kein Filelog bei Autocreate anlegen
|
$hash->{noAutocreatedFilelog} = 1; # kein Filelog bei Autocreate anlegen
|
||||||
$hash->{ShutdownFn} = "GHoma_Shutdown";
|
$hash->{ShutdownFn} = "GHoma_Shutdown";
|
||||||
|
$hash->{DbLog_splitFn} = "GHoma_DbLog_splitFn";
|
||||||
}
|
}
|
||||||
#####################################
|
#####################################
|
||||||
sub GHoma_ClientConnect($) { # im Mom unnuetz
|
sub GHoma_ClientConnect($) { # im Mom unnuetz
|
||||||
@ -376,7 +377,7 @@ sub GHoma_Read($) { # wird von der globalen loop aufgerufen (ueber $hash->{F
|
|||||||
my $value=$values{unpack('H*',substr($_,19,1))};
|
my $value=$values{unpack('H*',substr($_,19,1))};
|
||||||
if (defined($value)) {
|
if (defined($value)) {
|
||||||
my ($high,$mid,$low)=unpack('CCC',substr($_,21,3));
|
my ($high,$mid,$low)=unpack('CCC',substr($_,21,3));
|
||||||
readingsBulkUpdate($hash, $value, ($high*65536+$mid*256+$low)/100);
|
readingsBulkUpdate($hash, $value, ($high*65536+$mid*256+$low)/($value eq 'energy' ? 1000 : 100));
|
||||||
} else {
|
} else {
|
||||||
# readingsBulkUpdate($hash, 'message_'.unpack('H*',substr($_,19,1)), unpack('H*',substr($_,20)));
|
# readingsBulkUpdate($hash, 'message_'.unpack('H*',substr($_,19,1)), unpack('H*',substr($_,20)));
|
||||||
Log3 $name, 3, "$name unknown control message Id: " . unpack('H*',substr($_,19,1)) . " value: " . unpack('H*',substr($_,20));
|
Log3 $name, 3, "$name unknown control message Id: " . unpack('H*',substr($_,19,1)) . " value: " . unpack('H*',substr($_,20));
|
||||||
@ -503,6 +504,24 @@ sub GHoma_udpbroad {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub GHoma_DbLog_splitFn($) { # Einheiten
|
||||||
|
my ($event) = @_;
|
||||||
|
Log3 undef, 5, "in DbLog_splitFn empfangen: $event";
|
||||||
|
my ($reading, $value, $unit) = "";
|
||||||
|
|
||||||
|
my @parts = split(/ /,$event);
|
||||||
|
$reading = shift @parts;
|
||||||
|
$reading =~ tr/://d;
|
||||||
|
$value = $parts[0];
|
||||||
|
$unit = "W" if(lc($reading) =~ m/power/);
|
||||||
|
$unit = "kWh" if(lc($reading) =~ m/energy/);
|
||||||
|
$unit = "V" if(lc($reading) =~ m/voltage/);
|
||||||
|
$unit = "A" if(lc($reading) =~ m/current/);
|
||||||
|
$unit = "Hz" if(lc($reading) =~ m/frequency/);
|
||||||
|
$unit = "W" if(lc($reading) =~ m/maxpower/);
|
||||||
|
return ($reading, $value, $unit);
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
||||||
=pod
|
=pod
|
||||||
@ -695,4 +714,4 @@ sub GHoma_udpbroad {
|
|||||||
|
|
||||||
=end html_DE
|
=end html_DE
|
||||||
|
|
||||||
=cut
|
=cut
|
Loading…
x
Reference in New Issue
Block a user