cflurin / homebridge-mqtt

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

homebridge/from/set missing service_type #114

Open mriksman opened 3 years ago

mriksman commented 3 years ago

Documentation shows that homebridge/from/set should show service_type.

However, I don't see it. I get back set = {"name":"nodeID_5","service_name":"endpoint_1","characteristic":"On","value":true}

mriksman commented 3 years ago

Logs show this

[05/10/2021, 22:31:10] [mqtt] Accessory.set [iid 10] 'nodeID_5' 'endpoint_1' 'undefined' 'On' false
[05/10/2021, 22:31:10] [mqtt] buildTopic homebridge/from/set

...So why is it showing undefined...?

cflurin commented 3 years ago

It seems some files are corrupt, remove homebridge and homebridge-mqtt and install them again.

mriksman commented 3 years ago

This is a brand new install!

It went Homebridge, Homebridge-config-ui-x, and then I used the GUI to install Homebridge-MQTT.

cflurin commented 3 years ago

I need more infos:

Whatt does ui-x>accessories show? (screenshot) how many accessories did you add?

Post how you did add endpoint_1 (playload)

mriksman commented 3 years ago

Hey, image

Here is the node-red image I split the incoming topic name up, and then use this to construct the payload for homebridge/to/add/ and homebridge/to/add/service. I get warnings ack=false saying that nodeID_5 and endpoint_1 and endpoint_1 already exist every time a new message arrives, but I don't think that is an issue.

That msg.payload is

{
    "name": payload[1],
    "service_name": payload[3],
    "service": "Switch",
    "reachable":true
}

So msg.payload[1] is nodeId_5 - unique for each Z-Wave device, and it has two binary switches, so for msg.payload[3] I get endpoint_1 and endpoint_2.

cflurin commented 3 years ago

Sorry, I can't reproduce it this way, please try with a simple inject-node containing the payload and put a debug node to see what mqtt-out sends.

Post your simplified flow here, so that I can import it.

mriksman commented 3 years ago

Hey,

image

