Hi,
da ich mein FHEM 6.4 auf Bookworm aufgesetzt habe, bin ich über die Tatsache gestolpert, dass die acht Ausgänge per Default als Eingänge genutzt werden, d.h. man muss erst
gpio -x mcp23s17:200:0:0 mode 200 out
....
gpio -x mcp23s17:200:0:0 mode 207 out
Ich hätte das 50_Piface.pm nun so erweitert, dass man per Config und Attribut dies erledigen kann.
Vielleicht wäre das für die Allgemeinheit wichtig, da ich sehr lange gesucht hatte.
Momentan funktioniert es leider noch nicht per fhem.cfg, erst wenn man es händisch oben in die Befehlsleiste der Weboberfläche eingibt. Vielleicht findet noch einer einen Fehler.
Add PIFACE_Initialize
" portInOut0:in,out" .
" portInOut1:in,out" .
" portInOut2:in,out" .
" portInOut3:in,out" .
" portInOut4:in,out" .
" portInOut5:in,out" .
" portInOut6:in,out" .
" portInOut7:in,out" .
Add PIFACE_Attr
elsif ($attrName =~ m/^portInOut/) {
my $port = substr($attrName, 9, 1);
my $adr = $base + $port;
my $portInOut = $attrVal;
my $val;
$portInOut = "in" if (!defined $attrVal);
if ($attrVal !~ m/^(in|out)$/) {
$portInOut = "in" ;
Log3($name, 3, "PIFACE $name attribute-value [$attrName] = $attrVal wrong");
CommandDeleteAttr(undef, "$name $port");
}
$cmd = "$gpioCmd -p mode $adr $portInOut";
$val = `$cmd`;
$cmd = "$gpioCmd -p read $adr";
$val = `$cmd`;
$val =~ s/\n//g;
$val =~ s/\r//g;
readingsSingleUpdate($hash, 'in' . $port, $val, 1);
}
Add fhem.cfg
define Mypiface PIFACE
attr Mypiface defaultState off
attr Mypiface pollInterval 1
attr Mypiface portMode0 up
attr Mypiface portMode1 up
attr Mypiface portMode2 up
attr Mypiface portMode3 up
attr Mypiface portMode4 up
attr Mypiface portMode5 up
attr Mypiface portMode6 up
attr Mypiface portMode7 up
attr Mypiface portInOut0 out
attr Mypiface portInOut1 out
attr Mypiface portInOut2 out
attr Mypiface portInOut3 out
attr Mypiface portInOut4 out
attr Mypiface portInOut5 out
attr Mypiface portInOut6 out
attr Mypiface portInOut7 out
portInOut scheint - warum auch immer - über die fhem.cfg nicht zu funktionieren, über die Kommandoleiste schon. Vielleicht hat noch einer eine Idee.
Weiterhin wäre es nice, wenn man beim Modul vielleicht aus das Github Projekt WiringPi verweisen kann. Dies zu finden ist auch nicht so einfach.
https://github.com/WiringPi/WiringPi/releases/download/x.yy/wiringpi_x.yy_zzzzz.deb
sudo apt install ./wiringpi_x.yy_zzzzz.deb
wobei x.yy die Version ist und zzzzz die Hardware.
mfg
NaCkHaYeD
Bei mir funktioniert Deine Änderung auch aus der gespeicherten Konfiguration heraus.
Nach einem FHEM Neustart werden die ports entsprechend der Attribute gesetzt.
Aber:
- das Modul heißt 55_PIFACE.pm, nicht 50_PIFACE.pm
- hier ist das falsche Unterforum für das Modul 55_PIFACE.pm
Den Button zum verschieben in den richtigen Bereich (damit der Modulautor etwas mitbekommt) findest Du unten links auf der Seite. Das "richtige" Unterforum findest Du mit "help piface" in der FHEM Befehlszeile.