Hi,
I know there might be some "things missing" in the homie convention but i followed the development for more than a year now. First I was arguing too but in the end all works much better than I expected in the beginning. In my opinion the convention is open enough to do whatever you like (or in the end either participate or do your own extension).
So I took your suggestions and made a first test.
First I checked how to auto discover the Base Topic (and got the naming right).
in auto discover mode the broker node subscribes to +/+/$homie
and if it receives a message it will then subscribe to this Base Topic.
13 May 22:20:26 - [info] [homie.device.config:mosquitto@home] New Homie base topic detected: 'homie' $homie=4.0.0 subscribed to homie/#
13 May 22:20:26 - [info] [homie.device.config:mosquitto@home] New Homie base topic detected: 'devices' $homie=4.0.0 subscribed to devices/#
So this was a easy one. Now I have to update all my code to reflect the extra level in the data structure. I thought about all this for a while and decided to rewrite the broker node (and the homie-device, homie state and homie-node) instead of patching code which is already full of patches. This time based on definition objects instead of switch/case and if/then structures. That would make updates easier later. Here is the homie convention as I read it in a nutshell
this.homieConvention = {
"deviceId": {"type":"string", "required":true},
"$homie": {"type":"string", "required":true},
"$name": {"type":"string", "required":true},
"$state": {"type":"enum", "required":true, "default":"lost", "format":"init,ready,disconnected,sleeping,lost,alert"},
"$nodes": {"type":"array", "required":true, "default":"string"},
"$extensions": {"type":"string", "required":true, "default":""},
"$implementation": {"type":"string", "required":false},
"_nodes":{
"nodeId": {"type":"string", "required":true},
"$name": {"type":"string", "required":true, "default":""},
"$type": {"type":"string", "required":true, "default":""},
"$properties": {"type":"array", "required":true, "default":""},
"_properties": {
"propertyId":{"type":"string", "required":true},
"$name":{"type":"string", "required":true},
"$datatype":{"type":"enum", "required":true, "default":"string", "format":"string,integer,float,boolean,enum,color,DateTime,Duration"},
"$format":{"type":"string", "required":false},
"$settable":{"type":"boolean", "required":false, "default":false},
"$retained":{"type":"boolean", "required":false, "default":true},
"$unit":{"type":"string", "required":false, "default":""}
}
}
}
Perhaps you see something I missed or got wrong
Same for extensions (which I noted could be addable in the future). I added some extra properties like suitable UI-Icons to have the opportunity to be flexible with future extensions perhaps even user defined ones.
this.homieExDef = {
"$state":{"icon":"fa fa-bolt","type":"enum","unit":"","required":true,"default":"lost","format":
{
"init":"fa fa-cog fa-spin",
"ready":"fa fa-spinner fa-spin",
"disconnected":"fa fa-times",
"sleeping":"fa fa-moon-o",
"lost":"fa fa-question-circle",
"alert":"fa fa-exclamation-triangle"
}
},
"$homie":{"icon":"fa fa-label","type":"string","unit":"","required":true,"default":"n/a","format":""},
"$nodes":{"icon":"fa fa-labels","type":"array","unit":"","required":true,"default":"n/a","format":""},
"$extensions":{"icon":"fa fa-labels","type":"string","unit":"","required":true,"default":"n/a","format":""},
"$type":{"icon":"fa fa-cogs","type":"string","unit":"","required":true,"default":"n/a","format":""},
"$implementation":{"icon":"fa fa-code","type":"string","unit":"","required":false,"default":"n/a","format":""},
"$localip":{"icon":"fa fa-address-card-o","type":"string","unit":"","required":true,"default":"n/a","format":""},
"$mac":{"icon":"fa fa-barcode","type":"string","unit":"","required":true,"default":"n/a","format":""},
"$fw":{
"name":{"icon":"fa fa-file-code-o","type":"string","unit":"","required":true,"default":"n/a","format":""},
"version":{"icon":"fa fa-code-fork","type":"string","unit":"","required":true,"default":"n/a","format":""},
"*":{"icon":"fa fa-label","type":"string","unit":"","required":false,"default":"","format":""}
},
"$stats": {
"interval":{"icon":"fa fa-undo","type":"integer","unit":"sec","required":true,"default":0,"format":""},
"uptime":{"icon":"fa fa-clock-o","type":"integer","unit":"sec","required":true,"default":0,"format":""},
"signal":{"icon":"fa fa-wifi","type":"integer","unit":"%","required":false,"default":0,"format":"0:100"},
"cputemp":{"icon":"fa fa-thermometer-half","type":"float","unit":"°C","required":false,"default":0,"format":""},
"cpuload":{"icon":"fa fa-microchip","type":"integer","unit":"%","required":false,"default":0,"format":"0:100"},
"battery":{"icon":"fa fa-battery-half","type":"integer","unit":"%","required":false,"default":0,"format":"0:100"},
"freeheap":{"icon":"fa fa-braille","type":"integer","unit":"bytes","required":false,"default":0,"format":""},
"supply":{"icon":"fa fa-plug","type":"float","unit":"V","required":false,"default":0,"format":""},
}
};
This is already in use in the home.state node
Last but not least ... the Base Topic is not part of the homie Topology So fixing it to a single user defined one I thought was not wrong in the beginning. But I got the argument to have a extra level of organisation could be convenient. What I got out of many conversations on github is that many "feature requests" you mentioned where already discussed. It is a good lecture for understanding the convention and it's goals better. The only thing I really miss in many conversations about the homie convention is a "theory of operation" document to explain the "why" better. Why messages have to be retained or the logic behind the /set
topic. With this my ESPs (running ESPEasy with the Homie plugins - far more developed than the currently distributed - when I will find time to rebase my repro and do a PR?). I love how easy it is to "survive" a wd-reset without RTC-Memory or wearing out the flash memory when using the homie convention.
Additionally I love that the convention do not have to many "should", "may" or "cans" - I was really shocked about all the subjunctive forms in the MQTT standard (especially around retained messages). As an architect I could say that many buildings will collapse if our standards would be so vague
That's enough for today.