cflurin / homebridge-mqtt

Homebridge-mqtt is a Plugin for Homebridge.
Apache License 2.0
229 stars 39 forks source link

Adding devices which already exist in mqtt communication #56

Closed JuanGrados closed 6 years ago

JuanGrados commented 6 years ago

Hi and sorry if this seems like a déjà-Vu but I still can get it working. Let me explain my situation:

I have a temperature sensor working and integrated with mqtt in HomeAssistant (hassio), it works fine. It communicates through mqtt with the topic: homeassistant/sensors/esp1/office/temperature

Now I would like to have it visible in HomeKit so I found this project.

Is it possible to add this sensor in homebridge-mqtt doing something like this in node-red?:

topic: homebridge/to/add
payload: {"name": "homeassistant/sensors/esp1/office/temperature", "service_name": "sensor", "service": "Temperature"}

i.e. the "name" field in the playload has to be set to the topic where the sensor already communicates?

Thanks a lot! Cheers

cflurin commented 6 years ago

Hi, HomeKitType -> TemperatureSensor:

https://github.com/KhaosT/HAP-NodeJS/blob/master/lib/gen/HomeKitTypes.js#L3421

topic: homebridge/to/add
payload: {"name": "any-name", "service_name": "sensor", "service": "TemperatureSensor"}
JuanGrados commented 6 years ago

I see, thanks.

Now I am able to get a button in the Homekit interface and the status is reflected in the debug window of node-red. Either way if I change the status in the node-red interface I see the button in Homekit being updated.

But this is just half way since my switch is not receiving the correct message. If I use the Homeassistant interface to turn on the switch, the switch receives:

Message arrived on topic: homeassistant/switches/esp1/livingroom/ambientLamp/state Message: on

But instead by using homebridge it is receiving:

Message arrived on topic: homebridge/to/set Message: { "name":"homeassistant/switches/esp1/livingroom/ambientLamp/state", "characteristic":"On", "value":true }

Is this something that I have to set by my own? I mean, to re-do the code of my switches to receive a JSON instead of a "direct instruction"?

Thanks a lot for your help!

cflurin commented 6 years ago

Have a look at https://github.com/cflurin/homebridge-mqtt/wiki and concerning node-red: to ask for help go to > https://groups.google.com/forum/#!forum/node-red

JuanGrados commented 6 years ago

Hi!

I already looked the wiki examples (way before asking here). But my question was not clarified from them.

After integratig a switch in homebridge-mqtt using node-red, I can see the button in my iphone’s home app, but when pressing it I see in the debug window that it is publishing the JSON in the topic homebridge/from/set/ which obvuisly the switch does not recieve (and even of the topic were correct, the payload is not the correct for the switch).

So obviusly I am doing something wrong or I was wrongly expectig that this pluging connects the switch with homekit in a trasparent way.

Right now, to make it work, I had to include a function in node-red that reads the JSON from the the topic homebridge/from/set/# and publish the payload.value into the topic payload.name, probably not the moat elegant way.

Thanks for your help. Cheers

cflurin commented 6 years ago

The ways devices use MQTT is countless. Using a function in node-red is the correct solution.

Node-red is a "Flow-based programming for the Internet of Things" (Node-RED is a programming tool for wiring together hardware devices, APIs and online services ...)

My time is limited and I'm focused on software developing, so please for more help use node-red google group.