rdmtc / RedMatic

Node-RED packaged as Addon for the Homematic CCU3 and RaspberryMatic 🤹‍♂️
Apache License 2.0
534 stars 47 forks source link

node-red-contrib-alexa-home vs. node-red-contrib-alexa-local #243

Open franksto opened 5 years ago

franksto commented 5 years ago

Hi zusammen,

hatte bisher node-red-contrib-alexa-local zur Anbindung an Alexa genutzt. Nachdem es immer wieder Probleme mit dem Flow gibt - Geräte reagieren nicht, dann wieder doch - Geräte werden nicht discovered dann wieder doch wollte ich node-red-contrib-alexa-local durch node-red-contrib-alexa-home austauschen. Soweit so gut node-red-contrib-alexa-home installiert, bekomme aber den Discover nicht hin, sprich in Node-Red sieht alles gut aus, aber es finden sich die anlegten Devices nicht in Alexa. Jemand eine Idee, gleiches Problem, schön evtl. gelöst oder funktioniert es einfach nicht auf RedMatic?

Danke im Vorraus!

ThomasPoett commented 5 years ago

Hi @franksto
leider sind alle Lösung zu Alexa ein bissal instabil. Ich arbeite mit: node-red-contrib-alexa-home-skill eigenen Cmd absetzten (stabil, jedoch ab und zu ist der Cloud Connect für ein paar sec weg) node-red-contrib-alexa-remote2 (so weit gut, aber auch hier muss ich immer wieder den login erneuern) Ich denke, das liegt an der Raspmatic auf der Node Red läuft. wenn einen normal Distribution drunter liegt, sollten bei Module besser laufen.

franksto commented 5 years ago

Ich denke, das liegt an der Raspmatic auf der Node Red läuft. wenn einen normal Distribution drunter liegt, sollten bei Module besser laufen. -> des wegen hab ich es hier als Frage gepostet

node-red-contrib-alexa-remote2 + node-red-contrib-alexa-home-skill möchte ich aufgrund von zusätzlicher Cloudanbindung nicht nutzen.

Will einfach eine lokale Alexa anbindung, ohne noch ein Zweitsystem mit OpenHab oder sonstiges aufzubauen.

ThomasPoett commented 5 years ago

Eine lokal Anbindung wird nicht gehen. Alexa ist ein Cloud Service, d.h. Du must immer die API in der Cloud ansprechen. Diese schickt dann, wenn der Auth Token passt an das definierte / registrierte Alexa Device.

ThomasPoett commented 5 years ago

Eine lokal Anbindung wird nicht gehen. Alexa ist ein Cloud Service, d.h. Du must immer die API in der Cloud ansprechen. Diese schickt dann, wenn der Auth Token passt an das definierte / registrierte Alexa Device.

Eine lokal Anbindung wird nicht gehen. Alexa ist ein Cloud Service, d.h. Du must immer die API in der Cloud ansprechen. Diese schickt dann, wenn der Auth Token passt an das definierte / registrierte Alexa Device. Wenn Du eigenen cmd senden willst, must Du via Alexa Skills (auch private) agieren. d.h. via Alexa Lambda (oder wie sie hießen) arbeiten. Dazu must Du aber einen RevProxy und eine feste IP haben (auch DynDNS)

franksto commented 5 years ago

Alexa ist ein Cloud Dienst ja, aber ich will keinen zweiten Cloud Service nur für die Anbindung haben - deswegen ja node-red-contrib-alexa-home vs. node-red-contrib-alexa-local - diese simulieren eine Hue Bridge im lokalen LAN und Alexa kann diese discovern.

Aber zurück zur eigentlichen Frage:

Soweit so gut node-red-contrib-alexa-home installiert, bekomme aber den Discover nicht hin, sprich in Node-Red sieht alles gut aus, aber es finden sich die anlegten Devices nicht in Alexa. Jemand eine Idee, gleiches Problem, schön evtl. gelöst oder funktioniert es einfach nicht auf RedMatic?

dehsgr commented 5 years ago

