Ich bin zwar kein Alexa* power User aber hier und da nutze ich sie ja doch.
So war ich am überlegen wir ich das ganze ohne zusätzliche Cloud Anbindung (was mir ganz lieb war), kostenlos und trotzdem noch einfach zu handhaben mache.

Ich wurde von paar anderen ioBroker User darauf hingewiesen das mit dem Node-Red Node
node-red-contrib-amazon-echo das ganze recht gut zu handhaben wäre.

So bin ich dann auf die Lösung gekommen das ich die Daten von Alexa* über Node-Red in einen ioBroker Datenpunkt schreibe und diesen dann mit einen Script innerhalb von ioBroker verarbeite.

Der Node-Red Flow

Ich habe wie hier zu sehen, habe ich paar Emulierte Alexa* Endpunkte angelegt die als Gerät dann von der Alexa* gefunden werden.

Wie hier zu sehen gibt Name den Rufnamen für Alexa an, und Topic das Device in ioBroker.
Wobei das Device ohne Datenendpunkt angeben wird, da dieses automatisch anhand den gesprochenen Aktion durch das Script ermittelt wird.

Mehr muss ich dann für neue Device Integrationen im Node-Red dann nicht mehr vornehmen, da Node-Red hier nur das Bindeglied zwischen Alexa und ioBroker ist.

Das Script

Hier einmal das Repo.

legt diese drei Datenpunkte innerhalb von ioBroker an.

  • Database
    • das Mapping vom ioBroker Device zum Alexa Device (für das Script)
    • die Datenbank baut sich selbständig auf, und erweitertet sich mit jeden neuen angesprochenen Device
  • Input
    • der Input von Node-Red (hier lausch der Script drauf)
  • Output
    • der Output vom Script für Alexa (hier lausch Node-Red drauf)

Das Script unterstützt zur Zeit vier Aktionen.

  • bri
    • Helligkeit (Dimmen)
  • hue
    • Licht Farbe
  • ct
    • ColorTemp (Licht Temperatur)
  • on
    • An / Aus

Zu diesen Zeitpunkt werden die Adapter Zigbee und Wled unterstützt, wenn man einen weiteren Adapter hinzufügen will, muss nur das Device Type Datapoint Mapping erweitert werden.

So sieht das aktuelle Device Type Datapoint Mapping aus

const deviceTypeDatapointMap = {
    zigbee: { bri:{ dp:'brightness', min:0, max:100 }, hue:'color', ct:'colortemp', on:'state' },
    wled: { bri:{ dp:'bri', min:0, max:254 }, hue:'seg.0.col.0_HEX', ct:'', on:'on' }
}

Hier noch einmal das Mapping etwas aufgeschlüsselt

zigbee: {               // Adapter Kennung zur Erkennung (wie z.B. zigbee.0.588e81fffed3eddd)
    bri: {              // Brightness
       dp: 'brightness',// Der Datenpunkt
       min: 0,          // Das minimale Brightness Level
       max: 100         // Das maximale Brightness Level
    }, 
    hue: 'color',       // Der Licht Farben Datenpunkt
    ct: 'colortemp',    // Der Licht Temperatur Datenpunkt
    on: 'state'         // Der State Datenpunkt
}

Was mir doch etwas den Kopf zerbrochen hatte, war dass Problem das Alexa es nicht mitbekommen hatte wenn ein Device von einen anderen Eingabegeräte gesteuert wurde.

Was zum teil echt wilde Effekte hatte…

Nun habe ich das Script so aufgebaut, dass dieses sich die angesprochenen Devices merkt und die relevanten Datenpunkte abonniert und an Alexa meldet.

Das klappt auch erstaunlich gut 🙂

Die Integration

Also nochmal kurz zusammen gefasst wie man das Ganze zum laufen bekommt.

Als erstes muss der Script im Javascript Adapter kopieren, ggf. erweitert und dann gestartet werden, so das die erforderlichen Datenpunkte angelegt werden.

Nun sollte das Node node-red-contrib-amazon-echo installier, der Flow in Node-Red importiert und die Devices angepasst werden, wichtig ist hier zu beachten das dass Node-Red als ioBroker Adapter installiert wurde da dort sonst die Verbindung zu ioBroker Fehlt.

Hier einmal mein Flow

