cflurin / xiaomi-mqtt

A Bridge between the Xiaomi Mi Smart Home Gateway and the Mqtt broker.
Apache License 2.0
50 stars 14 forks source link

Added option to new topic mode #6

Closed hallard closed 5 years ago

hallard commented 5 years ago

New features:

cflurin commented 5 years ago

Hi, Thanks for your PR. I'll have a look on my system and do some tests.

hallard commented 5 years ago

Hi, no problem, should works but saw a strange thing with MQTT FX, under certain circonstance broker disconnected me when filtering by model, I don't know if it's related to my broker (MOSQUITTO) or my client (MQTTFX)

xiaomi/from/+/+/sensor_ht/#

All other filtering works well, strange.

cflurin commented 5 years ago

Hi, I've quickly done some tests, so far it's okey.

  1. I added a similar feature in homebridge-mqtt and I'd like to handle it in the same way, I used topic_type single or multiple. topic_mode is also okey so you don't have to change that however the setting from and to are used to define the direction. So would you please change the topic_mode settings to something like short, full and both or multiple, single and both.

  2. I'd like to keep the README as simple as possible, the samples about filtering are mqtt features, I'd propose to move these examples to the Wiki and just add a link to the Wiki in README.

  3. In your config.json examples you have to remove the last commas.

    "heartbeatfreq": 6,

You can use https://jsonlint.com/ to validate

cflurin commented 5 years ago

... Note this apply only to gateway heartbeat not the device's one.

Devices also decrement the counter. add this log.debug to see what happens:

    case "heartbeat":
    if (hb_count > 1) {
        log.debug('count '+hb_count+' model '+msg.model);
hallard commented 5 years ago

It's done:

please give a test, done that in a hurry ;-)

cflurin commented 5 years ago
  1. Do you use the topic_mode both? I think we don't need that, you can set topic_mode full and use mqtt this way:

xiaomi/from/#

  1. Please remove the mqtt examples in the README as proposed above.
hallard commented 5 years ago

Yeah I agree and understand, but, I'm using both, to keep compatibility for old version that don't know the new features (and don't need) and if for example I'm using xiaomi/from/# and jeedom listening to xiaomi/from , will it work?

cflurin commented 5 years ago

Okey, let's keep the both setting, however it doesn't make sense to send the same data twice. It's better to change the subscriber topic.