HomeMatic USB Konfigurations-Adapter (HM-CFG-USB) in Fhem nutzen

Begonnen von mgernoth, 30 Mai 2013, 17:06:32

Vorheriges Thema - Nächstes Thema

Gandalv

Guten Morgen volschin,

genau das hab ich auch schon ausprobiert.
Genau das gleiche :-(

volschin

Hast Du mal ein ps auf den hmland gemacht, ob er wirklich läuft?
Intel NUC+Ubuntu 24.04+Docker+FHEM6
HomeMatic: HM-MOD-RPI-PCB+HM-USB-CFG2+hmland+diverse, HUE: Hue-Bridge, RaspBee+deCONZ+diverse
Amzn Dash-Buttons, Siro Rollos
4xRPi, 4xCO20, OWL+USB, HarmonyHub, FRITZ!Box 7690, Echo Dots+Show8, HomeBridge

Gandalv

Den Stick hab ich bis jetzt nur mit der HomeMatic Software getestet.
Was genau soll ich machen?
Mein perl wissen hält sich auch stark in grenzen, bin mehr der C-Mensch

volschin

Ich glaube, ich hatte das Problem auch. Meine Befehlszeile sieht anders aus. Lass das -l 127.0.0.1 weg.

Gruß
Veit
Intel NUC+Ubuntu 24.04+Docker+FHEM6
HomeMatic: HM-MOD-RPI-PCB+HM-USB-CFG2+hmland+diverse, HUE: Hue-Bridge, RaspBee+deCONZ+diverse
Amzn Dash-Buttons, Siro Rollos
4xRPi, 4xCO20, OWL+USB, HarmonyHub, FRITZ!Box 7690, Echo Dots+Show8, HomeBridge

Gandalv

ok danke. Werde ich versuchen, sobald ich wieder zuhause bin.
Werde dann auch gleich berichten :-)

kud

Zitat von: fiedel am 15 November 2013, 09:52:12
Hi,

das habe ich auf meinem Debian Squeeze probiert. Also Startscript für hmland erstellt, Abhängigkeiten gesetzt und dann das Startscript für FHEM neu erzeugen lassen, sodass hmland mit einer "01" startet und FHEM mit einer "02". Hat auch funktioniert, allerdings hat nun FHEM sehr lange zum starten gebraucht - auch bei einfachem "shutdown restart". Ich hatte dann noch ein wenig damit rumexperimentiert, ohne dass ich das Verhalten verbessern konnte.

Letztendlich rufe ich hmland aus FHEM auf mit folgendem Befehl:


define Func_Start_Init_W watchdog . 00:00:01 SAME {system("ps | grep hmland | grep -v -q grep || /opt/fhem/hmland -d -p 1234");;}


Das startet hmland beim Start von fhem, aber nur dann, wenn hmland noch nicht aktiv ist.


Die Zeile sieht ja kryptisch aus  ???
Wo steht diese denn ? In der fhem.cfg?
Kannst Du die Zeile mal kurz "übersetzten"... für alle Blindfüchse wie mich..
Danke und Gruss
Kai-Uwe

Gandalv

Hallo Funktioniert leider immer noch nicht.

So sieht die startfhem aus:
Zitat#!/bin/sh

home=/var/InternerSpeicher/fhem

cd $home

trap "" SIGHUP
modprobe cdc_acm
modprobe ftdi_sio
sleep 2

ln -sf $home/FHEM/fhemcmd.sh /var/fhemcmd

PATH=$home:$PATH
export PATH

export LD_LIBRARY_PATH=$home/lib
export PERL5LIB=$home/lib/perl5/site_perl/5.12.2/mips-linux:$home/lib/perl5/site_perl/5.12.2:$home/lib/perl5/5.12.2/mips-linux:$home/lib/perl5/5.12.2
# ps | grep hmland | grep -v -q grep || $home/lib/hmland -l 127.0.0.1 -p 1000 -d
ps | grep hmland | grep -v -q grep || $home/lib/hmland -p 1234 -d
sleep 2

# add user fhem with uid of boxusr80/boxusr99 (== ftpuser)
# Comment/delete everything between START and END to run FHEM as root

## START:fhem-user
id fhem > /dev/null 2>&1
if test "$?" -ne "0"; then
  grep -q 1099 /etc/passwd;
  if test $? -eq "0"; then
    echo "fhem:any:1099:0:fhem:/home-not-used:/bin/sh" >>/var/tmp/passwd
  else
    echo "fhem:any:1080:0:fhem:/home-not-used:/bin/sh" >>/var/tmp/passwd
  fi
  chown -R fhem FHEM docs log www
  chown fhem . *
  chown root dfu-programmer     
  chmod u+s dfu-programmer
