Code by B.M.
git-svn-id: https://svn.fhem.de/fhem/trunk@816 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
@@ -17,6 +17,7 @@ LIRC_Initialize($)
|
|||||||
|
|
||||||
# Provider
|
# Provider
|
||||||
$hash->{ReadFn} = "LIRC_Read";
|
$hash->{ReadFn} = "LIRC_Read";
|
||||||
|
$hash->{ReadyFn} = "LIRC_Ready";
|
||||||
$hash->{Clients} = ":LIRC:";
|
$hash->{Clients} = ":LIRC:";
|
||||||
|
|
||||||
# Consumer
|
# Consumer
|
||||||
@@ -33,13 +34,14 @@ LIRC_Define($$)
|
|||||||
|
|
||||||
$hash->{STATE} = "Initialized";
|
$hash->{STATE} = "Initialized";
|
||||||
|
|
||||||
|
$hash->{LircObj}->clean_up() if($hash->{LircObj});
|
||||||
delete $hash->{LircObj};
|
delete $hash->{LircObj};
|
||||||
delete $hash->{FD};
|
delete $hash->{FD};
|
||||||
|
|
||||||
my $name = $a[0];
|
my $name = $a[0];
|
||||||
my $config = $a[2];
|
my $config = $a[2];
|
||||||
|
|
||||||
Log 3, "LIRC opening LIRC device $config";
|
Log 3, "LIRC opening $name device $config";
|
||||||
my $lirc = Lirc::Client->new({
|
my $lirc = Lirc::Client->new({
|
||||||
prog => 'fhem',
|
prog => 'fhem',
|
||||||
rcfile => "$config",
|
rcfile => "$config",
|
||||||
@@ -53,9 +55,11 @@ LIRC_Define($$)
|
|||||||
$select->add( $lirc->sock );
|
$select->add( $lirc->sock );
|
||||||
|
|
||||||
$hash->{LircObj} = $lirc;
|
$hash->{LircObj} = $lirc;
|
||||||
$hash->{FD} = $lirc->sock;
|
|
||||||
$selectlist{"$name.$config"} = $hash;
|
$hash->{FD} = $lirc->{sock}; # is not working and sets timeout to undefined
|
||||||
$hash->{SelectObj} = $select;
|
$selectlist{"$name"} = $hash; #
|
||||||
|
$readyfnlist{"$name"} = $hash; # thats why we start polling
|
||||||
|
$hash->{SelectObj} = $select;
|
||||||
$hash->{DeviceName} = $name;
|
$hash->{DeviceName} = $name;
|
||||||
$hash->{STATE} = "Opened";
|
$hash->{STATE} = "Opened";
|
||||||
|
|
||||||
@@ -68,7 +72,10 @@ LIRC_Undef($$)
|
|||||||
{
|
{
|
||||||
my ($hash, $arg) = @_;
|
my ($hash, $arg) = @_;
|
||||||
|
|
||||||
$hash->{LircObj}->close() if($hash->{LircObj});
|
$hash->{LircObj}->clean_up() if($hash->{LircObj});
|
||||||
|
delete $hash->{LircObj};
|
||||||
|
delete $hash->{FD};
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,11 +92,22 @@ LIRC_Read($)
|
|||||||
# an ir event has been received (if you are tracking other filehandles, you need to make sure it is lirc)
|
# an ir event has been received (if you are tracking other filehandles, you need to make sure it is lirc)
|
||||||
my @codes = $lirc->next_codes; # should not block
|
my @codes = $lirc->next_codes; # should not block
|
||||||
for my $code (@codes){
|
for my $code (@codes){
|
||||||
Log 3, "LIRC code: $code\n";
|
Log 3, "LIRC $code toggle";
|
||||||
DoTrigger($code, "toggle");
|
DoTrigger($code, "toggle");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#####################################
|
||||||
|
sub
|
||||||
|
LIRC_Ready($)
|
||||||
|
{
|
||||||
|
my ($hash) = @_;
|
||||||
|
|
||||||
|
my $select= $hash->{SelectObj};
|
||||||
|
|
||||||
|
return $select->can_read(0);
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -2233,51 +2233,64 @@ A line ending with \ will be concatenated with the next one, so long lines
|
|||||||
<ul>
|
<ul>
|
||||||
<code>define <name> CUL_HM <6-digit-hex-code></code>
|
<code>define <name> CUL_HM <6-digit-hex-code></code>
|
||||||
<br><br>
|
<br><br>
|
||||||
Try to avoid this command with the <a href="#autocreate">autocreate</a>
|
Normally this command is generated by the <a
|
||||||
module enabled. Now you have two possibilities, both as a set command to
|
href="#autocreate">autocreate</a> module, together with the necessary
|
||||||
the corresponding CUL device: <a href="#CULset">hmPairForSec</a> and
|
hmClass and subType attributes. Usually you issue a <a
|
||||||
<a href="#CULset">hmPairSerial</a>.
|
href="#CULset">hmPairForSec</a> command and press the corresponding button
|
||||||
<br>
|
on the device to be paired, or issue a <a href="#CULset">hmPairSerial</a>
|
||||||
If a device was not paired with the CUL, then it won't know its subType,
|
set command if the device is a receiver and you know its serial number.
|
||||||
and therefore won't be able to interpret device messages correctly.
|
Autocreate will then create a fhem device and set all necessary attributes.
|
||||||
|
<br><br>
|
||||||
|
If you cannot use autocreate, then you have to specify:<br>
|
||||||
|
<ul>
|
||||||
|
<li>the <6-digit-hex-code><br>
|
||||||
|
which is the hardcoded address of the device (no, you cannot choose
|
||||||
|
it arbitrarily like for FS20 devices). You may detect it by
|
||||||
|
inspecting the fhem log.
|
||||||
|
<li>the hmClass attribute<br>
|
||||||
|
which is either sender or receiver
|
||||||
|
<li>the subType attribute<br>
|
||||||
|
which is one of switch dimmer blindActuator remote sensor swi
|
||||||
|
pushButton threeStateSensor motionDetector keyMatic winMatic
|
||||||
|
smokeDetector<br>
|
||||||
|
Without these attributes fhem won't be able to decode device messages
|
||||||
|
appropriately.
|
||||||
|
|
||||||
|
</ul>
|
||||||
</ul><br>
|
</ul><br>
|
||||||
|
|
||||||
<a name="CUL_HMset"></a>
|
<a name="CUL_HMset"></a>
|
||||||
<b>Set</b>
|
<b>Set</b>
|
||||||
<ul>
|
<ul>
|
||||||
General commands (available to all hm devices):
|
Note: devices which are normally send-only (remote/sensor/etc) must be set
|
||||||
|
into pairing/learning mode in order to receive the following commands.
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
General commands (available to most hm devices):
|
||||||
<ul>
|
<ul>
|
||||||
<li>raw <data> ...<br>
|
<li>statusRequest<br>
|
||||||
Only needed for experimentation.
|
Send a status request to the device.
|
||||||
send a list of "raw" commands. The first command will be immediately
|
|
||||||
sent, the next one after the previous one is acked by the target. The
|
|
||||||
length will be computed automatically, and the message counter will be
|
|
||||||
incremented if the first tw charcters are ++.
|
|
||||||
Example (enable AES):<pre>
|
|
||||||
set hm1 raw ++A001F100001234560105000000001\
|
|
||||||
++A001F10000123456010802010AF10B000C00\
|
|
||||||
++A001F1000012345601080801\
|
|
||||||
++A001F100001234560106<pre>
|
|
||||||
</li>
|
</li>
|
||||||
<li>reset<br>
|
<li>reset<br>
|
||||||
Factory reset the device. You need to pair it again to use it.
|
Factory reset the device. You need to pair it again to use it with
|
||||||
|
fhem.
|
||||||
</li>
|
</li>
|
||||||
<li>pair<br>
|
<li>pair<br>
|
||||||
Pair the device again with its known serialNumber
|
Pair the device again with its known serialNumber (e.g. after a device
|
||||||
</li>
|
reset). </li>
|
||||||
<li>statusRequest<br>
|
|
||||||
Send a statusRequest to the device.
|
|
||||||
</li>
|
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
<br>
|
||||||
subType (i.e family) dependent commands:
|
subType (i.e family) dependent commands:
|
||||||
<ul>
|
<ul>
|
||||||
|
<br>
|
||||||
<li>switch
|
<li>switch
|
||||||
<ul>
|
<ul>
|
||||||
<li>on [forSec] - set the switch on</li>
|
<li>on [forSec] - set the switch on</li>
|
||||||
<li>off - set the switch off</li>
|
<li>off - set the switch off</li>
|
||||||
<li>toggle - toggle the switch.</li>
|
<li>toggle - toggle the switch.</li>
|
||||||
</ul></li>
|
</ul></li>
|
||||||
|
<br>
|
||||||
<li>dimmer, blindActuator
|
<li>dimmer, blindActuator
|
||||||
<ul>
|
<ul>
|
||||||
<li>0 - 100 with a resolution of 0.5:<br>
|
<li>0 - 100 with a resolution of 0.5:<br>
|
||||||
@@ -2285,6 +2298,7 @@ A line ending with \ will be concatenated with the next one, so long lines
|
|||||||
<li>on / off<br>
|
<li>on / off<br>
|
||||||
this corresponds to 100 or 0 %.
|
this corresponds to 100 or 0 %.
|
||||||
</ul></li>
|
</ul></li>
|
||||||
|
<br>
|
||||||
<li>4Dis (HM-PB-4DIS-WM)
|
<li>4Dis (HM-PB-4DIS-WM)
|
||||||
<ul>
|
<ul>
|
||||||
<li>text <btn_no> [on|off] <text1> <text2><br>
|
<li>text <btn_no> [on|off] <text1> <text2><br>
|
||||||
@@ -2298,6 +2312,23 @@ A line ending with \ will be concatenated with the next one, so long lines
|
|||||||
</ul>
|
</ul>
|
||||||
</ul></li>
|
</ul></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
Debugging:
|
||||||
|
<ul>
|
||||||
|
<li>raw <data> ...<br>
|
||||||
|
Only needed for experimentation.
|
||||||
|
send a list of "raw" commands. The first command will be immediately
|
||||||
|
sent, the next one after the previous one is acked by the target. The
|
||||||
|
length will be computed automatically, and the message counter will be
|
||||||
|
incremented if the first tw charcters are ++.
|
||||||
|
Example (enable AES):<pre>
|
||||||
|
set hm1 raw ++A001F100001234560105000000001\
|
||||||
|
++A001F10000123456010802010AF10B000C00\
|
||||||
|
++A001F1000012345601080801\
|
||||||
|
++A001F100001234560106<pre>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
</ul><br>
|
</ul><br>
|
||||||
|
|
||||||
<a name="CUL_HMget"></a>
|
<a name="CUL_HMget"></a>
|
||||||
@@ -3054,12 +3085,32 @@ A line ending with \ will be concatenated with the next one, so long lines
|
|||||||
<a name="LIRC"></a>
|
<a name="LIRC"></a>
|
||||||
<h3>LIRC</h3>
|
<h3>LIRC</h3>
|
||||||
<ul>
|
<ul>
|
||||||
|
Can use infrared signals received by an lirc device as toggle events.
|
||||||
|
<br>
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<a name="LIRCdefine"></a>
|
<a name="LIRCdefine"></a>
|
||||||
<b>Define</b>
|
<b>Define</b>
|
||||||
<ul>
|
<ul>
|
||||||
<code>define <name> LIRC <device></code>
|
define <name> LIRC <lircrc_file><br>
|
||||||
|
Example:<br>
|
||||||
|
<ul>
|
||||||
|
define Lirc LIRC /etc/lirc/lircrc
|
||||||
|
</ul>
|
||||||
|
Note: In the lirc configuration file you have to define each possible event.
|
||||||
|
If you have this configuration
|
||||||
|
<pre>
|
||||||
|
begin
|
||||||
|
prog = fhem
|
||||||
|
button = pwr
|
||||||
|
config = IrPower
|
||||||
|
end</pre>
|
||||||
|
and you press the pwr button the IrPower toggle event occures at fhem.
|
||||||
|
<pre>
|
||||||
|
define IrPower01 notify IrPower set lamp toggle</pre>
|
||||||
|
turns the lamp on and off.
|
||||||
|
If you want a faster reaction to keypresses you have to change the
|
||||||
|
defaultvalue of readytimeout from 5 seconds to e.g. 1 second in fhem.pl
|
||||||
</ul>
|
</ul>
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user