mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-01 20:20:10 +00:00
Code by B.M.
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@816 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
5d02951e65
commit
3da333ced1
@ -17,6 +17,7 @@ LIRC_Initialize($)
|
||||
|
||||
# Provider
|
||||
$hash->{ReadFn} = "LIRC_Read";
|
||||
$hash->{ReadyFn} = "LIRC_Ready";
|
||||
$hash->{Clients} = ":LIRC:";
|
||||
|
||||
# Consumer
|
||||
@ -33,13 +34,14 @@ LIRC_Define($$)
|
||||
|
||||
$hash->{STATE} = "Initialized";
|
||||
|
||||
$hash->{LircObj}->clean_up() if($hash->{LircObj});
|
||||
delete $hash->{LircObj};
|
||||
delete $hash->{FD};
|
||||
|
||||
my $name = $a[0];
|
||||
my $config = $a[2];
|
||||
|
||||
Log 3, "LIRC opening LIRC device $config";
|
||||
Log 3, "LIRC opening $name device $config";
|
||||
my $lirc = Lirc::Client->new({
|
||||
prog => 'fhem',
|
||||
rcfile => "$config",
|
||||
@ -53,9 +55,11 @@ LIRC_Define($$)
|
||||
$select->add( $lirc->sock );
|
||||
|
||||
$hash->{LircObj} = $lirc;
|
||||
$hash->{FD} = $lirc->sock;
|
||||
$selectlist{"$name.$config"} = $hash;
|
||||
$hash->{SelectObj} = $select;
|
||||
|
||||
$hash->{FD} = $lirc->{sock}; # is not working and sets timeout to undefined
|
||||
$selectlist{"$name"} = $hash; #
|
||||
$readyfnlist{"$name"} = $hash; # thats why we start polling
|
||||
$hash->{SelectObj} = $select;
|
||||
$hash->{DeviceName} = $name;
|
||||
$hash->{STATE} = "Opened";
|
||||
|
||||
@ -68,7 +72,10 @@ LIRC_Undef($$)
|
||||
{
|
||||
my ($hash, $arg) = @_;
|
||||
|
||||
$hash->{LircObj}->close() if($hash->{LircObj});
|
||||
$hash->{LircObj}->clean_up() if($hash->{LircObj});
|
||||
delete $hash->{LircObj};
|
||||
delete $hash->{FD};
|
||||
|
||||
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)
|
||||
my @codes = $lirc->next_codes; # should not block
|
||||
for my $code (@codes){
|
||||
Log 3, "LIRC code: $code\n";
|
||||
Log 3, "LIRC $code toggle";
|
||||
DoTrigger($code, "toggle");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#####################################
|
||||
sub
|
||||
LIRC_Ready($)
|
||||
{
|
||||
my ($hash) = @_;
|
||||
|
||||
my $select= $hash->{SelectObj};
|
||||
|
||||
return $select->can_read(0);
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -2233,51 +2233,64 @@ A line ending with \ will be concatenated with the next one, so long lines
|
||||
<ul>
|
||||
<code>define <name> CUL_HM <6-digit-hex-code></code>
|
||||
<br><br>
|
||||
Try to avoid this command with the <a href="#autocreate">autocreate</a>
|
||||
module enabled. Now you have two possibilities, both as a set command to
|
||||
the corresponding CUL device: <a href="#CULset">hmPairForSec</a> and
|
||||
<a href="#CULset">hmPairSerial</a>.
|
||||
<br>
|
||||
If a device was not paired with the CUL, then it won't know its subType,
|
||||
and therefore won't be able to interpret device messages correctly.
|
||||
Normally this command is generated by the <a
|
||||
href="#autocreate">autocreate</a> module, together with the necessary
|
||||
hmClass and subType attributes. Usually you issue a <a
|
||||
href="#CULset">hmPairForSec</a> command and press the corresponding button
|
||||
on the device to be paired, or issue a <a href="#CULset">hmPairSerial</a>
|
||||
set command if the device is a receiver and you know its serial number.
|
||||
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>
|
||||
|
||||
<a name="CUL_HMset"></a>
|
||||
<b>Set</b>
|
||||
<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>
|
||||
<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>statusRequest<br>
|
||||
Send a status request to the device.
|
||||
</li>
|
||||
<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>pair<br>
|
||||
Pair the device again with its known serialNumber
|
||||
</li>
|
||||
<li>statusRequest<br>
|
||||
Send a statusRequest to the device.
|
||||
</li>
|
||||
|
||||
Pair the device again with its known serialNumber (e.g. after a device
|
||||
reset). </li>
|
||||
</ul>
|
||||
<br>
|
||||
subType (i.e family) dependent commands:
|
||||
<ul>
|
||||
<br>
|
||||
<li>switch
|
||||
<ul>
|
||||
<li>on [forSec] - set the switch on</li>
|
||||
<li>off - set the switch off</li>
|
||||
<li>toggle - toggle the switch.</li>
|
||||
</ul></li>
|
||||
<br>
|
||||
<li>dimmer, blindActuator
|
||||
<ul>
|
||||
<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>
|
||||
this corresponds to 100 or 0 %.
|
||||
</ul></li>
|
||||
<br>
|
||||
<li>4Dis (HM-PB-4DIS-WM)
|
||||
<ul>
|
||||
<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></li>
|
||||
</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>
|
||||
|
||||
<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>
|
||||
<h3>LIRC</h3>
|
||||
<ul>
|
||||
Can use infrared signals received by an lirc device as toggle events.
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<a name="LIRCdefine"></a>
|
||||
<b>Define</b>
|
||||
<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>
|
||||
<br>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user