Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding custom prefix/customize published MQTT payload for clients with multiple services #152

Open
taligentx opened this issue Jun 14, 2019 · 0 comments

Comments

@taligentx
Copy link

Hi there, is there a way to add a prefix or otherwise alter the MQTT payloads published by homekit2mqtt?

I'm interfacing a security system with Arduino/esp8266 that can have up to 8 partitions, each of which is treated as a separate SecuritySystem object. It's not a problem for the Arduino sketch to publish the current security system state to multiple topics (one for each partition), but subscribing to multiple topics can have a few issues as the MQTT library rotates between all of the subscriptions.

For other integrations (Home Assistant and Homebridge-mqttthing), I have the Arduino sketch subscribe to one topic. The other software packages support customizing the MQTT payload, so they are configured to send payloads with a prefix partition number + payload. The Arduino sketch can then take action on all partitions while subscribing to one topic.

It'd be great if something similar can be achieved with homekit2mqtt as it otherwise seems to handle the SecuritySystem object correctly and doesn't require users to install Homebridge as compared to homebridge-mqttthing. Also in a more general case, a single Arduino/esp8266/esp32 may be controlling many services.

Example: homekit2mqtt currently publishes the SecuritySystemTargetState as an integer (0-3) and with an example configuration as follows it is impossible to determine which partition to apply the state:

{
  "dscKeybusInterface": {
    "name": "DSC",
    "manufacturer": "DSC",
    "model": "DSC",
    "services": [
      {
        "name": "Partition 1",
        "service": "SecuritySystem",
        "topic": {
          "setSecuritySystemTargetState": "dsc/Set",
          "statusSecuritySystemCurrentState": "dsc/Get/Partition1"
        },
        "payload": {},
        "config": {},
        "props": {},
        "json": {}
      },
      {
        "name": "Partition 2",
        "service": "SecuritySystem",
        "topic": {
          "setSecuritySystemTargetState": "dsc/Set",
          "statusSecuritySystemCurrentState": "dsc/Get/Partition2"
        },
        "payload": {},
        "config": {},
        "props": {},
        "json": {}
      }
    ],
    "id": "DSC",
    "payload": {},
    "config": {}
  }
}

Thanks for homekit2mqtt!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant