mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-25 03:39:21 +00:00
10_MQTT2_DEVICE.pm: add subscriptions Reading (Forum #104992)
git-svn-id: https://svn.fhem.de/fhem/trunk@20448 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
1e417b3fcf
commit
adf7b8b46f
@ -7,6 +7,8 @@ use warnings;
|
|||||||
use SetExtensions;
|
use SetExtensions;
|
||||||
|
|
||||||
my $bridgeTimerStarted;
|
my $bridgeTimerStarted;
|
||||||
|
my $subscrCheckTimerStarted;
|
||||||
|
sub zigbee2mqtt_devStateIcon255($;$$);
|
||||||
|
|
||||||
sub
|
sub
|
||||||
MQTT2_DEVICE_Initialize($)
|
MQTT2_DEVICE_Initialize($)
|
||||||
@ -82,9 +84,33 @@ MQTT2_DEVICE_Define($$)
|
|||||||
$bridgeTimerStarted = 1;
|
$bridgeTimerStarted = 1;
|
||||||
|
|
||||||
AssignIoPort($hash, $ioname);
|
AssignIoPort($hash, $ioname);
|
||||||
|
|
||||||
|
if($init_done) {
|
||||||
|
MQTT2_DEVICE_checkSubscr();
|
||||||
|
} elsif(!$subscrCheckTimerStarted) {
|
||||||
|
$subscrCheckTimerStarted = 1;
|
||||||
|
InternalTimer(time()+60, "MQTT2_DEVICE_checkSubscr", undef, 0);
|
||||||
|
}
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Set the subscriptions reading from the corresponding MQTT2_SERVER connection
|
||||||
|
sub
|
||||||
|
MQTT2_DEVICE_checkSubscr()
|
||||||
|
{
|
||||||
|
$subscrCheckTimerStarted = 0;
|
||||||
|
my %conn;
|
||||||
|
for my $c (devspec2array("TYPE=MQTT2_SERVER")) {
|
||||||
|
if($defs{$c} && $defs{$c}{cid} && $defs{$c}{subscriptions}) {
|
||||||
|
$conn{$defs{$c}{cid}} = join(" ", sort keys %{$defs{$c}{subscriptions}});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for my $dev (devspec2array("TYPE=MQTT2_DEVICE")) {
|
||||||
|
next if(!$defs{$dev}{CID} || !$conn{$defs{$dev}{CID}});
|
||||||
|
readingsSingleUpdate($defs{$dev},"subscriptions",$conn{$defs{$dev}{CID}},0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#############################
|
#############################
|
||||||
sub
|
sub
|
||||||
MQTT2_DEVICE_Parse($$)
|
MQTT2_DEVICE_Parse($$)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user