No announcement yet.

Wildcard Template for Auto-Association of MQTT control topics to existing HS devices

  • Filter
  • Time
  • Show
Clear All
new posts

  • #31
    I did add the option to either create upon reception or as you desire to create immediately to http://mcsSprinklers/ You can interface the two however you like. Pulling works fine for small population of devices. For those that have 100's or 1000's the latency can become excessive in not only with the data being pulled, but also due to the resource consumption that delays everything down. Over time HS has tended to change their API so it is something you need watch over and continue to maintain the interface.


    • #32
      @Michael McSharry

      Thanks I will move the sensor updates component to using mcsMQTT (you are correct, MQTT is ultimately better for near real-time updates), if it's available I will use it to avoid the 100ms json poll.

      I've got the entire JSON on a seperate 30 second interval going into a local array in Node-Red so can match up data from the mcsMQTT via the ref and pull richer data from the JSON (eg if there is a battery level) or associations.

      Should be a fun night of coding,


      • #33
        @Michael McSharry

        "Associate all non-plugin HS Devices immediately" is working.

        One small change needed which is to force the "Default Payload Template" upon all Associations. Currently this only occurs once, not if the user updates it.

        Eg if the user changes the "Default Payload Template" on the General tab, it is not currently applied to all the associations.

        A work around is to toggle between these tick boxes in the GUI.

        "Associate Topic to HS Device upon receipt of control Topic"
        "Associate all non-plugin HS Devices immediately"

        Btw this works really well for sending a JSON formatted payload:

        { "ref": $$REF:, "name": "$$NAME:", "value": "$$VALUE:", "type": "$$TYPE:" }

        mcsMQTT General Tab:
        Click image for larger version  Name:	345345345.JPG Views:	1 Size:	24.2 KB ID:	1263433

        How it looks in Node-Red:

        Click image for larger version  Name:	node-red-json-hs.JPG Views:	1 Size:	26.4 KB ID:	1263434

        Sample Node-Red flow if anyone finds it useful

        [{"id":"fdb6cc25.a5c32","type":"function","z":"a92a988d.6d afa 8","name":"Logic","func":"// Variables\nvar test = JSON.parse(msg.payload);\nmsg.payload = {}\nmsg.payload = test;\nreturn msg;\n","outputs":1,"noerr":0,"x":930,"y":220,"wires":[["effae800.48baa8"]]},{"id":"5aea4253.881adc","type":"mqtt in","z":"a92a988d.6dafa8","name":"","topic":"homeseer/#","qos":"2","broker":"3437cea9.b22eb2","x":760,"y":220," wir es":[["fdb6cc25.a5c32"]]},{"id":"effae800.48baa8","type":"debug","z":"a92a988d.6daf a 8","name":"","active":true,"tosidebar":true,"console":fal se, "tostatus":false,"complete":"payload","x":1090,"y":220," wire s":[]},{"id":"3437cea9.b22eb2","type":"mqtt-broker","z":"","name":"MQTT","broker":"homeseer.local","port ":"1883","clientid":"","usetls":false,"compatmode":true, "kee palive":"60","cleansession":true,"birthTopic":"","birthQos": "0","birthPayload":"","closeTopic":"","closeQos":"0","cl oseP ayload":"","willTopic":"","willQos":"0","willPayload":""}]

        Connects to MQTT, Parse's the JSON and prints the output to debug


        • #34
          The concept is to allow the user to edit device associations individually so once the association is made it will only change on a device by device basis even if the default templates are changed. If you want the payload template to be different for everything then a safe way to do it is to delete \data\mcsMQTT\mcsMQTT.db and then start the plugin so it will create everything with new defaults.


          • #35
            I ended up making a custom solution using the HTTP JSON interface, posted to Github: