mgcrea / homebridge-tydom

Homebridge plugin to manage Tydom hardware by Delta Dore from Apple HomeKit.
62 stars 13 forks source link

Ajout des Zigbee plugs #108

Closed Neo33ASM closed 1 year ago

Neo33ASM commented 1 year ago

Bonjour,

Depuis les nouvelles box, un réseau zigbee est possible, et Delta Dore propose à la vente des prises connectées. Voici l'extrait de log que cela m'a généré

2022-11-22T15:49:50.762Z homebridge-tydom Unknown hash=plug:2534c497ff8fb013a88da28d341adff5bc0ba77e1fc8ea8dcb8b8f1c9d62ce19 with firstUsage="plug" [11/22/2022, 4:49:50 PM] [Tydom] Unsupported firstUsage="plug" for endpoint with id="1669131055" 2022-11-22T15:49:50.763Z homebridge-tydom { endpoint: { id_endpoint: 1669131055, last_usage: 'plug', id_device: 1669131055, name: 'Prise 1', anticipation_start: false, picto: 'picto_smartplug', first_usage: 'plug' } }

On peut y voir le hash de la valeur ENDPOINTS_SIGNATURES_CATEGORIES dédiée à cette catégorie. Ce ne sont que de simples on/off, avec affichage de la consommation.

Cordialement

mgcrea commented 1 year ago

J'ai release la 0.22.0 qui essaye d'ajouter le support, pas sur que ça fonctionne vu que je n'ai pas le device à la maison!

A tester.

Neo33ASM commented 1 year ago

Alors merci beaucoup, par contre c'est plutôt un switch comme type de device. En gros c'est une prise connectée ON/OFF qui, en plus, mesure la consommation.

Mais du coup, à moins qu'il soit possible d'avoir les 2, je pense qu'il faut intégrer en priorité la fonction on/off (Categories.LIGHTBULB ?).

mgcrea commented 1 year ago

Normalement dans HomeKit tu peux switcher l'apparence d'une prise pour mettre une icône d'éclairage.

Neo33ASM commented 1 year ago

En effet mais là ça a été placé dans la catégorie SENSOR

'plug:2534c497ff8fb013a88da28d341adff5bc0ba77e1fc8ea8dcb8b8f1c9d62ce19': Categories.SENSOR // @Neo33ASM (Easy Plug)

Neo33ASM commented 1 year ago

Est-il donc possible juste de rectifier la ligne 159 de /src/helpers/tydom.ts pour remplacer Categories.SENSOR par Categories.LIGHTBULB svp?

mgcrea commented 1 year ago

Oui en effet je n'étais pas bien réveillé quand j'ai fait le commit, il faut que ce soit Categories.OUTLET. J'ai release la v0.22.1 qui corrige cela. Après dans l'accessoire prise tu peux changer l'icône pour mettre une lampe.

Neo33ASM commented 1 year ago

Pes de mal merci bcp je teste ça

Neo33ASM commented 1 year ago

Petit retour : la lecture d'état et le on/off ne fonctionnent pas, voici quelques extraits de log concernant le plug :

[11/24/2022, 2:43:36 PM] [Tydom] Found new device with firstUsage='plug', deviceId=1669297073 and endpointId=1669297073 [11/24/2022, 2:43:36 PM] [Tydom] Adding new device with firstUsage='plug', deviceId=1669297073 and endpointId=1669297073 [11/24/2022, 2:43:36 PM] [Tydom] Found new tydom device named='Radiateur' with deviceId=1669297073 (id=676c9ea3-84f7-42e9-92e9-dd74795c4a6c) [11/24/2022, 2:43:36 PM] [Tydom] Updating accessory named="Radiateur" with deviceId="1669297073"

2022-11-24T13:43:35.388Z homebridge-tydom ←PUT:ignored for device id='1669297073', endpoints: [{"id":1669297073,"error":0,"data":[{"name":"energyInstantTotElecP","validity":"expired","value":0}]}]

2022-11-24T13:43:36.892Z homebridge-tydom ←PUT:update for device id='1669297073', updates: [{"name":"energyInstantTotElecP","validity":"upToDate","value":0}]

2022-11-24T13:44:06.427Z homebridge-tydom →GET:On for accessory named='Radiateur' with id='00000047-0000-1000-8000-0026BB765291' ...

mgcrea commented 1 year ago

Ok, il me faudra plus de logs du coup:

