Ankündigung

Einklappen
Keine Ankündigung bisher.

Amazon-Echo Logikbaustein

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

    Zitat von Hightech Beitrag anzeigen
    Hallo Frank!

    Irgendwie wird der Thread hier etwas unübersichtlich bzw. ich habe den Anschluss verloren - kannst Du noch mal kurz zusammenfassen, warum Du einen neuen Logikbaustein bauen willst? In meinen Augen bietet der von Werner alles, was man benötigt? Bin irgendwie zu blind, den Unterschied zu sehen?

    Danke und Grüße
    Olaf
    Hallo Olaf (und alle anderen),

    ich bin der Meinung dass das Echo alles mitbringt um die aktuellen Funktionen auch ohne Lambda, externe Freischaltung und ähnliches abzuwickeln. Die beste, derzeit verfügbare, Lösung ist die Ha-Bridge. Dies ist eine Software die Separat installiert werden muss und eine Hue Bridge emuliert, sprich das Discovery im internen Netzwerk abwickelt und die Requests die vom Echo kommen so übersetzt das hinten raus irgendwas anderes gesprochen werden kann. Nun kommt mein (ziemlich verdorrtes) Admin und Entwicklerherz zum Vorschein das mir sagt "Irgendwie ist es doof dinge an mehreren Stellen konfigurieren zu müssen".

    Da kommt nun der neue Logikbaustein in Spiel. Aktuell bin ich in einer Proof Of Concept phase bei der ich eine proxylösung baue (in Java) die die Konfiguration aus dem aktuellen Logikbaustein ausliest und so aufbereitet das Echo damit was anfangen kann (mehr dazu später). Wenn ich das irgendwann vollständig am laufen habe möchte ich mich mit Werner zusammensetzen und schauen ob wir die notwendigen Abläufe direkt in den Logikbaustein integrieren können um somit komplett auf externe Software verzichten zu können.

    Disclaimer: Nach bisherigem Kenntnisstand unterstützt das Echo nur Steckdosen und Lampen. Es gibt zwar auch Raumthemostate von Nest die angeblich kompatibel sind, ich weiss aber noch nicht wie diese dinger discovered oder angesprochen werden.


    Nun zum bisherigen Arbeitsstand:
    Ich habe es heute das erste mal geschafft das mein Echo ein von mir definiertes Gerät gefunden und angesprochen hat (wie gesagt, ohne lamba, externe portfreischaltung oder ähnliches!). *freu*

    Ablauf bisher ist wie folge:

    Kommando: "Alexa, finde Geräte"

    Das Echo sendet einen UDP Broadcast an 239.255.255.250:1900 mit folgendem Inhalt:
    Code:
    M-SEARCH * HTTP/1.1
    HOST: 239.255.255.250:1900
    MAN: "ssdp:discover"
    MX: 15
    ST: urn:schemas-upnp-org:device:basic:1
    
    xml
    OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
    01-NLS: d87ea11e-1dd1-11b2-8504-89dd041dbb93
    NT: urn:microsoft.com:service:X_MS_MediaReceiverRegistrar:1
    NTS: ssdp:alive
    SERVER: Linux/3.2.40, UPnP/1.0, Portable SDK for UPnP devices/1.6.18
    X-User-Agent: redsonic
    USN: uuid:0011322a-f9ad-0011-adf9-adf92a321100::urn:microsoft.com:service:X_MS_MediaReceiverRegistrar:1
    Darauf antworte ich mittels UDP direkt an das Gerät (bei mir war es immer port 50000)
    Code:
    HTTP/1.1 200 OK
    CACHE-CONTROL: max-age=100
    EXT:
    LOCATION: http://10.18.91.73:4711/description.xml
    SERVER: Linux/3.14.0 UPnP/1.0 IpBridge/1.15.0
    hue-bridgeid: 20CF30FFFE19ADE2
    ST: urn:schemas-upnp-org:device:basic:1
    USN: uuid:2f402f80-da50-11e1-9b23-20cf3019ade2
    Daraufhin versucht das Echo unter der in "LOCATION" angegebenen Adresse per TCP die description.xml abzurufen
    Request vom Echo:
    Code:
    GET /description.xml HTTP/1.1
    Host: 10.18.91.73:4711
    Accept: */*
    Ich antworte mit
    Code:
    HTTP/1.1 200 OK
    CONTENT-LENGTH: 469
    CONTENT-TYPE: text/xml; charset="utf-8"
    DATE: Tue Feb 14 22:55:58 CET 2017
    EXT:
    SERVER: Unspecified, UPnP/1.0, Unspecified
    X-User-Agent: redsonic
    
    <?xml version="1.0"?>
    <root xmlns="urn:schemas-upnp-org:device-1-0">
    <URLBase>http://10.18.91.73:4711</URLBase>
    <device>
      <deviceType>urn:schemas-upnp-org:device:DimmableLight:1</deviceType>
      <friendlyName>wurstblinker</friendlyName>
      <manufacturer>Royal Philips Electronics</manufacturer>
      <modelName>Philips hue bridge 2012</modelName>
      <modelNumber>929000226503</modelNumber>
      <UDN>uuid:2f402f80-da50-11e1-9b23-20cf3019ade2</UDN>
    </device>
    </root>
    Als nächstes folgen die Hue-typischen API requests um die vorhandenen Geräte auszulesen. Es werden zwei relevante Calls abgesetzt, wobei es bei mir bisher gereicht hat nur auf einen zu Antworten:

    Request vom Echo:
    Code:
    GET /api/WArFWYfmKONr23IFa1Kf9MZbzBmMJtZaPR0NiTiA/lights HTTP/1.1
    Host: 10.18.91.73:4711
    Accept: */*
    Meine Response:
    Code:
    HTTP/1.1 200 OK
    CONTENT-LENGTH: 513
    CONTENT-TYPE: text/xml; charset="utf-8"
    DATE: Tue Feb 14 22:55:59 CET 2017
    EXT:
    SERVER: Unspecified, UPnP/1.0, Unspecified
    X-User-Agent: redsonic
    
    {
        "1": {
        "state": {
            "on": false,
            "bri": 0,
            "hue": 0,
            "sat": 0,
            "xy": [0,0],
            "ct": 0,
            "alert": "none",
            "effect": "none",
            "colormode": "hs",
            "reachable": true
        },
        "type": "Extended color light",
        "name": "Wurstblinker",
     "uniqueid": "726abc7f-27db-4936-abd2-505830a73b31",
        "modelid": "LCT001",
        "swversion": "65003148",
        "pointsymbol": {
            "1": "none",
            "2": "none",
            "3": "none",
            "4": "none",
            "5": "none",
            "6": "none",
            "7": "none",
            "8": "none"
        }
    }}
    Diese Response kann auch mehrere Geräte beinhalten.


    Nach ablauf der Suchzeit (20 sekunden) meldet Alexa "Ich habe ein Smarthomegerät gefunden" und das gefundene Gerät wird in der Alexa App dargestellt.

    Nun kann ich meinem Echo den Befehl geben "Alexa, schalte Wurstblinker ein" woraufhin der folgende Request abgesetzt (aber aktuell von mir noch nicht beantwortet) wird:

    Code:
    PUT /api/WArFWYfmKONr23IFa1Kf9MZbzBmMJtZaPR0NiTiA/lights/1/state HTTP/1.1
    Host: 10.18.91.73:4711
    Accept: */*
    Content-type: application/x-www-form-urlencoded
    Content-Length: 12
    
    {"on": true}
    Wenn ich diesen Request korrekt behandle, sollte Alexa mit einem "OK" antworten.


    Ich hatte eben noch einen zweiten Request erwähnt, den ich im Moment nicht verarbeite. Dabei handelt es sich um einen Request zum vollständigen Abruf eines Hue Datastores siehe auch -> https://www.developers.meethue.com/d...tate_datastore

    Ausblick:
    Die Hue API ist mächtiger als ich bisher dachte. Ich weiß nicht was Echo alles integriert hat, aber abgesehen von Dimmen sollten grundsätzlich auch Farbänderungen möglich sein (ich habe tatsächlich einige RGB LED Stripes im Einsatz). Hierbei wäre allerdings einiges an Umrechnung erforderlich, da im KNX die RGB Ansteuerung über 3 Gruppenadressen erfolgt, hue aber nur einen Integer sendet. Mehr infos -> https://www.developers.meethue.com/d...et_light_state

    Ich werde die Software erstmal soweit bringen das die wirklich als vollfunktionsfähiger Proxy agiert und dann mal mit Werner sprechen ob die wir Logik etwas weiter aufbohren können. Ich bin im moment skeptisch ob das ganze UDP/TCP Handling wirklich in den Logikbaustein integriert werden kann/sollte.

    Gruß
    Frank
    Mein Bus; 2 Linien bestehend aus Gira USB Schnitstelle, B&J Linienkoppler, 3* Gira Dali GW, 6*B&J Dimmaktoren (4K), 4*B&J Jalousienaktor (26K), 1*MDT Schaltaktor (20K), 2*B&J Ventilantriebsaktoren (18K), 8*B&J Binäreingang (66K), 6 Gira Präsenzmelder, 5*B&J RTR, 22*B&J Tastsensoren, Wiregate und Gira Homeserver

    Kommentar


      Hi Yves,

      glad to hear you got it working.
      Thanks for planing to make a donation, this makes it easier for me to find arguments for my wife to work on the version 0.4.

      If you need further assistance, just ask.

      Best regards
      Werner

      Kommentar


        Ich verstehe nicht ganz, welche Teile hier alle an der Kommunikation beteiligt sind. Kann das mal jemand aufzeichnen?
        Aus meiner Sicht wäre es außerdem sinnvoll die Ressourcen hier im Forum zu bündeln und einen skill zu entwickeln, dessen Rückmeldung dann von verschiedenen Systemen im Heimnetzwerk verarbeitet werden kann. Sei es ein gira home server, ein edomi, openhub, pi oder wiregate. Ist sowas nicht möglich?

        Kommentar


          Hi Frank,

          ich bin mir auch nicht sicher, ob es vielleicht mehr Sinn machen würde, deine Arbeit in einen eigenen Baustein fließen zu lassen.
          Falls hierfür Teile von meinem Baustein hilfreich sein sollten, könnten diese von meiner Seite aus, auch verwendet werden.

          Ich sehe zwar den technischen Vorteil deines Ansatzes (kein SSL-Certificate und Portfreigabe bzw. kein SQS-Proxy nötig), aber der große überwiegende Nachteil für mich ist, dass ich den Custom Skill nicht mehr nutzen könnte.
          Ich bin mir auch nicht sicher, welchen Weg Amazon in Zukunft beim Smart-Home Skill beschreitet. Meine Vermutung ist jedoch, dass es evtl. für gewisse kommende Smart-Home API Funktionen keine eigene Implementierung mehr (wie z.B. die Umsetzung der HUE-API) im Echo/Dot selbst geben könnte. D.h. man müsste dann auf diese Funktionalität verzichten, oder doch wieder auf eine externe Implementierung wie z.B. der Lambda-Funktion bauen.

          Viele Grüße
          Werner

          P.S.: Nach anfänglichen kleineren Problemen, habe ich die Anbindung bei mir jetzt seit einigen Tagen per "Amazon SQS – Message Queuing Service" stabil am Laufen (d.h. die Anbindung benötigt kein Self-Signed-Certificate und keine Portfreigabe mehr). Allerdings muss dafür ein zugehöriger SQS-Proxy im lokalen Netz auf einem anderen Rechner laufen. Die anfänglichen Probleme kamen unter anderem, von der Node.js SQS-Proxy Implementierung, die ich im Netz gefunden habe.
          Nachdem ich diese durch eine eigene Java Implementierung ersetzt habe, läuft es stabil und ich kann auch keinen Performance unterschied feststellen.

          Kommentar


            Hallo SirTobiIV,
            nachdem ich sowieso noch vor hatte Bildchen zu malen (nicht besonders schön aber vielleicht informativ), anbei die drei Anbindungsvarianten ohne Gewähr auf Richtigkeit:

            anbindungVarianteA.png

            anbindungVarianteB.png

            anbindungVarianteC.png

            Prinzipiell gebe ich dir recht, dass es sinnvoll sein könnte, die Resourcen zu bündeln, aber die Anforderungen, Wünsche und Vorstellungen der Entwickler(-teams) dann unter einen Hut zu bringen stelle ich mir schwierig vor.

            Viele Grüße
            Werner

            Kommentar


              Hello everybody!

              First of all, sorry for the English but I think this is better than Google Translate German..
              I tried to follow the complete wiki on GitHub and thought it was all doing fine. All the tests went well except the last and most important test. The Echo won't recognize any devices to control. Is there anything I need to focus on in particular? Is there anything I can check to see if the script is executed when I click on the 'Discover Devices' button in the Alexa app? I did not configure the Self Signed SSL, is this an absolute requisite for the Echo to discover the devices?

              Thank you for your help!

              Greetings Ben

              Kommentar


                Hi Ben,

                the Lambda-Function uses https to connect to the Gira "Logikbaustein", so in V0.3 it is an absolute requirement to configure a SSL certificate (portforwarding without SSL isn't recommended).
                Did you also do the test "2.3.1 Test der AWS Anbindung"? I think this test can't succeed without SSL - or has it?

                In the next upcoming V0.4, you could use variant B) "Amazon SQS – Message Queuing Service" as an alternative to variant A) "SSL/Portforwarding" (both variants are explained in the picture above). But I can't tell you when V0.4 will be released.

                Best regards
                Werner

                P.S:: I forgot to mention, that in that case you need a separate hardware (Synology, Raspberry, ...) to run the SQS-Proxy. As it is not possible to run it on the Gira Homeserver.
                Zuletzt geändert von wernerL; 15.02.2017, 16:54.

                Kommentar


                  Hi Werner

                  Thanks for the quick response! The test did succeed but I received a 'null' response. Maybe that means it in fact did not succeed.. Either way, the next thing to do is configure the SSL. Therefore the only thing to do is put the .cert file in the hsupload folder right? Then retransfer the data to the HS. Do I have to do something extra on the Amazon side?

                  greets
                  Ben

                  Kommentar


                    Hi Ben,

                    no, there is nothing extra to be done on the Amazon side.
                    You only have to put the .cert file named "amazonEchoSSL.cert" (case sensitive) in the hsupload folder.
                    Make sure that you have enabled the transfering of files for the hsupload folder in the Gira Experte (see also post #327 in this thread)

                    After uploading the cert, have a look in the log of the Logikbaustein. Homeserver debug webpage => Amazon Echo Service => log.

                    You should see something like:
                    Amazon Echo Service - Logfile

                    Loglevel = 3 (Info)
                    2017-02-08 10:24:55 | SYS Amazon Echo Service V0.4 vom 07.02.2017 09:53 - (Python Version: (2, 6, 6, 'final', 0) Default Encoding:ascii)
                    2017-02-08 10:24:55 | SYS Initiate 20 seconds delay for HS to be fully up and running ...
                    2017-02-08 10:25:15 | SYS Initialize Amazon Echo Service.
                    2017-02-08 10:25:15 | SYS SSL certificate loaded successfully - writing it to file '/tmp/amazonEchoSSL.cert'.
                    2017-02-08 10:25:15 | INFO Appliances configuration successfully loaded.
                    2017-02-08 10:25:15 | SYS Starting Amazon Echo Service.


                    Good luck.
                    Werner

                    Kommentar


                      Hello Werner,

                      The problem i have now is that i have no devices found in the Alexa app.
                      This is the log file from the "Baustein"
                      2017-02-14 20:21:02 | SYS Amazon Echo Service V0.3 vom 16.01.2017 04:17 - (Python Version: (2, 6, 6, 'final', 0) Default Encoding:ascii) 2017-02-14 20:21:02 | SYS Initiate 20 seconds delay for HS to be fully up and running ... 2017-02-14 20:21:22 | SYS Initialize Amazon Echo Service. 2017-02-14 20:21:22 | SYS SSL certificate loaded successfully - writing it to file '/tmp/amazonEchoSSL.cert'. 2017-02-14 20:21:22 | WARN Appliances configuration is empty. 2017-02-14 20:21:22 | SYS Starting Amazon Echo Service. 2017-02-15 08:01:49 | ERROR Unhandled exception occured: 2017-02-15 08:01:49 | ERROR Traceback (most recent call last): File "<13626_Amazon Echo (13626)>", line 679, in do_REQ File "<13626_Amazon Echo (13626)>", line 208, in discovery AttributeError: 'unicode' object has no attribute 'get' 2017-02-15 20:45:22 | SECUR Attempt to access service with no access token. Thanks Best Regards Yves

                      Kommentar


                        Hi all!

                        So the SSL was imported correctly, now I can acces the discovery and so on via https: https://xxx.giradns.com:4002/discove...geId=undefined.
                        Log file from HomeServer Amazon Echo:
                        Code:
                        [B]Loglevel = 2 (Warn)[/B]
                        2017-02-16 09:44:52 | SYS Amazon Echo Service V0.3 vom 16.01.2017 04:17 - (Python Version: (2, 6, 6, 'final', 0) Default Encoding:ascii)
                        2017-02-16 09:44:52 | SYS Initiate 20 seconds delay for HS to be fully up and running ...
                        2017-02-16 09:45:12 | SYS Initialize Amazon Echo Service.
                        2017-02-16 09:45:12 | SYS SSL certificate loaded successfully - writing it to file '/tmp/amazonEchoSSL.cert'.
                        2017-02-16 09:45:12 | SYS Starting Amazon Echo Service.
                        But unfortunately Alexa does not find any devices.

                        This is the output when I try the discovery test in the Lambda function:
                        Code:
                        {
                        "header": {
                        "payloadVersion": "2",
                        "namespace": "Alexa.ConnectedHome.Discovery",
                        "name": "DiscoverAppliancesResponse",
                        "messageId": "undefined"
                        },
                        "payload": {
                        "discoveredAppliances": [
                        {
                        "modelName": "n.a.",
                        "actions": [
                        "incrementTargetTemperature",
                        "decrementTargetTemperature",
                        "setTargetTemperature"
                        ],
                        "friendlyDescription": "Showroom",
                        "version": "1.0",
                        "manufacturerName": "n.a.",
                        "friendlyName": "Showroom",
                        "applianceId": "1",
                        "isReachable": true
                        },
                        {
                        "modelName": "n.a.",
                        "actions": [
                        "turnOn",
                        "turnOff",
                        "incrementPercentage",
                        "decrementPercentage",
                        "setPercentage"
                        ],
                        "friendlyDescription": "Showroom Table",
                        "version": "1.0",
                        "manufacturerName": "n.a.",
                        "friendlyName": "Showroom Table",
                        "applianceId": "1_1",
                        "isReachable": true
                        }
                        ]
                        }
                        }
                        This seems like it is working fine.
                        By the way, I only have loglevel 2 on the HomeServer. How do you get access to loglevel 3? EDIT: This number is going up when the service is working properly isn't it?

                        Also for the ports, I used the same port in my internal network as in the external network. So I had my router setup to forward 4002 to 4002. I don't think this is a problem?

                        Thanks in advance!
                        Ben
                        Zuletzt geändert von BenGee; 16.02.2017, 10:43.

                        Kommentar


                          Hi Ben,

                          the output looks fine.
                          Here are some things to check:
                          • you have activated your skill and successfully finished the account linking in the Alexa App? The Gira HS Smart-Home skill must be listed under the menu entry Smart Home. This is documented in the Wiki under "4. Hinzufügen des Smart Home Skills über die Alexa App" (How to add your Smart-Home Skill with the Alexa App).
                          • Have you also tried to find your devices by the Alexa website or only in the Android, iOS Alexa App?
                          • Please check, that you have entered the correct "arn" of your Lambda-Funtion.
                            Go to Amazon Developer Console -> Alexa -> Alexa Skills kit -> Gira HS Smart Home (how you named the skill) -> Configuration -> Service Endpoint something like (arn:aws:lambda:eu-west-1:XXXXXXXXX::function:GiraHS)
                          • Can you look in the Cloudwatch logs of the lambda function (AWS Console), if there are any messages when you start the device discovery.
                          • If you do, also check the logs of the "Logikbaustein".


                          You can set the loglevel with input E4 of the "Logikbaustein".

                          Greetings
                          Werner

                          Kommentar


                            Hi Ben,

                            no you have to set the loglevel manually and no there is no problem, if you use the same port number for both sides.

                            Since, you got the correct output by invoking the test event of the lambda function, the connection betweem the lambda function and the "Logikbaustein" is working fine (so is your portforwarding and the ssl connection).
                            The problem must be before somwhere before the Lambda-Function.

                            Greetings
                            Werner

                            Kommentar


                              Hi Werner

                              So the skill is listed in the menu entry Smart Home and I have tried finding devices on both iOS and the Alexa website without succes.
                              The only logs I get to see in the Cloudwatch are those I did myself with testing the lambda function but nothing from the Alexa discovery itself.
                              Here is the log of the "Logikbaustein", it looks fine to me:
                              Code:
                              [B]Loglevel = 3 (Info)[/B]  
                               2017-02-16 10:49:37 | SYS   Amazon Echo Service V0.3 vom 16.01.2017 04:17  -  (Python Version: (2, 6, 6, 'final', 0) Default Encoding:ascii)
                              2017-02-16 10:49:37 | SYS   Initiate 20 seconds delay for HS to be fully up and running ...
                              2017-02-16 10:49:57 | SYS   Initialize Amazon Echo Service.
                              2017-02-16 10:49:57 | SYS   SSL certificate loaded successfully - writing it to file '/tmp/amazonEchoSSL.cert'.
                              2017-02-16 10:49:57 | INFO  Appliances configuration successfully loaded.
                              2017-02-16 10:49:57 | SYS   Starting Amazon Echo Service.
                              I am going to check everything from scratch to see if everything is correct.
                              So the problem is between the Skill and the Lambda function?
                              Another question since I really don't understand German very well. Is it a problem that I still have the Alexa Skills Kit trigger enabled as well as the Smart Home trigger?
                              I also have my Echo setup in English, is that a problem for the discovery?

                              Greetings
                              Ben
                              Zuletzt geändert von BenGee; 16.02.2017, 11:35.

                              Kommentar


                                Hi Ben,

                                the problem is somewhere before the Lambda function.
                                • It could be between the Skill and the Lambda function, but if you checked that you entered the correct Lambda-Function ARN in the Configuration tab of your Smat Home skill and you checked that you use the same regions for both I doubt it. You also checked, that you have added the trigger for the Smart-Home Skill and the trigger is enabled?
                                • It could also be between the Echo/Alexa App and the Skill (Skill not activated, Account Linking not working, Security profiles wrong, ...)

                                No, it's not a problem to have both triggers enabled.

                                To be honest, I never tested it with an "Echo" which is setup to use English.
                                You have chosen "English" in the Skill information page when you setup the skill?

                                I will setup one of my Echo's to use english in the next days to see if there is a specific problem here.

                                Greetings
                                Werner


                                Kommentar

                                Lädt...
                                X