[{"id":"efbfd209b4b4bba8","type":"tab","label":"Flow 4","disabled":false,"info":""},{"id":"82157e3f70d3190e","type":"mqtt out","z":"efbfd209b4b4bba8","name":"","topic":"homebridge/to/add","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"cae6e757.5e6a38","x":650,"y":220,"wires":[]},{"id":"807362e0111e958c","type":"inject","z":"efbfd209b4b4bba8","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\t    \"name\": \"nodeID_6\",\t    \"service_name\": \"endpoint_1\",\t    \"service\": \"Switch\",\t    \"reachable\":true\t}","payloadType":"jsonata","x":350,"y":220,"wires":[["82157e3f70d3190e"]]},{"id":"f5ee488f33d9d4d6","type":"mqtt in","z":"efbfd209b4b4bba8","name":"","topic":"homebridge/from/response","qos":"2","datatype":"auto","broker":"cae6e757.5e6a38","x":390,"y":340,"wires":[["32ef7dac574dfa2d"]]},{"id":"32ef7dac574dfa2d","type":"debug","z":"efbfd209b4b4bba8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":630,"y":340,"wires":[]},{"id":"cae6e757.5e6a38","type":"mqtt-broker","name":"Local MQTT","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

Homebridge logs.

[06/10/2021, 11:11:32] [mqtt] on.message add 
{
  "name": "nodeID_6",
  "service_name": "endpoint_1",
  "service": "Switch",
  "reachable": true,
  "request_id": 0
}
[06/10/2021, 11:11:32] [mqtt] Accessory.configureAccessory 'nodeID_6' 'endpoint_1' 'Switch'
[06/10/2021, 11:11:32] [mqtt] Accessory.configureCharacteristics nodeID_6 >endpoint_1< Name endpoint_1
[06/10/2021, 11:11:32] [mqtt] Accessory.configureCharacteristics nodeID_6 >endpoint_1< On false
[06/10/2021, 11:11:32] [mqtt] Controller.setAccessoryInformation {"name":"nodeID_6","manufacturer":"homebridge-mqtt","model":"undefined","serialnumber":"added 2021-10-06T10:11","firmwarerevision":"plugin v1.0.1"}
[06/10/2021, 11:11:32] [mqtt] buildTopic homebridge/from/response
[06/10/2021, 11:11:32] [mqtt] addAccessory true, accessory 'nodeID_6', service_name 'endpoint_1' is added. [0]
[06/10/2021, 11:11:34] [mqtt] Accessory.get [iid 3] 'nodeID_4' '' 'undefined' 'Manufacturer' 'AEON Labs'
[06/10/2021, 11:11:34] [mqtt] buildTopic homebridge/from/get
[06/10/2021, 11:11:34] [mqtt] Accessory.get [iid 4] 'nodeID_4' '' 'undefined' 'Model' 'DSC27'
[06/10/2021, 11:11:34] [mqtt] buildTopic homebridge/from/get
[06/10/2021, 11:11:34] [mqtt] Accessory.get [iid 6] 'nodeID_4' '' 'undefined' 'SerialNumber' '4711'
[06/10/2021, 11:11:34] [mqtt] buildTopic homebridge/from/get
[06/10/2021, 11:11:34] [mqtt] Accessory.get [iid 7] 'nodeID_4' '' 'undefined' 'FirmwareRevision' '1.0.1'
[06/10/2021, 11:11:34] [mqtt] buildTopic homebridge/from/get
[06/10/2021, 11:11:34] [mqtt] Accessory.get [iid 10] 'nodeID_4' 'light_x' 'undefined' 'On' 'true'
[06/10/2021, 11:11:34] [mqtt] buildTopic homebridge/from/get
[06/10/2021, 11:11:34] [mqtt] Accessory.get [iid 10] 'nodeID_5' 'endpoint_1' 'undefined' 'On' 'false'
[06/10/2021, 11:11:34] [mqtt] buildTopic homebridge/from/get
[06/10/2021, 11:11:34] [mqtt] Accessory.getService_names
[06/10/2021, 11:11:34] [mqtt] Accessory.getService_names [iid 10] nodeID_6 'On' 'endpoint_1'
[06/10/2021, 11:11:34] [mqtt] Accessory.get [iid 10] 'nodeID_6' 'endpoint_1' 'undefined' 'On' 'false'
[06/10/2021, 11:11:34] [mqtt] buildTopic homebridge/from/get
[06/10/2021, 11:11:52] [mqtt] Accessory.get [iid 10] 'nodeID_6' 'endpoint_1' 'undefined' 'On' 'false'
[06/10/2021, 11:11:52] [mqtt] buildTopic homebridge/from/get
[06/10/2021, 11:12:38] [mqtt] Accessory.set [iid 10] 'nodeID_6' 'endpoint_1' 'undefined' 'On' true
[06/10/2021, 11:12:38] [mqtt] buildTopic homebridge/from/set
mriksman commented 3 years ago

A homebridge/to/get knows it is a Switch...

homebridge/from/response : msg.payload : string[157]
"{"nodeID_5":{"services":{"endpoint_1":"Switch","endpoint_2":"Switch"},"characteristics":{"endpoint_1":{"On":true},"endpoint_2":{"On":false}}},"request_id":0}"
cflurin commented 3 years ago

The service_type has been added by a PR. Maybe the author can fix this bug. I'll put it to my todo list anyway.

mriksman commented 3 years ago

Yeah. It was me! Hahah. Back in January 2020; v0.61. But I am not a good programmer; I've had a look, and I can't see what may have affected it since then...

cflurin commented 3 years ago

A workaround would be to define the accessory this way:

{
    "name": "nodeID_6",
    "service_name": "nodeID_6",
    "service": "Switch",
    "reachable": true
}

Also service_name = name

mriksman commented 3 years ago

Interesting. Setting service_name = name does in fact work. However, I have a dual switch, so my topics are image So I need to have separate name (nodeID_5) and service_name (endpoint_1 and endpoint_2).

cflurin commented 3 years ago

Well, it's up to you to investigate. I'm working on other projects and I don't know when I can fix it.