Il faut lancer (de n'importe quel PC, cela se connecte aux serveurs tydom):

npx tydom-client request /configs/file /devices/data /devices/meta /devices/cmeta --file tydom_output.json --username 001A25XXXXXX --password XXXXXX

Ensuite il faut lancer (de n'importe quel PC, cela se connecte aux serveurs tydom):

npx tydom-client listen --username 001A25XXXXXX --password XXXXXX

Puis que tu lances l'application tydom et que "tu joues" avec la prise (allumer/éteindre), etc. et m'envoyer le log reçu.

Neo33ASM commented 1 year ago

J'ai éteint puis allumé, j'envoie ça vite fait avant d'aller chercher les enfants, je mets en forme après

Creating tydom client ... Connecting to hostname='mediation.tydom.com' with username='001A2506032A' ... tydom-client About to GET request with url='https://mediation.tydom.com/mediation/client?mac=001A2506032A&appli=1' +0ms tydom-client Attempting to open new socket for hostname='mediation.tydom.com' +115ms tydom-client Tydom socket opened for hostname='mediation.tydom.com' +113ms tydom-client Configuring keep-alive interval of ~30s +1ms Successfully connected to Tydom hostname='mediation.tydom.com' with username='001A2506032A' Now listening to new messages from hostname='mediation.tydom.com' (Ctrl-C to exit) ... tydom-client Tydom socket received a 257-sized message received for hostname='mediation.tydom.com' +208ms tydom-client Parsed 257-sized received message as request: tydom-client ☻PUT /devices/data HTTP/1.1 tydom-client Server: Tydom-001A2506032A tydom-client content-type: application/json tydom-client Transfer-Encoding: chunked tydom-client tydom-client 7F tydom-client [{"id":1669301966,"endpoints":[{"id":1669301966,"error":0,"data":[{"name":"plugCmd","validity":"upToDate","value":"OFF"}]}]}] tydom-client tydom-client 0 tydom-client tydom-client +2ms [2022-11-24T15:30:02.204Z] Received new request message on Tydom socket, PUT on uri='/devices/data'" with status=null, body: [{"id":1669301966,"endpoints":[{"id":1669301966,"error":0,"data":[{"name":"plugCmd","validity":"upToDate","value":"OFF"}]}]}] tydom-client Tydom socket received a 267-sized message received for hostname='mediation.tydom.com' +2s tydom-client Parsed 267-sized received message as request: tydom-client ☻PUT /devices/data HTTP/1.1 tydom-client Server: Tydom-001A2506032A tydom-client content-type: application/json tydom-client Transfer-Encoding: chunked tydom-client tydom-client 89 tydom-client [{"id":1669301966,"endpoints":[{"id":1669301966,"error":0,"data":[{"name":"energyInstantTotElecP","validity":"upToDate","value":0}]}]}] tydom-client tydom-client 0 tydom-client tydom-client +0ms [2022-11-24T15:30:03.957Z] Received new request message on Tydom socket, PUT on uri='/devices/data'" with status=null, body: [{"id":1669301966,"endpoints":[{"id":1669301966,"error":0,"data":[{"name":"energyInstantTotElecP","validity":"upToDate","value":0}]}]}] tydom-client Tydom socket received a 256-sized message received for hostname='mediation.tydom.com' +238ms tydom-client Parsed 256-sized received message as request: tydom-client ☻PUT /devices/data HTTP/1.1 tydom-client Server: Tydom-001A2506032A tydom-client content-type: application/json tydom-client Transfer-Encoding: chunked tydom-client tydom-client 7E tydom-client [{"id":1669301966,"endpoints":[{"id":1669301966,"error":0,"data":[{"name":"plugCmd","validity":"upToDate","value":"ON"}]}]}] tydom-client tydom-client 0 tydom-client tydom-client +1ms [2022-11-24T15:30:04.195Z] Received new request message on Tydom socket, PUT on uri='/devices/data'" with status=null, body: [{"id":1669301966,"endpoints":[{"id":1669301966,"error":0,"data":[{"name":"plugCmd","validity":"upToDate","value":"ON"}]}]}] tydom-client Attempting to gracefully close socket ... +2s Terminer le programme de commandes (O/N) ? tydom-client Tydom socket closed for hostname='mediation.tydom.com' +32ms tydom-client Socket instance properly closed, exiting! +1ms

mgcrea commented 1 year ago

Je viens de release la 0.23.7 qui essaye de gérer cela, à tester!

Neo33ASM commented 1 year ago

Ah, tout est cassé lol

`[11/24/2022, 5:12:41 PM] ==================== [11/24/2022, 5:12:41 PM] ERROR LOADING PLUGIN homebridge-tydom: [11/24/2022, 5:12:41 PM] Error: Cannot find module 'hap-nodejs/dist/lib/definitions' Require stack:

mgcrea commented 1 year ago

Oups 😅! 0.23.9!

Neo33ASM commented 1 year ago

Bingo, c'est fonctionnel pour le plug, et encore plus réactif que l'appli Tydom au passage ^^ gg

mgcrea commented 1 year ago

Cool!