Schau mal, ob auf der RaspberryMatic in den Firewall-Einstellungen entsprechend benötigte Ports zugelassen werden...

franksto commented 5 years ago

Ports sind alle offen - Discover findet nichts. Controller Node sagt ok Device Node sagt ok

ThomasPoett commented 5 years ago

@franksto Jetzt habe ich verstanden was Du magst. Danke Dir ! Ich versuche mal zu testen, muss aber die 2te RoteBerenKuchen fit machen

franksto commented 5 years ago

hmmmm - eventuell liegt hier das Problem - wenn jemand mit geschulten Auge mal draufschauen könnte, mein Bauchgefühl sagt mir, dass irgendwo hier das Problem versteckt ist:

netstat -tulpen

Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:42001 0.0.0.0: LISTEN 595/lighttpd tcp 0 0 0.0.0.0:2001 0.0.0.0: LISTEN 595/lighttpd tcp 0 0 0.0.0.0:8883 0.0.0.0: LISTEN 984/mosquitto tcp 0 0 0.0.0.0:8884 0.0.0.0: LISTEN 984/mosquitto tcp 0 0 0.0.0.0:48181 0.0.0.0: LISTEN 595/lighttpd tcp 0 0 0.0.0.0:8181 0.0.0.0: LISTEN 595/lighttpd tcp 0 0 0.0.0.0:22 0.0.0.0: LISTEN 608/sshd tcp 0 0 0.0.0.0:8183 0.0.0.0: LISTEN 898/ReGaHss tcp 0 0 127.0.0.1:1880 0.0.0.0: LISTEN 15681/node-red tcp 0 0 0.0.0.0:42010 0.0.0.0: LISTEN 595/lighttpd tcp 0 0 0.0.0.0:2010 0.0.0.0: LISTEN 595/lighttpd tcp 0 0 0.0.0.0:1883 0.0.0.0: LISTEN 984/mosquitto tcp 0 0 0.0.0.0:443 0.0.0.0: LISTEN 595/lighttpd tcp 0 0 0.0.0.0:1884 0.0.0.0: LISTEN 984/mosquitto tcp 0 0 0.0.0.0:8700 0.0.0.0: LISTEN 656/cuxd tcp 0 0 0.0.0.0:8701 0.0.0.0: LISTEN 656/cuxd tcp 0 0 127.0.0.1:2047 0.0.0.0: LISTEN 15681/node-red tcp 0 0 0.0.0.0:31999 0.0.0.0: LISTEN 898/ReGaHss tcp 0 0 127.0.0.1:2048 0.0.0.0: LISTEN 15681/node-red tcp 0 0 0.0.0.0:32001 0.0.0.0: LISTEN 735/rfd tcp 0 0 0.0.0.0:49292 0.0.0.0: LISTEN 595/lighttpd tcp 0 0 0.0.0.0:9292 0.0.0.0: LISTEN 595/lighttpd tcp 0 0 0.0.0.0:41999 0.0.0.0: LISTEN 595/lighttpd tcp 0 0 0.0.0.0:1999 0.0.0.0: LISTEN 595/lighttpd tcp 0 0 0.0.0.0:42000 0.0.0.0: LISTEN 595/lighttpd tcp 0 0 0.0.0.0:2000 0.0.0.0: LISTEN 595/lighttpd tcp 0 0 0.0.0.0:80 0.0.0.0: LISTEN 595/lighttpd tcp 0 0 :::36017 ::: LISTEN 15681/node-red tcp 0 0 :::42001 ::: LISTEN 595/lighttpd tcp 0 0 :::2001 ::: LISTEN 595/lighttpd tcp 0 0 :::42611 ::: LISTEN 15681/node-red tcp 0 0 :::8883 ::: LISTEN 984/mosquitto tcp 0 0 :::48181 ::: LISTEN 595/lighttpd tcp 0 0 :::8181 ::: LISTEN 595/lighttpd tcp 0 0 :::22 ::: LISTEN 608/sshd tcp 0 0 :::8088 ::: LISTEN 961/node tcp 0 0 :::42010 ::: LISTEN 595/lighttpd tcp 0 0 :::2010 ::: LISTEN 595/lighttpd tcp 0 0 :::38395 ::: LISTEN 15681/node-red tcp 0 0 :::443 ::: LISTEN 595/lighttpd tcp 0 0 :::39292 ::: LISTEN 769/java tcp 0 0 :::43037 ::: LISTEN 15681/node-red tcp 0 0 :::34975 ::: LISTEN 15681/node-red tcp 0 0 :::42945 ::: LISTEN 15681/node-red tcp 0 0 :::41381 ::: LISTEN 15681/node-red tcp 0 0 :::44965 ::: LISTEN 15681/node-red tcp 0 0 :::42089 ::: LISTEN 15681/node-red tcp 0 0 :::32010 ::: LISTEN 769/java tcp 0 0 :::9099 ::: LISTEN 961/node tcp 0 0 :::49292 ::: LISTEN 595/lighttpd tcp 0 0 :::9292 ::: LISTEN 595/lighttpd tcp 0 0 :::41165 ::: LISTEN 15681/node-red tcp 0 0 :::9293 ::: LISTEN 769/java tcp 0 0 :::36655 ::: LISTEN 15681/node-red tcp 0 0 :::41999 ::: LISTEN 595/lighttpd tcp 0 0 :::1999 ::: LISTEN 595/lighttpd tcp 0 0 :::42000 ::: LISTEN 595/lighttpd tcp 0 0 :::2000 ::: LISTEN 595/lighttpd tcp 0 0 :::80 ::: LISTEN 595/lighttpd udp 0 0 192.168.0.5:50355 0.0.0.0: 15681/node-red udp 0 0 192.168.0.5:50372 0.0.0.0: 15681/node-red udp 0 0 192.168.0.5:60109 0.0.0.0: 961/node udp 0 0 192.168.0.5:50897 0.0.0.0: 15681/node-red udp 0 0 192.168.0.5:49880 0.0.0.0: 961/node udp 0 0 192.168.0.5:50939 0.0.0.0: 15681/node-red udp 0 0 192.168.0.5:48899 0.0.0.0: 961/node udp 0 0 192.168.0.5:10000 0.0.0.0: 961/node udp 0 0 192.168.0.5:50962 0.0.0.0: 15681/node-red udp 0 0 192.168.0.5:50963 0.0.0.0: 15681/node-red udp 0 0 192.168.0.5:50978 0.0.0.0: 15681/node-red udp 0 0 192.168.0.5:48946 0.0.0.0: 961/node udp 0 0 192.168.0.5:50997 0.0.0.0: 15681/node-red udp 0 0 127.0.0.1:323 0.0.0.0: 555/chronyd udp 0 0 192.168.0.5:50500 0.0.0.0: 15681/node-red udp 0 0 192.168.0.5:50505 0.0.0.0: 15681/node-red udp 0 0 192.168.0.5:58194 0.0.0.0: 961/node udp 0 0 192.168.0.5:50008 0.0.0.0: 15681/node-red udp 0 0 192.168.0.5:5987 0.0.0.0: 961/node udp 0 0 0.0.0.0:1900 0.0.0.0: 15681/node-red udp 0 0 0.0.0.0:1900 0.0.0.0: 15681/node-red udp 0 0 0.0.0.0:1900 0.0.0.0: 15681/node-red udp 0 0 0.0.0.0:1900 0.0.0.0: 15681/node-red udp 0 0 0.0.0.0:1900 0.0.0.0: 15681/node-red udp 0 0 0.0.0.0:1900 0.0.0.0: 15681/node-red udp 0 0 0.0.0.0:1900 0.0.0.0: 15681/node-red udp 0 0 0.0.0.0:1900 0.0.0.0: 15681/node-red udp 0 0 0.0.0.0:1900 0.0.0.0: 15681/node-red udp 0 0 0.0.0.0:1900 0.0.0.0: 15681/node-red udp 0 0 0.0.0.0:1900 0.0.0.0: 15681/node-red udp 0 0 0.0.0.0:1900 0.0.0.0: 15681/node-red udp 0 0 0.0.0.0:1900 0.0.0.0: 15681/node-red udp 0 0 0.0.0.0:1900 0.0.0.0: 15681/node-red udp 0 0 0.0.0.0:1900 0.0.0.0: 15681/node-red udp 0 0 0.0.0.0:1900 0.0.0.0: 15681/node-red udp 0 0 0.0.0.0:1900 0.0.0.0: 15681/node-red udp 0 0 0.0.0.0:1900 0.0.0.0: 15681/node-red udp 0 0 0.0.0.0:1900 0.0.0.0: 15681/node-red udp 0 0 0.0.0.0:1900 0.0.0.0: 15681/node-red udp 0 0 0.0.0.0:1900 0.0.0.0: 15681/node-red udp 0 0 0.0.0.0:1900 0.0.0.0: 15681/node-red udp 0 0 0.0.0.0:1900 0.0.0.0: 15681/node-red udp 0 0 0.0.0.0:1900 0.0.0.0: 602/ssdpd udp 0 0 0.0.0.0:1901 0.0.0.0: 961/node udp 0 0 0.0.0.0:1902 0.0.0.0: 961/node udp 0 0 0.0.0.0:1905 0.0.0.0: 961/node udp 0 0 192.168.0.5:50591 0.0.0.0: 15681/node-red udp 0 0 0.0.0.0:43438 0.0.0.0: 769/java udp 0 0 0.0.0.0:43439 0.0.0.0: 585/eq3configd udp 0 0 127.0.0.1:1998 0.0.0.0: 898/ReGaHss udp 0 0 192.168.0.5:50151 0.0.0.0: 15681/node-red udp 0 0 127.0.0.1:8182 0.0.0.0: 205/hss_led udp 0 0 192.168.0.5:50181 0.0.0.0: 15681/node-red udp 0 0 0.0.0.0:35344 0.0.0.0: 961/node udp 0 0 192.168.0.5:50214 0.0.0.0: 15681/node-red udp 0 0 192.168.0.5:50731 0.0.0.0: 15681/node-red udp 0 0 192.168.0.5:50220 0.0.0.0: 15681/node-red udp 0 0 0.0.0.0:33836 0.0.0.0: 735/rfd udp 0 0 192.168.0.5:50739 0.0.0.0: 15681/node-red udp 0 0 192.168.0.5:50790 0.0.0.0: 15681/node-red udp 0 0 192.168.0.5:50801 0.0.0.0: 15681/node-red udp 0 0 192.168.0.5:50317 0.0.0.0: 15681/node-red udp 0 0 192.168.0.5:50351 0.0.0.0: 15681/node-red udp 0 0 ::1:323 ::: 555/chronyd udp 0 0 :::58523 ::: 769/java udp 0 0 :::43686 :::* 769/java #

