mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-06 12:46:57 +00:00
PRESENCE: support custom readings via presenced/lepresenced/collectord (Forum: #54482)
git-svn-id: https://svn.fhem.de/fhem/trunk@12344 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
886eebf38f
commit
46fbb44dbe
@ -444,7 +444,7 @@ PRESENCE_Read($)
|
|||||||
{
|
{
|
||||||
Log3 $name, 5, "PRESENCE ($name) - received data: $line";
|
Log3 $name, 5, "PRESENCE ($name) - received data: $line";
|
||||||
|
|
||||||
if($line =~ /^absence|absent$/)
|
if($line =~ /^absence|absent/)
|
||||||
{
|
{
|
||||||
if(!$hash->{helper}{DISABLED} and $hash->{helper}{CURRENT_TIMEOUT} eq "present" and $hash->{TIMEOUT_NORMAL} != $hash->{TIMEOUT_PRESENT})
|
if(!$hash->{helper}{DISABLED} and $hash->{helper}{CURRENT_TIMEOUT} eq "present" and $hash->{TIMEOUT_NORMAL} != $hash->{TIMEOUT_PRESENT})
|
||||||
{
|
{
|
||||||
@ -453,7 +453,15 @@ PRESENCE_Read($)
|
|||||||
DevIo_SimpleWrite($hash, $hash->{ADDRESS}."|".$hash->{TIMEOUT_NORMAL}."\n", 2);
|
DevIo_SimpleWrite($hash, $hash->{ADDRESS}."|".$hash->{TIMEOUT_NORMAL}."\n", 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
PRESENCE_ProcessState($hash, "absent") unless($hash->{helper}{DISABLED});
|
unless($hash->{helper}{DISABLED})
|
||||||
|
{
|
||||||
|
PRESENCE_ProcessState($hash, "absent");
|
||||||
|
|
||||||
|
if($line=~ /^[^;]+;(.+)$/)
|
||||||
|
{
|
||||||
|
PRESENCE_ProcessAddonData($hash, $1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
elsif($line =~ /present;(.+?)$/)
|
elsif($line =~ /present;(.+?)$/)
|
||||||
{
|
{
|
||||||
@ -467,15 +475,23 @@ PRESENCE_Read($)
|
|||||||
unless($hash->{helper}{DISABLED})
|
unless($hash->{helper}{DISABLED})
|
||||||
{
|
{
|
||||||
PRESENCE_ProcessState($hash, "present");
|
PRESENCE_ProcessState($hash, "present");
|
||||||
|
my $data = $1;
|
||||||
|
|
||||||
if($1 =~ /^(.*);(.+)$/)
|
if($data =~ /\S=\S/)
|
||||||
{
|
{
|
||||||
readingsBulkUpdate($hash, "room", $2);
|
PRESENCE_ProcessAddonData($hash, $data);
|
||||||
readingsBulkUpdate($hash, "device_name", $1);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
readingsBulkUpdate($hash, "device_name", $1);
|
if($1 =~ /^(.*);(.+)$/)
|
||||||
|
{
|
||||||
|
readingsBulkUpdate($hash, "room", $2);
|
||||||
|
readingsBulkUpdate($hash, "device_name", $1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
readingsBulkUpdate($hash, "device_name", $1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1153,6 +1169,19 @@ PRESENCE_ProcessState($$)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub PRESENCE_ProcessAddonData($$)
|
||||||
|
{
|
||||||
|
my ($hash, $data) = @_;
|
||||||
|
|
||||||
|
my ($a, $h) = parseParams($data, ";");
|
||||||
|
|
||||||
|
foreach my $key (sort keys %{$h})
|
||||||
|
{
|
||||||
|
readingsBulkUpdate($hash, $key, $h->{$key}) if(defined($h->{$key}));
|
||||||
|
}
|
||||||
|
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
1;
|
1;
|
||||||
|
|
||||||
=pod
|
=pod
|
||||||
|
Loading…
x
Reference in New Issue
Block a user