[{"id":"f520be9d.1dc9","type":"amazon-echo-hub","z":"c3b4a742.7ec8e8","port":"80","processinput":"1","discovery":true,"x":390,"y":100,"wires":[["bec28245.0485d"]]},{"id":"12424426.64e0cc","type":"amazon-echo-device","z":"c3b4a742.7ec8e8","name":"Schreibtisch","topic":"wled.0.600194397548","x":150,"y":220,"wires":[["da72efb5.3fb53"]]},{"id":"13048f09.53d481","type":"ioBroker out","z":"c3b4a742.7ec8e8","name":"To ioBroker","topic":"0_userdata.0.AlexaToNodeRed.Input","ack":"true","autoCreate":"false","stateName":"","role":"","payloadType":"","readonly":"","stateUnit":"","stateMin":"","stateMax":"","x":370,"y":40,"wires":[]},{"id":"bf06c3c3.d66a2","type":"function","z":"c3b4a742.7ec8e8","name":"Move object to payload","func":"const obj = msg;\nmsg.payload = JSON.stringify(obj);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":170,"y":40,"wires":[["13048f09.53d481"]]},{"id":"71a7122.e1281ec","type":"amazon-echo-device","z":"c3b4a742.7ec8e8","name":"Bett","topic":"zigbee.0.588e81fffefea724","x":590,"y":220,"wires":[["9d1e7e55.0631c"]]},{"id":"da72efb5.3fb53","type":"link out","z":"c3b4a742.7ec8e8","name":"","links":["94b7dda8.2227c","5a9743c7.77e37c"],"x":395,"y":220,"wires":[]},{"id":"9d1e7e55.0631c","type":"link out","z":"c3b4a742.7ec8e8","name":"","links":["94b7dda8.2227c","5a9743c7.77e37c"],"x":715,"y":220,"wires":[]},{"id":"94b7dda8.2227c","type":"link in","z":"c3b4a742.7ec8e8","name":"Alexa to ioBroker","links":["291e6b41.b12fa4","313d132a.7daf4c","316940f1.4439e","38679977.16dbc6","3da05cbf.2ab6c4","773bb6db.03d6a8","9d1e7e55.0631c","a3dafcaa.c63a1","da72efb5.3fb53","e0b9d63d.579fd8","f8fe003.a7ea2","7d9b5204.b6bcbc","309ff20.878b90e"],"x":35,"y":40,"wires":[["bf06c3c3.d66a2"]]},{"id":"f6239bff.1e5658","type":"amazon-echo-device","z":"c3b4a742.7ec8e8","name":"Arbeitsplatte","topic":"zigbee.0.group_3","x":630,"y":460,"wires":[["3da05cbf.2ab6c4"]]},{"id":"3da05cbf.2ab6c4","type":"link out","z":"c3b4a742.7ec8e8","name":"","links":["94b7dda8.2227c","5a9743c7.77e37c"],"x":775,"y":460,"wires":[]},{"id":"268b65c2.91523a","type":"amazon-echo-device","z":"c3b4a742.7ec8e8","name":"Kueche","topic":"zigbee.0.group_5","x":620,"y":540,"wires":[["e0b9d63d.579fd8"]]},{"id":"e0b9d63d.579fd8","type":"link out","z":"c3b4a742.7ec8e8","name":"","links":["94b7dda8.2227c","5a9743c7.77e37c"],"x":775,"y":540,"wires":[]},{"id":"31c81738.2c4878","type":"amazon-echo-device","z":"c3b4a742.7ec8e8","name":"Kinderzimmer","topic":"zigbee.0.842e14fffe1f08e7","x":160,"y":460,"wires":[["313d132a.7daf4c"]]},{"id":"313d132a.7daf4c","type":"link out","z":"c3b4a742.7ec8e8","name":"","links":["94b7dda8.2227c","5a9743c7.77e37c"],"x":415,"y":460,"wires":[]},{"id":"6c3fca80.bcf604","type":"comment","z":"c3b4a742.7ec8e8","name":"-=====- Büro -=====-","info":"","x":120,"y":180,"wires":[]},{"id":"a9401a4b.16c118","type":"comment","z":"c3b4a742.7ec8e8","name":"-=====- Schlafzimmer -=====-","info":"","x":610,"y":180,"wires":[]},{"id":"199239f2.f09616","type":"comment","z":"c3b4a742.7ec8e8","name":"-=====- Küche -=====-","info":"","x":600,"y":420,"wires":[]},{"id":"84b286c4.7ddab8","type":"comment","z":"c3b4a742.7ec8e8","name":"-=====- Kinderzimmer -=====-","info":"","x":150,"y":420,"wires":[]},{"id":"5f29e87d.624588","type":"amazon-echo-device","z":"c3b4a742.7ec8e8","name":"Betthimmel","topic":"zigbee.0.8418260000101f8c","x":150,"y":500,"wires":[["316940f1.4439e"]]},{"id":"316940f1.4439e","type":"link out","z":"c3b4a742.7ec8e8","name":"","links":["94b7dda8.2227c","5a9743c7.77e37c"],"x":415,"y":500,"wires":[]},{"id":"b22939b9.2122f8","type":"amazon-echo-device","z":"c3b4a742.7ec8e8","name":"Disco","topic":"zigbee.0.841826000010328a","x":130,"y":540,"wires":[["38679977.16dbc6"]]},{"id":"38679977.16dbc6","type":"link out","z":"c3b4a742.7ec8e8","name":"","links":["94b7dda8.2227c","5a9743c7.77e37c"],"x":415,"y":540,"wires":[]},{"id":"33524969.696fe6","type":"amazon-echo-device","z":"c3b4a742.7ec8e8","name":"Kinderzimmer Weinachtsbeleuchtung","topic":"zigbee.0.group_4","x":230,"y":580,"wires":[["f8fe003.a7ea2"]]},{"id":"f8fe003.a7ea2","type":"link out","z":"c3b4a742.7ec8e8","name":"","links":["94b7dda8.2227c","5a9743c7.77e37c"],"x":415,"y":580,"wires":[]},{"id":"b8c09fd9.f9b7f","type":"amazon-echo-device","z":"c3b4a742.7ec8e8","name":"Kueche Decke","topic":"zigbee.0.group_1","x":640,"y":500,"wires":[["773bb6db.03d6a8"]]},{"id":"773bb6db.03d6a8","type":"link out","z":"c3b4a742.7ec8e8","name":"","links":["94b7dda8.2227c","5a9743c7.77e37c"],"x":775,"y":500,"wires":[]},{"id":"79a3431c.7feeec","type":"ioBroker in","z":"c3b4a742.7ec8e8","name":"From ioBroker","topic":"0_userdata.0.AlexaToNodeRed.Output","payloadType":"value","onlyack":"","func":"all","gap":"","fireOnStart":"false","x":90,"y":100,"wires":[["bc1c9d7a.b276"]]},{"id":"bc1c9d7a.b276","type":"json","z":"c3b4a742.7ec8e8","name":"","property":"payload","action":"obj","pretty":true,"x":230,"y":100,"wires":[["f520be9d.1dc9"]]},{"id":"7b020572.fdc3bc","type":"amazon-echo-device","z":"c3b4a742.7ec8e8","name":"Stimmungslicht","topic":"zigbee.0.588e81fffee73f29","x":160,"y":260,"wires":[["7d9b5204.b6bcbc"]]},{"id":"7d9b5204.b6bcbc","type":"link out","z":"c3b4a742.7ec8e8","name":"","links":["94b7dda8.2227c","5a9743c7.77e37c"],"x":395,"y":260,"wires":[]},{"id":"6607386b.ae8ec8","type":"amazon-echo-device","z":"c3b4a742.7ec8e8","name":"Buero","topic":"","x":130,"y":300,"wires":[["c12425d0.763328","71c6f4eb.6105cc"]]},{"id":"309ff20.878b90e","type":"link out","z":"c3b4a742.7ec8e8","name":"","links":["94b7dda8.2227c","5a9743c7.77e37c"],"x":395,"y":300,"wires":[]},{"id":"c12425d0.763328","type":"change","z":"c3b4a742.7ec8e8","name":"Schreibtisch","rules":[{"t":"set","p":"topic","pt":"msg","to":"wled.0.600194397548","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":300,"wires":[["309ff20.878b90e"]]},{"id":"71c6f4eb.6105cc","type":"change","z":"c3b4a742.7ec8e8","name":"Stimmungslicht","rules":[{"t":"set","p":"topic","pt":"msg","to":"zigbee.0.588e81fffee73f29","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":340,"wires":[["309ff20.878b90e"]]},{"id":"4ebe2cf4.9c0ca4","type":"link in","z":"c3b4a742.7ec8e8","name":"","links":["bec28245.0485d"],"x":35,"y":220,"wires":[["12424426.64e0cc"]]},{"id":"bec28245.0485d","type":"link out","z":"c3b4a742.7ec8e8","name":"","links":["4ebe2cf4.9c0ca4","feeefb83.a07058","6b74fc29.886e94","4956d3ba.4fe6ac","923c2f60.a9e7b","eafe64cc.9f0a88","6bc19740.053f58","924f5827.4f8748","5a81cd46.c47ba4","46fd591d.2052b8","5e857a86.953c64"],"x":515,"y":100,"wires":[]},{"id":"feeefb83.a07058","type":"link in","z":"c3b4a742.7ec8e8","name":"","links":["bec28245.0485d"],"x":35,"y":260,"wires":[["7b020572.fdc3bc"]]},{"id":"6b74fc29.886e94","type":"link in","z":"c3b4a742.7ec8e8","name":"","links":["bec28245.0485d"],"x":35,"y":300,"wires":[["6607386b.ae8ec8"]]},{"id":"4956d3ba.4fe6ac","type":"link in","z":"c3b4a742.7ec8e8","name":"","links":["bec28245.0485d"],"x":495,"y":220,"wires":[["71a7122.e1281ec"]]},{"id":"923c2f60.a9e7b","type":"link in","z":"c3b4a742.7ec8e8","name":"","links":["bec28245.0485d"],"x":515,"y":460,"wires":[["f6239bff.1e5658"]]},{"id":"eafe64cc.9f0a88","type":"link in","z":"c3b4a742.7ec8e8","name":"","links":["bec28245.0485d"],"x":515,"y":500,"wires":[["b8c09fd9.f9b7f"]]},{"id":"6bc19740.053f58","type":"link in","z":"c3b4a742.7ec8e8","name":"","links":["bec28245.0485d"],"x":515,"y":540,"wires":[["268b65c2.91523a"]]},{"id":"924f5827.4f8748","type":"link in","z":"c3b4a742.7ec8e8","name":"","links":["bec28245.0485d"],"x":35,"y":460,"wires":[["31c81738.2c4878"]]},{"id":"5a81cd46.c47ba4","type":"link in","z":"c3b4a742.7ec8e8","name":"","links":["bec28245.0485d"],"x":35,"y":500,"wires":[["5f29e87d.624588"]]},{"id":"46fd591d.2052b8","type":"link in","z":"c3b4a742.7ec8e8","name":"","links":["bec28245.0485d"],"x":35,"y":540,"wires":[["b22939b9.2122f8"]]},{"id":"5e857a86.953c64","type":"link in","z":"c3b4a742.7ec8e8","name":"","links":["bec28245.0485d"],"x":35,"y":580,"wires":[["33524969.696fe6"]]}]

Viel Spaß beim probieren 🙂

Mit * markierte Links sind Amazon ParnerNet Affiliate Links


8 Kommentare

Marco · 5. Dezember 2021 um 17:05

Sehr coole Script,

könnte man auch sonoff (Tasmota) Geräte mit den Sonoff Adapter (Mqtt) steuern
Habe da eine Zeile eingefügt aber die funktioniert nicht :
sonoff: { bri:“, hue:“, ct:“, on:’True‘ }

    Marco · 5. Dezember 2021 um 17:10

    Meine sehr cooles Script,
    habe den Fehler gefunden die Zeile ist :
    sonoff: { bri:“, hue:“, ct:“, on:’POWER‘ }

      IdleBit · 5. Dezember 2021 um 18:14

      Topp, hast es ja schon herausgefunden 🙂

Kai · 9. November 2021 um 08:18

Wenn ich über den Alexa Zigbee Hub Geräte verbunden habe, kann ich dann auch außerhalb (bspw. über einen Raspberry PI mit node red) auf diese zugreifen?

schraubzwinge · 16. Oktober 2021 um 09:00

Hallo,
klingt super! Wo ist denn dein Zigbee gateway?
Kann ich das gateway aus einer alexa echo show 8 nutzen um über iobroker zu steuern? bzw weisst du ob das alexa gateway auch ohne Internet geht? Oder muss zwingend das gateway am iobroker hängen?
damge.

    IdleBit · 16. Oktober 2021 um 23:41

    Alexa braucht immer Internet, da die Intelligenz von Alexa in der Cloud bei Amazon hängt.
    Und ja das Gateway muss an ioBroker hängen.

Markus · 18. September 2021 um 08:32

Hallo tolles Script !!! DANKE
Was muss ich zu Alexa sagen das sie die Farbtemperatur ändert??

    IdleBit · 18. September 2021 um 15:23

    Schön das es gefällt.

    Sagen musst Du da z.B. „Alexa Deckenlampe wärmer“ oder „Alexa Deckenlampe kälter“.

Schreibe einen Kommentar

Avatar-Platzhalter

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.