Vielleicht hilft es weiter - hatte mal was ähnliches angefangen für OpenMQTTGateway:
Es wird alles in ein MQTT2_DEVICE gepiped, das von den unterschiedlichen ESP's für einen BT-Tag empfangen wird:
define OMG_FFFFC424A12B MQTT2_DEVICE FFFFC424A12B
attr OMG_FFFFC424A12B userattr maxPresenceAge maxReadingsAge
attr OMG_FFFFC424A12B IODev MQTT2_FHEM_Server
attr OMG_FFFFC424A12B autocreate 0
attr OMG_FFFFC424A12B icon rfid_tag
attr OMG_FFFFC424A12B maxPresenceAge 1200
attr OMG_FFFFC424A12B maxReadingsAge 100000
attr OMG_FFFFC424A12B model OpenMQTTGateway_BT_gtag
attr OMG_FFFFC424A12B readingList home/(O[^/]*M[^/]*G[^/]*)/BTtoMQTT/FFFFC424A12B:.* { $TOPIC =~ m,home/(O[^/]*M[^/]*G[^/]*)/BTtoMQTT,;; json2nameValue($EVENT, "${1}_") }\
home/(O[^/]*M[^/]*G[^/]*)/BTtoMQTT/FFFFC424A12B:.* { $TOPIC =~ m,home/(O[^/]*M[^/]*G[^/]*)/BTtoMQTT,;; {"last_IO"=>"$1"}}
attr OMG_FFFFC424A12B room Steuerung->Interfaces
attr OMG_FFFFC424A12B stateFormat Last IO: last_IO
attr OMG_FFFFC424A12B userReadings bestRecentGW:.*_rssi.* {identifyMyBestGW($name)}
PRESENCE auch via function:
define FFFFC424A12B_presence PRESENCE function { my $maxage = AttrVal("OMG_FFFFC424A12B","maxPresenceAge","300");;;; ReadingsAge("OMG_FFFFC424A12B","Last_IO","100000") < $maxage ? 1 : 0 }
Und hier noch die myUtils für das Ermitteln des "besten IO's":
sub identifyMyBestGW {
my $name = shift;
my $maxReadingsAge = shift // AttrVal($name,"maxReadingsAge",600);
my $hash = $defs{$name};
my @rssis = grep { $_ =~ /.*_rssi/ } sort keys %{ $hash->{READINGS} };
my $bestGW = "unknown";
my $bestGWold = ReadingsVal($name,"bestRecentGW","unknownGW");
my $bestRSSI = -1000;
my $currentRSSI = 0;
for (@rssis) {
if (ReadingsAge($name,$_,100) < $maxReadingsAge) {
$currentRSSI = ReadingsVal($name,$_,-1100);
if ($currentRSSI > $bestRSSI) {
$bestRSSI = $currentRSSI ;
$bestGW = $_;
}
}
}
$bestGW =~ s/_.*//g;
return $bestGW ne $bestGWold ? $bestGW : undef;
}