fi
## END:fhem-user

perl fhem.pl fhem.cfg

und so die fhem.cfg
Zitatattr global autoload_undefined_devices 1
attr global logfile ./log/fhem-%Y-%m.log
attr global modpath .
attr global motd SecurityCheck:\
\
WEB,WEBphone,WEBtablet has no basicAuth attribute.\
telnetPort has no password/globalpassword attribute.\
\
Restart fhem for a new check if the problem is fixed,\
or set the global attribute motd to none to supress this message.\

attr global sendStatistics never
attr global statefile ./log/fhem.save
attr global userattr devStateIcon devStateStyle icon sortby webCmd
attr global verbose 3

define telnetPort telnet 7072 global

define WEB FHEMWEB 8083 global

define WEBphone FHEMWEB 8084 global
attr WEBphone stylesheetPrefix smallscreen

define WEBtablet FHEMWEB 8085 global
attr WEBtablet stylesheetPrefix touchpad

# Fake FileLog entry, to access the fhem log from FHEMWEB
define Logfile FileLog ./log/fhem-%Y-%m.log fakelog

define autocreate autocreate
attr autocreate autosave 1
attr autocreate device_room %TYPE
attr autocreate filelog ./log/%NAME-%Y.log
attr autocreate weblink 1
attr autocreate weblink_room Plots

# Disable this to avoid looking for new USB devices on startup
define initialUsbCheck notify global:INITIALIZED usb create


# If the above notify did not helped, then you probably have to enable some of
# the following lines.  Verify first that /dev/xxx ist correct.

#define FHZ FHZ /dev/USB0
#define CUL CUL /dev/ttyACM0@38400 1234
#attr CUL rfmode HomeMatic

#define EUL TCM 310 /dev/ttyACM0@38400
#define BscBor TCM 120 /dev/ttyUSB0@9600
#define BscSmartConnect TCM 310 /dev/ttyUSB0@57600

define fbaha FBAHA localhost:2002

define CUL_0 CUL /dev/ttyACM0@38400 1034

define Kuechenzeile FS20 3008 10
attr Kuechenzeile eventMap /off:Aus/on:An/
attr Kuechenzeile group Licht
attr Kuechenzeile model fs20su
attr Kuechenzeile room Kueche

define Tischbeleuchtung FS20 3008 11
attr Tischbeleuchtung eventMap /off:Aus/on:An/
attr Tischbeleuchtung group Licht
attr Tischbeleuchtung model fs20su
attr Tischbeleuchtung room Kueche

define Rolladen_Fenster FS20 3008 13
attr Rolladen_Fenster eventMap /off:Ab/on:Auf/
attr Rolladen_Fenster group Rolladen
attr Rolladen_Fenster model fs20rsu
attr Rolladen_Fenster room Kueche

define Rolladen_Tuer FS20 3008 12
attr Rolladen_Tuer eventMap /off:Ab/on:Auf/
attr Rolladen_Tuer group Rolladen
attr Rolladen_Tuer model fs20rsu
attr Rolladen_Tuer room Kueche


#Kueche
#Rolladen unter der Woche
define rolladenfenster at *20:00:03 { fhem("set Rolladen_Fenster off") if (!$we) }
define rolladentuer at *20:00:00 { fhem("set Rolladen_Tuer off") if (!$we) }
define rolladenfensterauf at *07:00:00 { fhem("set Rolladen_Fenster on") if (!$we) }
define rolladentueron at *07:00:03 { fhem("set Rolladen_Tuer on") if (!$we) }
#
#Rolladen am Wochenende
define rolladenfensterwe at *20:00:00 { fhem("set Rolladen_Fenster off") if ($we) }
define rolladentuerwe at *21:00:00 { fhem("set Rolladen_Tuer off") if ($we) }
define rolladenfensteraufwe at *07:00:00 { fhem("set Rolladen_Fenster on") if ($we) }
define rolladentueronwe at *07:00:03 { fhem("set Rolladen_Tuer on") if ($we) }
#
#Licht aus unter der Woche
define kuechenlichtaus at *23:15:00 { fhem("set Tischbeleuchtung off ;; set Kuechenzeile off")  if(!$we)}
#
#Licht aus am Wochenende
define kuechenlichtauswe at *01:00:00 { fhem("set Tischbeleuchtung off ;; set Kuechenzeile off")  if($we)}

