mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-28 11:01:59 +00:00
improvement: use makeReadingName
git-svn-id: https://svn.fhem.de/fhem/trunk@24952 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
346d24b41e
commit
c147fd8b6f
@ -84,6 +84,7 @@ BEGIN {
|
|||||||
defs
|
defs
|
||||||
AttrVal
|
AttrVal
|
||||||
ReadingsVal
|
ReadingsVal
|
||||||
|
makeReadingName
|
||||||
))
|
))
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -248,33 +249,38 @@ sub onmessage($$$) {
|
|||||||
Log3($hash->{NAME},5,"calling readingsSingleUpdate($hash->{NAME},$reading,$message,1)");
|
Log3($hash->{NAME},5,"calling readingsSingleUpdate($hash->{NAME},$reading,$message,1)");
|
||||||
readingsSingleUpdate($hash,$reading,$message,1);
|
readingsSingleUpdate($hash,$reading,$message,1);
|
||||||
}
|
}
|
||||||
} elsif ($topic =~ $hash->{'.autoSubscribeExpr'}) {
|
} elsif ($topic =~ m{$hash->{'.autoSubscribeExpr'}}) {
|
||||||
Log3($hash->{NAME},5,"calling readingsSingleUpdate($hash->{NAME},$1,$message,1)");
|
my $rname = $1;
|
||||||
CommandAttr(undef,"$hash->{NAME} subscribeReading_$1 $topic");
|
$rname = makeReadingName($rname);
|
||||||
readingsSingleUpdate($hash,$1,$message,1);
|
return if !defined $rname;
|
||||||
|
Log3($hash->{NAME},5,"calling readingsSingleUpdate($hash->{NAME}, $rname, $message,1)");
|
||||||
|
CommandAttr(undef,"$hash->{NAME} subscribeReading_$rname $topic");
|
||||||
|
readingsSingleUpdate($hash,$rname,$message,1);
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
__END__
|
||||||
|
|
||||||
=pod
|
=pod
|
||||||
=item [device]
|
=item [device]
|
||||||
=item summary MQTT_DEVICE acts as a fhem-device that is mapped to mqtt-topics
|
=item summary MQTT_DEVICE acts as a fhem-device that is mapped to mqtt-topics
|
||||||
=begin html
|
=begin html
|
||||||
|
|
||||||
<a name="MQTT_DEVICE"></a>
|
<a id="MQTT_DEVICE"></a>
|
||||||
<h3>MQTT_DEVICE</h3>
|
<h3>MQTT_DEVICE</h3>
|
||||||
<ul>
|
<ul>
|
||||||
<p>acts as a fhem-device that is mapped to <a href="http://mqtt.org/">mqtt</a>-topics.</p>
|
<p>acts as a fhem-device that is mapped to <a href="http://mqtt.org/">mqtt</a>-topics.</p>
|
||||||
<p>requires a <a href="#MQTT">MQTT</a>-device as IODev<br/>
|
<p>requires a <a href="#MQTT">MQTT</a>-device as IODev<br/>
|
||||||
Note: this module is based on <a href="https://metacpan.org/pod/distribution/Net-MQTT/lib/Net/MQTT.pod">Net::MQTT</a> which needs to be installed from CPAN first.</p>
|
Note: this module is based on <a href="https://metacpan.org/pod/distribution/Net-MQTT/lib/Net/MQTT.pod">Net::MQTT</a> which needs to be installed from CPAN first.</p>
|
||||||
<a name="MQTT_DEVICEdefine"></a>
|
<a id="MQTT_DEVICE-define"></a>
|
||||||
<p><b>Define</b></p>
|
<p><b>Define</b></p>
|
||||||
<ul>
|
<ul>
|
||||||
<p><code>define <name> MQTT_DEVICE</code><br/>
|
<p><code>define <name> MQTT_DEVICE</code><br/>
|
||||||
Specifies the MQTT device.</p>
|
Specifies the MQTT device.</p>
|
||||||
</ul>
|
</ul>
|
||||||
<a name="MQTT_DEVICEset"></a>
|
<a id="MQTT_DEVICE-set"></a>
|
||||||
<p><b>Set</b></p>
|
<p><b>Set</b></p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
@ -292,7 +298,7 @@ sub onmessage($$$) {
|
|||||||
<code>attr mqttest eventMap { dev=>{ 'true'=>'on', 'false'=>'off' }, usr=>{ '^on$'=>'true', '^off$'=>'false' }, fw=>{ '^on$'=>'on', '^off$'=>'off' } }</code></p>
|
<code>attr mqttest eventMap { dev=>{ 'true'=>'on', 'false'=>'off' }, usr=>{ '^on$'=>'true', '^off$'=>'false' }, fw=>{ '^on$'=>'on', '^off$'=>'off' } }</code></p>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<a name="MQTT_DEVICEattr"></a>
|
<a id="MQTT_DEVICE-attr"></a>
|
||||||
<p><b>Attributes</b></p>
|
<p><b>Attributes</b></p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user