# $Id$ #################################################################################################### # # 12_HProtocolTank.pm # # Copyright: Stephan Eisler # Email: fhem.dev@hausautomatisierung.co # # This file is part of fhem. # # Fhem is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # # Fhem is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with fhem. If not, see . # #################################################################################################### package main; sub HProtocolTank_Initialize($) { my ($hash) = @_; $hash->{DefFn} = "HProtocolTank_Define"; $hash->{ParseFn} = "HProtocolTank_Parse"; $hash->{FingerprintFn} = "HProtocolTank_Fingerprint"; $hash->{AttrFn} = "HProtocolGateway_Attr"; $hash->{Match} = "^[a-zA-Z0-9_]+ [a-zA-Z0-9_]+ [+-]*[0-9]+([.][0-9]+)?"; $hash->{AttrList} = "hID " . "sensorSystem:Hectronic,Unitronics,PMS-IB " . "mode:FillLevel,Volume,Ullage " . "product:Diesel,FuelOil,Petrol " . "type " . $readingFnAttributes; } sub HProtocolTank_Define($$) { my ($hash, $def) = @_; my @a = split("[ \t][ \t]*", $def); return "Wrong syntax: use define HProtocolTank " if(int(@a) != 3); my $name = $a[0]; my $gateway = $a[2]; if (!$hash->{IODev}) { AssignIoPort($hash, $gateway); } if (defined($hash->{IODev})) { Log3 $name, 3, "$name: I/O device is " . $hash->{IODev}->{NAME}; } else { Log3 $name, 1, "$name: no I/O device"; } if (defined($hash->{IODev})) { $iodev = $hash->{IODev}->{NAME}; } $hash->{STATE} = "Initialized"; $attr{$name}{room} = "HProtocol"; # TODO This has to be updated when renaming the device. $modules{HProtocolTank}{defptr}{$name} = $hash; # TODO A Tank has to be unregistered when it's removed or renamed. HProtocolGateway_RegisterTank($hash); return undef; } sub HProtocolTank_Parse($$) { my ($iohash, $message) = @_; # $message = " " my @array = split("[ \t][ \t]*", $message); my $tankName = @array[0]; my $reading = @array[1]; my $value = @array[2]; my $hash = $modules{HProtocolTank}{defptr}{$tankName}; readingsSingleUpdate($hash, $reading, $value, 1); return $tankName; } sub HProtocolTank_Fingerprint($$) { # this subroutine is called before running Parse to check if # this message is a duplicate message. Refer to FHEM Wiki. } sub HProtocolTank_Attr (@) { my ($command, $name, $attr, $val) = @_; my $hash = $defs{$name}; my $msg = ''; if ($attr eq 'type') { $attr{$name}{type} = $val; } elsif ($attr eq 'mode') { $attr{$name}{mode} = $val; } elsif ($attr eq 'product') { $attr{$name}{product} = $val; } elsif ($attr eq 'sensorSystem') { $attr{$name}{sensorSystem} = $val; } } 1; =pod =item summary devices communicating via the HProtocolGateway =begin html

HProtocolTank

    The HProtocolTank is a fhem module defines a device connected to a HProtocolGateway.


    Define
      define <name> HProtocolTank HProtocolGateway
      attr <name> hID 01
      attr <name> sensorSystem Hectronic
      attr <name> product FuelOil

      Defines an HProtocolTank connected to a HProtocolGateway.


    Readings
    • ullage
      0..999999 Ullage in litres
    • filllevel
      0..99999 Fill level in cm
    • volume
      0..999999 Volume in litres
    • volume_15C
      0..999999 Volume in litres at 15 °C
    • temperature
      -999 - +999 Temperature in °C
    • waterlevel
      0..9999 Water level in mm
    • probe_offset
      -9999 - +9999 Probe offset in mm
    • version
      00..999 Software version
    • error
      0..9 00.. Probe error

    Attributes
    • hID
      01 - 32 Tank Number / Tank Address (99 for testing only)
    • sensorSystem
      Sensor System / Hectronic, Unitronics, PMS-IB
    • mode
      Mode / FillLevel, Volume, Ullage
    • type
      Type / Strapping Table csv
    • product
      Product / Diesel, FuelOil, Petrol


    strapping table csv

    level,volume
    10,16
    520,7781
    1330,29105
    1830,43403
    2070,49844
    2220,53580
    2370,57009
    2400,57650
    2430,58275
    2370,57009
    2400,57650
    2430,58275

=end html =cut