und so das log file
Zitat2013.11.21 17:24:46 2: SecurityCheck:  WEB,WEBphone,WEBtablet has no basicAuth attribute. telnetPort has no password/globalpassword attribute.  Restart fhem for a new check if the problem is fixed, or set the global attribute motd to none to supress this message.
2013.11.21 17:24:46 0: Server started with 25 defined entities (version $Id: fhem.pl 4251 2013-11-19 13:44:02Z rudolfkoenig $, os linux, user boxusr99, pid 2989)
2013.11.21 17:25:54 1: Including fhem.cfg
2013.11.21 17:25:54 3: telnetPort: port 7072 opened
2013.11.21 17:25:54 3: WEB: port 8083 opened
2013.11.21 17:25:54 3: WEBphone: port 8084 opened
2013.11.21 17:25:54 3: WEBtablet: port 8085 opened
2013.11.21 17:25:54 3: Opening fbaha device localhost:2002
2013.11.21 17:25:54 3: Can't connect to localhost:2002: Connection refused
2013.11.21 17:25:54 3: Opening CUL_0 device /dev/ttyACM0
2013.11.21 17:25:54 3: Setting CUL_0 baudrate to 38400
2013.11.21 17:25:54 3: CUL_0 device opened
2013.11.21 17:25:54 3: CUL_0: Possible commands: BCFiAZEGMRTVWXefmltux
2013.11.21 17:25:54 1: Including ./log/fhem.save
2013.11.21 17:26:39 2: wrong syntax: define <name> HMLAN ip[:port]
2013.11.21 17:26:39 1: define: wrong syntax: define <name> HMLAN ip[:port]
2013.11.21 17:26:46 1: HMLAN_Parse: hmusb new condition disconnected
2013.11.21 17:26:46 3: Opening hmusb device 127.0.0.1:1000
2013.11.21 17:26:46 3: Can't connect to 127.0.0.1:1000: Connection refused

Ich danke schon mal für eure Hilfe!

Gandalv

Hallo,

hatte noch unterschiedliche Ports drin.
Port 1234 in der startfhem und den port 1000 in der fhem.cfg.

Behoben :-)

Aber leider habe ich immer noch disconnect drin stehen :-(

marc2

Hmm,

kann mir nicht vorstellen, dass der hmland wirklich läuft.

1) Was sagt ps ?

root@fritzbox:/var/media/ftp/fhem# ps | grep hmlan | grep -v grep
32204 root      1136 S <  /var/media/ftp/bin/hmland -l 127.0.0.1 -p 1000 -d -r 04:00


2) Was sagt netstat (hoffe, dass das auf einer nicht gemoddeten Box überhaupt drauf ist ...) ?

root@fritzbox:/var/media/ftp/fhem# netstat -an | grep LISTEN | grep ":1000"
tcp        0      0 127.0.0.1:1000          0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:10000           0.0.0.0:*               LISTEN 
   

3) Was steht im Logfile vom hmland ?

Gruß, Marc

Gandalv

#159
Hallo marc2

wie funktioniert das mit "ps"?
Sorry das ich das ganze nicht ohne Hilfe hinbekomme.

Folgendes Steht im HMLAND.log
Zitat/var/InternerSpeicher/fhem/startfhem: line 19: /var/InternerSpeicher/fhem/lib/hmland: Permission denied

-------------EDIT--------------------
Rechte angepasst nun steht folgendes im log
Zitat/var/InternerSpeicher/fhem/lib/hmland: can't load library 'libusb-1.0.so.0'

-------------EDIT2-------------------

ES FUNKTIONIERT!!!!!!!!!!!!!!    :-)

Clyde

Hallo Gandalv!

2013.11.23 19:06:36 2: HMLAN_Parse: hmusb new condition disconnected
2013.11.23 19:06:36 3: Opening hmusb device 127.0.0.1:1000
2013.11.23 19:06:36 3: Can't connect to 127.0.0.1:1000: Connection refused


Hänge genau am selben Punkt wie Du fest. Wie hast Du es zum Laufen bekommen?
Proxmox auf MINIX-Z100, LXC: FHEM, FS20, FHT, HM, Tradfri, Alexa, Anker Solix Solarbank 2

marc2

Hallo Clyde,

auch hier der Hinweis auf das Logfile des hmland, das sollte Dir helfen !

Zitat/var/InternerSpeicher/fhem/startfhem: line 19:c: Permission denied

Hier fehlten die Ausführungsrechte für der den User

chmod 750  /var/InternerSpeicher/fhem/lib/hmland


