mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
36_EleroDrive: support for two sticks
git-svn-id: https://svn.fhem.de/fhem/trunk@15168 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
ddc3bfddad
commit
0fb542107e
@ -1,10 +1,5 @@
|
|||||||
# $Id$
|
# $Id$
|
||||||
|
|
||||||
# ToDo-List
|
|
||||||
# ---------
|
|
||||||
# [ ] Move to any position, not only top, bottom, intermediate, ...
|
|
||||||
|
|
||||||
|
|
||||||
package main;
|
package main;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
@ -51,7 +46,19 @@ sub EleroDrive_Define($$) {
|
|||||||
|
|
||||||
$modules{EleroDrive}{defptr}{$channel} = $hash;
|
$modules{EleroDrive}{defptr}{$channel} = $hash;
|
||||||
|
|
||||||
|
my $ioDev = undef;
|
||||||
|
my @parts = split("_", $devName);
|
||||||
|
if(@parts == 3) {
|
||||||
|
$ioDev = $parts[1];
|
||||||
|
}
|
||||||
|
if($ioDev) {
|
||||||
|
AssignIoPort($hash, $ioDev);
|
||||||
|
}
|
||||||
|
else {
|
||||||
AssignIoPort($hash);
|
AssignIoPort($hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if(defined($hash->{IODev}->{NAME})) {
|
if(defined($hash->{IODev}->{NAME})) {
|
||||||
Log3 $devName, 4, "$devName: I/O device is " . $hash->{IODev}->{NAME};
|
Log3 $devName, 4, "$devName: I/O device is " . $hash->{IODev}->{NAME};
|
||||||
}
|
}
|
||||||
@ -214,6 +221,24 @@ sub EleroDrive_Parse($$) {
|
|||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
my $buffer = $msg;
|
my $buffer = $msg;
|
||||||
|
|
||||||
|
# aa054d00010102 : channel 1 top
|
||||||
|
# aa054d00010202 : channel 1 bottom
|
||||||
|
# aa054d00020102 : channel 2 top
|
||||||
|
# aa054d00020202 : channel 2 bottom
|
||||||
|
# aa 05 4d 00 01 01 02
|
||||||
|
# ----- -- -- -- -- --
|
||||||
|
# | | | | | |
|
||||||
|
# | | | | | Checksum
|
||||||
|
# | | | | State (top, bottom, ...)
|
||||||
|
# | | | Lower channel bits (1 - 8)
|
||||||
|
# | | Upper channel bits (9 - 15)
|
||||||
|
# | 4d = Easy_Ack (answer on Easy_Send or Easy_Info)
|
||||||
|
# Fix aa 05
|
||||||
|
# State: 0x01 = top
|
||||||
|
# 0x02 = bottom
|
||||||
|
# 0x03 = intermediate
|
||||||
|
# 0x04 = tilt
|
||||||
|
|
||||||
# get the channel
|
# get the channel
|
||||||
my $firstChannels = substr($buffer,6,2);
|
my $firstChannels = substr($buffer,6,2);
|
||||||
my $secondChannels = substr($buffer,8,2);
|
my $secondChannels = substr($buffer,8,2);
|
||||||
@ -237,7 +262,24 @@ sub EleroDrive_Parse($$) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
my $rhash = $modules{EleroDrive}{defptr}{$channel};
|
my $rhash = undef;
|
||||||
|
|
||||||
|
foreach my $d (keys %defs) {
|
||||||
|
my $h = $defs{$d};
|
||||||
|
my $type = $h->{TYPE};
|
||||||
|
if($type eq "EleroDrive") {
|
||||||
|
if (defined($h->{IODev}->{NAME})) {
|
||||||
|
my $ioDev = $h->{IODev}->{NAME};
|
||||||
|
my $def = $h->{DEF};
|
||||||
|
if ($ioDev eq $name && $def eq $channel) {
|
||||||
|
$rhash = $h;
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if($rhash) {
|
||||||
my $rname = $rhash->{NAME};
|
my $rname = $rhash->{NAME};
|
||||||
|
|
||||||
# get status
|
# get status
|
||||||
@ -284,7 +326,6 @@ sub EleroDrive_Parse($$) {
|
|||||||
my $newstate = $deviceStati{$statusByte};
|
my $newstate = $deviceStati{$statusByte};
|
||||||
my $percentClosed = $percentDefinitions{$statusByte};
|
my $percentClosed = $percentDefinitions{$statusByte};
|
||||||
|
|
||||||
if($modules{EleroDrive}{defptr}{$channel}) {
|
|
||||||
readingsBeginUpdate($rhash);
|
readingsBeginUpdate($rhash);
|
||||||
readingsBulkUpdate($rhash, "state", $newstate);
|
readingsBulkUpdate($rhash, "state", $newstate);
|
||||||
readingsBulkUpdate($rhash, "position", $newstate);
|
readingsBulkUpdate($rhash, "position", $newstate);
|
||||||
@ -298,7 +339,7 @@ sub EleroDrive_Parse($$) {
|
|||||||
return @list;
|
return @list;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return "UNDEFINED EleroDrive_$channel EleroDrive $channel";
|
return "UNDEFINED EleroDrive_" . $name . "_" . $channel . " EleroDrive " . $channel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user