# \[TP-Link\] Entwicklung neuer Dienst

**URL:** <https://community.gladysassistant.com/t/tp-link-developpement-nouveau-service/5747>\
**Category:** Développement\
**Created:** [15. November 2020 um 14:24 UTC](https://community.gladysassistant.com/t/tp-link-developpement-nouveau-service/5747 "2020-11-15T14:24:45Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![cicoub13](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/cicoub13/32/4482_2.png) [@cicoub13](https://community.gladysassistant.com/u/cicoub13)\
**Post date:** [15. November 2020 um 14:24 UTC](https://community.gladysassistant.com/t/tp-link-developpement-nouveau-service/5747/1 "2020-11-15T14:24:46Z")

</div>

Hallo,

Ich habe mit der Entwicklung des TP-Link-Moduls begonnen, um die Steckdosen und Lampen dieser Marke zu integrieren.

Ihr könnt das mit diesem Pull-Request testen und alle Kommentare sind willkommen 😄

> <https://github.com/GladysAssistant/Gladys/pull/957>
>
> \### Pull Request check-list
> 
> To ensure your Pull Request can be accepted as fa…st as possible, make sure to review and check all of these items:
> 
> \- \[x\] If your changes affects code, did your write the tests? 
> \- \[x\] Are tests passing? (\`npm test\` on both front/server)
> \- \[x\] Is the linter passing? (\`npm run eslint\` on both front/server)
> \- \[x\] Did you run prettier? (\`npm run prettier\` on both front/server)
> \- \[x\] If you are adding a new features/services, did you run integration comparator? (\`npm run compare-translations\` on front)
> \- \[x\] If your changes modify the API (REST or Node.js), did you modify the API documentation? (Documentation is based on comments in code)
> \- \[X\] If you are adding a new features/services which needs explanation, did you modify the user documentation? See \[the GitHub repo\](https://github.com/GladysAssistant/v4-website) and the \[website\](https://gladysassistant.com). https://github.com/GladysAssistant/v4-website/pull/28
> \- \[X\] Did you add fake requests data for the demo mode (\`front/src/config/demo.json\`) so that the demo website is working without a backend? (if needed) See \[https://demo.gladysassistant.com\](https://demo.gladysassistant.com).
> 
> NOTE: these things are not required to open a PR and can be done afterwards / while the PR is open.
> 
> \### Description of change
> 
> I worked on adding TP Link service to control plugs and bulbs. I used https://github.com/plasticrake/tplink-smarthome-api library to control devices.
> 
> Documentation and tests are ✅ 
> 
> \[GIF of integration working\](https://recordit.co/wpaPxyxGpu)
> 
> \### Main concerns
> 
> \* I don't like the way I developped discovery service : https://github.com/cicoub13/Gladys/blob/tplink/server/services/tp-link/lib/smart-device/smart-device.getDevices.js#L16 =\> Tested and working. There is no other way with this devices.
> \* I can't test with bulbs because I don't have =\> Done with the help of Will9
> \* In frontend, I grouped Setup and Devices page because TP Link does not require any setup. Devices are discoverable on the network. =\> I think it's the good way to handle this kind of devices.

---

<div class="post-metadata">

**Author:** ![cicoub13](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/cicoub13/32/4482_2.png) [@cicoub13](https://community.gladysassistant.com/u/cicoub13)\
**Post date:** [15. November 2020 um 14:27 UTC](https://community.gladysassistant.com/t/tp-link-developpement-nouveau-service/5747/2 "2020-11-15T14:27:50Z")

</div>

Ping @Will9 @JPL @Boimb @damalgos @bouillou7 @Jap93

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [16. November 2020 um 08:35 UTC](https://community.gladysassistant.com/t/tp-link-developpement-nouveau-service/5747/3 "2020-11-16T08:35:33Z")

</div>

Top @cicoub13 herzlichen Glückwunsch zu dieser Entwicklung 🙂

Ich freue mich darauf, diesen Service in Gladys Assistant laufen zu sehen

---

<div class="post-metadata">

**Author:** ![Will9](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/w/ebca7d/32.png) [@Will9](https://community.gladysassistant.com/u/Will9)\
**Post date:** [16. November 2020 um 14:07 UTC](https://community.gladysassistant.com/t/tp-link-developpement-nouveau-service/5747/4 "2020-11-16T14:07:58Z")

</div>

Hallo  
Cool, ich habe gerade vier Tplink-WLAN-Lampen ^^  
Muss ich warten, bis der PR gemerged wird, oder gibt es einen Trick, um sie vorher zu integrieren?

---

<div class="post-metadata">

**Author:** ![AlexTrovato](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/alextrovato/32/10705_2.png) [@AlexTrovato](https://community.gladysassistant.com/u/AlexTrovato)\
**Post date:** [16. November 2020 um 17:17 UTC](https://community.gladysassistant.com/t/tp-link-developpement-nouveau-service/5747/5 "2020-11-16T17:17:47Z")

</div>

Es ist möglich, ein Testbild aus seinem Branch zu generieren.

---

<div class="post-metadata">

**Author:** ![cicoub13](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/cicoub13/32/4482_2.png) [@cicoub13](https://community.gladysassistant.com/u/cicoub13)\
**Post date:** [18. November 2020 um 13:27 UTC](https://community.gladysassistant.com/t/tp-link-developpement-nouveau-service/5747/6 "2020-11-18T13:27:02Z")

</div>

Hallo, ich habe ein Docker-Image für alle Architekturen erstellt: [https://hub.docker.com/repository/registry-1.docker.io/cicoub13/gladys/tags?page=1](https://hub.docker.com/repository/registry-1.docker.io/cicoub13/gladys/tags?page=1)

Falls ihr testen wollt:

```
docker run -d \
--log-opt max-size=10m \
--restart=always \
--privileged \
--network=host \
--name gladys-tp-link \
-e NODE_ENV=production \
-e SERVER_PORT=1080 \
-e TZ=Europe/Paris \
-e SQLITE_FILE_PATH=/var/lib/gladysassistant/gladys-tplink.db \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /var/lib/gladysassistant:/var/lib/gladysassistant \
-v /dev:/dev \
cicoub13/gladys:dev-tp-link

```

---

<div class="post-metadata">

**Author:** ![VonOx](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/vonox/32/10128_2.png) [@VonOx](https://community.gladysassistant.com/u/VonOx)\
**Post date:** [18. November 2020 um 13:44 UTC](https://community.gladysassistant.com/t/tp-link-developpement-nouveau-service/5747/7 "2020-11-18T13:44:59Z")

</div>

Ich habe den Befehl bearbeitet, um die Produktionsdatenbank nicht zu überschreiben und einen anderen Port zu verwenden.

---

<div class="post-metadata">

**Author:** ![Will9](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/w/ebca7d/32.png) [@Will9](https://community.gladysassistant.com/u/Will9)\
**Post date:** [20. November 2020 um 12:03 UTC](https://community.gladysassistant.com/t/tp-link-developpement-nouveau-service/5747/8 "2020-11-20T12:03:47Z")

</div>

Hallo  
ich habe gerade dein Bild getestet

Keine Geräte gefunden. Stellen Sie sicher, dass Sie einen TP-Link-Stecker mit Ihrem WLAN verbunden haben.

Er erkennt keine Glühbirne in meinem Netzwerk  
Der Raspberry ist im selben Netzwerk wie die Glühbirnen und der Ping funktioniert sehr gut zwischen ihnen  
Was brauche ich zum Debuggen?

---

<div class="post-metadata">

**Author:** ![cicoub13](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/cicoub13/32/4482_2.png) [@cicoub13](https://community.gladysassistant.com/u/cicoub13)\
**Post date:** [20. November 2020 um 18:18 UTC](https://community.gladysassistant.com/t/tp-link-developpement-nouveau-service/5747/9 "2020-11-20T18:18:37Z")

</div>

Mist. Kannst du diese beiden Befehle ausführen und mir das Ergebnis geben?

Verbindung zur Docker-Instanz:  
`docker exec -it gladys-tp-link /bin/ash`

Suche nach Geräten im Netzwerk (dauert 10 Sekunden):  
`./services/tp-link/node_modules/.bin/tplink-smarthome-api search`

---

<div class="post-metadata">

**Author:** ![Will9](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/w/ebca7d/32.png) [@Will9](https://community.gladysassistant.com/u/Will9)\
**Post date:** [21. November 2020 um 05:09 UTC](https://community.gladysassistant.com/t/tp-link-developpement-nouveau-service/5747/10 "2020-11-21T05:09:54Z")

</div>

Hallo  
Hier ist das Ergebnis:

┌┼─┤ pi @ gladys ─┤├─ 09:06:43 ─┤(1200Mhz:61.8’C)  
└┼─┤ ~ | $ ▶docker exec -it gladys-tp-link /bin/ash  
/src/server # ./services/tp-link/node\_modules/.bin/tplink-smarthome-api search  
Searching…  
startDiscovery({  
discoveryInterval: 2000,  
discoveryTimeout: 10000,  
breakoutChildren: true,  
broadcast: ‹&nbsp;255.255.255.255&nbsp;›  
})  
LB120(EU) bulb IOT.SMARTBULB 192.168.1.22 9999 50C7BFEFFFBA 8012059DA69A4DBED01168CE56FA04F018D122A6 Chambre  
LB100(EU) bulb IOT.SMARTBULB 192.168.1.23 9999 50C7BFA361C8 801236FAD6778A0D8E460CF84E7D2BC4189AA1E8 Cuisine  
LB100(EU) bulb IOT.SMARTBULB 192.168.1.21 9999 50C7BFDAD944 8012C22D7A9D34CF0AEABD83255C2B6A18C57DCC Salon  
/src/server #

Da sind alle drei Lampen ^^

---

<div class="post-metadata">

**Author:** ![cicoub13](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/cicoub13/32/4482_2.png) [@cicoub13](https://community.gladysassistant.com/u/cicoub13)\
**Post date:** [21. November 2020 um 15:18 UTC](https://community.gladysassistant.com/t/tp-link-developpement-nouveau-service/5747/11 "2020-11-21T15:18:14Z")

</div>

Danke für den Test 🙂  
Ich habe einen Weg gefunden, um Lampen zu simulieren, und es gab einen Fehler in der Geräteerkennung.  
Ich habe ein neues Image mit dem Fix veröffentlicht 🐋

Du kannst die folgenden Befehle ausführen, um zu testen:

```
docker stop gladys-tp-link
docker rm gladys-tp-link
docker pull cicoub13/gladys:dev-tp-link

```

Und den Befehl weiter oben, um einen neuen Container mit diesem Image zu starten (docker run …)

---

<div class="post-metadata">

**Author:** ![Will9](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/w/ebca7d/32.png) [@Will9](https://community.gladysassistant.com/u/Will9)\
**Post date:** [21. November 2020 um 17:44 UTC](https://community.gladysassistant.com/t/tp-link-developpement-nouveau-service/5747/12 "2020-11-21T17:44:47Z")

</div>

Kein Problem

Neuer Test mit dem neuen Bild, es ist viel besser geworden 😁  
Alles funktioniert, außer dass ich mehrmals neu laden musste, um die 3 Lampen zu erhalten (insgesamt 3 Mal)  
Beim ersten Mal hat er 2 gesehen (Schlafzimmer, Wohnzimmer)  
Beim zweiten Mal nur eine (Wohnzimmer)  
Und die letzte beim dritten Mal (Küche) 😅

Danke

---

<div class="post-metadata">

**Author:** ![Will9](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/w/ebca7d/32.png) [@Will9](https://community.gladysassistant.com/u/Will9)\
**Post date:** [21. November 2020 um 17:47 UTC](https://community.gladysassistant.com/t/tp-link-developpement-nouveau-service/5747/13 "2020-11-21T17:47:27Z")

</div>

Also für die Lampen, die man einfach ein- und ausschaltet?  
Gibt es keine Steuerung der Farbe und der Helligkeit? (0 bis 100 %)  
Ist das geplant oder nicht?

---

<div class="post-metadata">

**Author:** ![Tlse-vins](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/tlse-vins/32/6054_2.png) [@Tlse-vins](https://community.gladysassistant.com/u/Tlse-vins)\
**Post date:** [21. November 2020 um 18:43 UTC](https://community.gladysassistant.com/t/tp-link-developpement-nouveau-service/5747/14 "2020-11-21T18:43:04Z")

</div>

Das ist geplant, es gibt hier ein Feature:

> [@RGB-Lampenfarbe über das Dashboard steuern](https://community.gladysassistant.com/t/gestion-de-la-couleur-des-ampoules-rgb-depuis-le-dashboard/5535):
>
> Darüber haben wir schon mehrmals im Forum gesprochen und ich denke, das ist eine fehlende Option für die Besitzer von Farb-LEDs.

---

<div class="post-metadata">

**Author:** ![cicoub13](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/cicoub13/32/4482_2.png) [@cicoub13](https://community.gladysassistant.com/u/cicoub13)\
**Post date:** [21. November 2020 um 18:52 UTC](https://community.gladysassistant.com/t/tp-link-developpement-nouveau-service/5747/15 "2020-11-21T18:52:03Z")

</div>

Ich habe mich nur auf Ein/Aus für die Steckdosen und Lichter konzentriert.  
Es ist für mich ziemlich schwierig, die Funktionen für die Lichter ohne physische Geräte zu entwickeln 😅  
Ich werde wahrscheinlich die Integration und die Tests für die einfache Integration von TP-Link-Geräten abschließen.  
Und später neue Funktionen integrieren (basierend auf den Philips Hue, das sollte klappen).  
Was denkt ihr darüber?

Und wie @Tlse-vins sagt, bin ich mir nicht sicher, ob die Boxen/Dashboards für die Front bereit sind.

---

<div class="post-metadata">

**Author:** ![AlexTrovato](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/alextrovato/32/10705_2.png) [@AlexTrovato](https://community.gladysassistant.com/u/AlexTrovato)\
**Post date:** [21. November 2020 um 19:30 UTC](https://community.gladysassistant.com/t/tp-link-developpement-nouveau-service/5747/16 "2020-11-21T19:30:23Z")

</div>

Ein technisches Thema wurde im PR eröffnet. Das ist noch nicht für sofort.

---

<div class="post-metadata">

**Author:** ![cicoub13](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/cicoub13/32/4482_2.png) [@cicoub13](https://community.gladysassistant.com/u/cicoub13)\
**Post date:** [5. Dezember 2020 um 11:08 UTC](https://community.gladysassistant.com/t/tp-link-developpement-nouveau-service/5747/17 "2020-12-05T11:08:49Z")

</div>

Ich habe alle Entwicklungen, Tests und Dokumentationen abgeschlossen. PR ist bereit.  
Eure Tests und Reviews können beginnen 🚀 😅

---

<div class="post-metadata">

**Author:** ![VonOx](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/vonox/32/10128_2.png) [@VonOx](https://community.gladysassistant.com/u/VonOx)\
**Post date:** [5. Dezember 2020 um 12:44 UTC](https://community.gladysassistant.com/t/tp-link-developpement-nouveau-service/5747/18 "2020-12-05T12:44:47Z")

</div>

Ich habe eine HS110 (TP-Link Steckdose) gekauft, ich teste sie dieses Wochenende.

---

<div class="post-metadata">

**Author:** ![VonOx](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/vonox/32/10128_2.png) [@VonOx](https://community.gladysassistant.com/u/VonOx)\
**Post date:** [6. Dezember 2020 um 10:40 UTC](https://community.gladysassistant.com/t/tp-link-developpement-nouveau-service/5747/19 "2020-12-06T10:40:34Z")

</div>

@cicoub13 Ok mit dem Plug HS110

Planst du auch den Verbrauch zu erfassen?

---

<div class="post-metadata">

**Author:** ![cicoub13](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/cicoub13/32/4482_2.png) [@cicoub13](https://community.gladysassistant.com/u/cicoub13)\
**Post date:** [6. Dezember 2020 um 11:35 UTC](https://community.gladysassistant.com/t/tp-link-developpement-nouveau-service/5747/20 "2020-12-06T11:35:31Z")

</div>

Ah ja, einige Steckdosen melden den Verbrauch zurück.  
Sollte man eine Funktion vom Typ SWITCH.VOLTAGE hinzufügen?

Ich werde die zurückgemeldeten Informationen prüfen.

[Nächste Seite](https://community.gladysassistant.com/t/tp-link-developpement-nouveau-service/5747.md?page=2)