Zitat/var/InternerSpeicher/fhem/lib/hmland: can't load library 'libusb-1.0.so.0'

Entweder die libusb-1.0.so.0 in ein Verzeichnis kopieren, das bereits im Suchpfad des Runtime  Linkers
liegt, oder LD_LIBRARY_PATH setzen.

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/var/InternerSpeicher/fhem/lib

Oder ggf. fehlen hier auch die Leserechte.

Gruß, Marc

Clyde

Hi Marc!

Danke für Deine Antwort. Leider wird der HM-USB-Stick nicht erkanntWenn ich es richtig verstanden habe, findet die Rechtevergabe in der Datei startfhem mit Perl-Kommandos statt. Diese Datei sieht nun so bei mir aus:

#!/bin/sh

home=/var/InternerSpeicher/fhem

cd $home

trap "" SIGHUP
modprobe cdc_acm
modprobe ftdi_sio
sleep 2

ln -sf $home/FHEM/fhemcmd.sh /var/fhemcmd

PATH=$home:$PATH
export PATH

export LD_LIBRARY_PATH=$home/lib
export PERL5LIB=$home/lib/perl5/site_perl/5.12.2/mips-linux:$home/lib/perl5/site_perl/5.12.2:$home/lib/perl5/5.12.2/mips-linux:$home/lib/perl5/5.12.2

chmod 750 /var/InternerSpeicher/fhem/lib/hmland
ps | grep hmland | grep -v -q grep || $home/lib/hmland -p 1234 -D - r 03:00
sleep 2

perl fhem.pl fhem.cfg



Die Logdatei nach dem Neustart bringt folgendes hervor:

2013.11.27 14:32:10 0: Server shutdown
2013.11.27 14:32:14 1: Including fhem.cfg
2013.11.27 14:32:15 3: telnetPort: port 7072 opened
2013.11.27 14:32:16 3: WEB: port 8083 opened
2013.11.27 14:32:16 3: WEBphone: port 8084 opened
2013.11.27 14:32:16 3: WEBtablet: port 8085 opened
2013.11.27 14:32:16 3: Opening fbaha device localhost:2002
2013.11.27 14:32:16 3: fbaha device opened
2013.11.27 14:32:16 1: FBAHA fbaha registered with handle: 0000001c
2013.11.27 14:32:16 3: Opening CUL_0 device /dev/ttyACM0
2013.11.27 14:32:17 3: Setting CUL_0 baudrate to 38400
2013.11.27 14:32:17 3: CUL_0 device opened
2013.11.27 14:32:17 3: CUL_0: Possible commands: BCFiAGMRTVWXefmltux
2013.11.27 14:32:19 2: HMLAN_Parse: hmusb new condition disconnected
2013.11.27 14:32:19 3: Opening hmusb device 127.0.0.1:1234
2013.11.27 14:32:19 3: Can't connect to 127.0.0.1:1234: Connection refused
2013.11.27 14:32:19 1: Including ./log/fhem.save
2013.11.27 14:32:19 1: statefile: Please define SVG_FileLog_PIRA_1_1 first
2013.11.27 14:32:19 1: usb create starting
2013.11.27 14:32:20 1: usb create end
2013.11.27 14:32:20 2: SecurityCheck:  Running with root privileges. Restart fhem for a new check if the problem is fixed, or set the global attribute motd to none to supress this message.
2013.11.27 14:32:20 0: Server started with 91 defined entities (version $Id: fhem.pl 3872 2013-09-07 11:58:33Z rudolfkoenig $, os linux, user root, pid 11094)
2013.11.27 14:32:21 3: telnetForBlockingFn: port 32910 opened


In der fhem.cfg ist folgendes konfiguriert:

define hmusb HMLAN 127.0.0.1:1234
attr hmusb hmId 424242
attr hmusb hmLanQlen 1_min
attr hmusb wdTimer 25


Proxmox auf MINIX-Z100, LXC: FHEM, FS20, FHT, HM, Tradfri, Alexa, Anker Solix Solarbank 2

Clyde

btw:

Unter fhem/log befindet sich das Logfile des hmland nicht. Muß ich das extra "einschalten"?

Proxmox auf MINIX-Z100, LXC: FHEM, FS20, FHT, HM, Tradfri, Alexa, Anker Solix Solarbank 2

betateilchen

-----------------------
Formuliere die Aufgabe möglichst einfach und
setze die Lösung richtig um - dann wird es auch funktionieren.
-----------------------
Lesen gefährdet die Unwissenheit!