wernersv commented 4 years ago

Für meine Flows verwende ich redmatic + node-red-contrib-amazon-echo auf Rasperymatic. Mittlerweile befinden sich hier drei Echo Dot v3 und alle funktionieren mit redmatic,

Die Ursache meiner Probleme beim Discover war, dass Echo Dot v3 nur auf Port 80 sucht. Das funktioniert aber nicht, da der light-httpd der CCU auf dem Port läuft. Die node "Amazon Echo Hub" habe ich auf Port 82 eingestellt, da sie sonst aufgrund des belegten Ports nicht starten kann. Auf Port 82 findet der Dot aber das "Gerät" nicht.

Lösung 1: NodeRed auf einem weiteren Raspi Installieren, wo es auf Port 80 laufen kann

Lösung 2: Proxy --> https://github.com/datech/node-red-contrib-amazon-echo/issues/89

Für den Light-Httpd auf RaspberryMatic sieht das wie folgt aus.

/etc/lighttpd/conf.d/proxy.conf

#-----------
# WebUI HTTP
#-----------
$SERVER["socket"] == ":80" {
  server.document-root = server_root
  $HTTP["url"] =~ "^/.*\.(exe|oxml|hssml).*" {
    $HTTP["remoteip"] !~ "^(127\.0\.0\.1|::ffff:127\.0\.0\.1|::1)$" {
      url.access-deny = ( "" )
    }
  }
  $HTTP["url"] !~ "^/(config/)|(upnp)|(webui/)|(ise/)|(api/)|(tools/)|(pda)|(pages/jpages)|(addons).*" {
    proxy.server = ( "" => ("localhost" => ("host" => "127.0.0.1", "port" => 8183)))
  }
##+ redirect Alexa
  $HTTP["url"] =~ "^/description.xml" {
    proxy.server = ( "" => ("localhost" => ("host" => "127.0.0.1", "port" => 82)))
  }
  $HTTP["url"] =~ "^/api/.*/lights" {
    proxy.server = ( "" => ("localhost" => ("host" => "127.0.0.1", "port" => 82)))
  }
##- redirect Alexa
  $HTTP["url"] =~ "^/(pages/jpages).*" {
    proxy.server = ( "" => ("localhost" => ("host" => "127.0.0.1", "port" => 39292)))
  }
}`
...

Das Dateisystem der RaspberryMatic ist readonly und muss zuerst schreibbar gemacht werden. mount -o remount rw / Danach den daemon durchstarten /etc/init.d/*http* restart.

Zu erwähnen wäre noch, dass die Änderungen in der proxy.conf nach einem Update der CCU ggf. wieder eingespielt werden müssen. Auch habe ich nur die Sektion für ip4:80 gemacht. Für ip6:80 und ip4:*:443/ip6:443 muss das ggf. auch noch eingetragen werden.

Mir stellt sich noch die Frage, ob die Proxy Config seitens Redmatic gemacht werden könnte, ohne das per SSH hacken zu müssen. Kann das @hobbyquaker beantworten?

hobbyquaker commented 4 years ago

@wernersv ja, das können wir machen. Ich würds in diese Datei mit rein nehmen: https://github.com/rdmtc/RedMatic/blob/master/addon_files/redmatic/etc/lighttpd.conf Wenn Du magst würde ich mich auch über einen Pullrequest freuen :)

wernersv commented 4 years ago

Diese Möglichkeit zur Erweiterung der lighttpd.conf war mir bislang unbekannt.

Eigentlich sind es nur diese Zeilen für /usr/local/addons/redmatic/etc/lighttpd.conf: $HTTP["url"] =~ "(^/description.xml)|(^/api/.*/lights)" { proxy.server = ( "" => ("localhost" => ("host" => "127.0.0.1", "port" => 6502))) } Lokal getestet und funktioniert.

Der Port (hier 6502) sollte aber konfigurierbar sein, da bei der Node auch der Port angegeben wird. Idealerweise hier: /addons/redmatic/settings.cgi

Er könnte aber auch bei der Node amazon-echo-hub ausgelesen /usr/local/addons/redmatic/var/projects/redmatic/flows.json { "id": "fc29ef8f.e859b", "type": "amazon-echo-hub", "z": "ca2b6395.bae9c", "port": "6502", "processinput": "2", "x": 250, "y": 420, "wires": [ [ ... ] ] } und in lighttpd.conf eingetragen werden. Programmatisch auslesen, in die Settings eintragen, Checkbox zum aktivieren/deaktivieren und die CCU neustarten. Das fände ich eleganter.

hobbyquaker commented 4 years ago

Auslesen aus dem Node ist problembehaftet. Man weiss ja gar nicht ob der User diese Nodes überhaupt verwendet ;-) Auch könnte es sein dass nicht node-red-contrib-amazon-echo sondern z.B. node-red-contrib-alexa-local verwendet wird. Ich würde das lieber einfach halten (statische Config) und das einfach in die Doku schreiben welcher Port genutzt werden muss.

wernersv commented 4 years ago

Done. :-)

hobbyquaker commented 4 years ago

Super, danke!

Vielleicht hättest ja Lust noch ein Beispielflow mit node-red-contrib-amazon-echo im Wiki zu veröffentlichen :-)