MQTT Homie Convention Node - questions about usage

Not so important to many end users: All functionality of ESPEasy is coded as plugins. OK the base is perhaps the base loop with all network, scripting and UI functions. But all others functions are either controller plugins named "C###.ino" mainly for protocolls (currently there are 16 core protocolls) and arrount 90 "P###.ino" function plugins and even more in the playground. C014 is the homie protocoll plugin and P086 the corresponding plugin. Due to the limitation of micro controllers there is now reasnonable way I know of to link compiled plugins in runtime on the ESP itself dynamically (like DLLs). So it depends on the plugins linked during build and there are stability and memory considerations not to link simply all of them.
Building your custom build is not a big deal but you are right not convenient. A build menue could be handy but someone has to do and maintain it. You can build your own version with Arduino IDE but I highly recommend using VS-Code & platformio.

Here a little update as I have not as much time I need get this done quicker.

This is a example JSON configuration:

{
    "devices": {
        "demo2": {
            "$name": "Node Red Demo Device",
            "$homie": "4.0.0",
            "$implementation": "Node-RED",
            "$nodes": {
                "node-1": {
                    "$name": "a demo node",
                    "$type":"Demo Type",
                    "$properties": {
                        "state": {
                            "$name": "program state",
                            "$datatype": "enum",
                            "$settable": false,
                            "$retained": true,
                            "$format": "stop,prepareing,runing,error"
                        }
                    }
                }
            }
        }
    }
}

This will give you this log:

15 May 19:11:56 - [info] Flows starten
15 May 19:11:56 - [info] [homie.device.config:mosquitto@home] MQTT connect to mqtt://192.168.2.14:1883 as user undefined
15 May 19:11:56 - [info] [homie.node:Node-RED Demo-1] reading config JSON of homie-node Node-RED Demo-1
15 May 19:11:56 - [info] [homie.node:Node-RED Demo-1] first node @ mqtt://192.168.2.14:1883
15 May 19:11:56 - [info] [homie.node:Node-RED Demo-1] new base: devices (devices)
15 May 19:11:56 - [info] [homie.node:Node-RED Demo-1] new deviceID: demo2 (devices)
15 May 19:11:56 - [info] [homie.node:Node-RED Demo-1] $name="Node Red Demo Device" $homie="4.0.0" $implementation="Node-RED" 
15 May 19:11:56 - [info] [homie.node:Node-RED Demo-1] $name="a demo node" $type="a demo type"
15 May 19:11:56 - [info] [homie.node:Node-RED Demo-1] $name="program state" $datatype="enum" $settable="false" $retained="true" $format="stop,prepareing,runing,error"

All based on the configuration above. During the read I preform some validation. Like extra properties:

17 May 09:32:18 - [warn] [homie.node:Node-RED Demo-1] Property does not match homie convention! $newFeature="this would be awesome"

Next step will be checking the convention against the imported data and fill in defaults if possible and send all to the broker.

Here are some design ideas (incomplete):

  • make it possible to edit the home convention JSON in the broker config to add something like "$newFeature"
  • a "own" network connection for "translated" or "virtual" devices to the broker to have the $state="lost" in case of "Node-RED" is going ungracefully offline (By LWT). But the node will actually using only one connection with several subscriptions.
  • handling the "complete" device lifecycle as described here
  • have a "build in" $state timer sending out the last known $state message as configured by $intervall. The message can be set through msg.$state or somthing like that
  • All properties and can be changed on the fly as described here:
  • Any device attributes except $name and $state
  • The $properties attribute of any node
  • Any attribute of any property except $name
  • have a "strict" or "open" mode to control if minor "modifications" on the convention are exceptionable or trow errors

Any thoughts?

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.