Closed timpur closed 5 years ago
In Types (typescript) it would look something like this:
interface Discoverable {
$name: string;
$type: string;
$attributes?: Array<Attribute>;
$discoverables?: Array<Discoverable>;
}
type Attribute = string;
EG.
interface Device extends Discoverable {
display-name: string;
version: string;
temp-node: Discoverable;
}
const device = {
$name: "homie-device",
$type: "device",
$attributes: ["display-name", "version"],
$discoverables: ["temp-node"],
display-name: "Homie Device",
version: "4.0.0",
temp-node: {
$name: "temp-node",
$type: "temp",
$attributes: ["simple-value"],
$discoverables: ["complex-value"],
simple-value: "25.00",
complex-value: {
...
}
}
}
The convention is how it is I'm afraid. Subtle details can be changed but the core topology was set in stone in the beginning already.
The target audience is all the different DIY projects publishing to anywhere on your MQTT broker to be harmonised.
Currently we have Property Attributes im thinking we could define all core ideas in one format.
For $attributes the format could be {discovery-path}[:[{datatype}]:[{unit}]:[{flags}]:[{format}]] Flags: r=retained, s=settable, !=not. eg. value, value:string, value::°C, value:number:°C, value:::!s!r.
$attributes: ["display-name:string", "version:string", "temp:number"]
You successfully reinvented JSon. Some projects like the HomeAssistant MQTT components use this approach of one descriptive topic that uses json to announce all meta data at once. Homie does not though.
Closing for now to keep this tidy. Please reopen if necessary :)
Discussion
Ive been looking into https://iot.mozilla.org/wot/ a lot lately. I i think there are some things we could take from and build on top of.
Id like to have a discussion about some core concepts about the design of homie with you guys.
The main thing id like to discus is our core approach to discoverablity. At the moment we have defined device, nodes and properties levels. Each level has defined attributes.
Im thinking in the mind set of, we define what is needed to "discoverable", and use this to implement everything else. Thus device, nodes and properties are self discoverable since they extends discoverable requirements. The idea it to specify the minimum, and let discovery do the rest.
Things to keep in mind:
Example
Lets say we define a
Discoverable
type to be:A
Device
is an extension ofDiscoverable
, thus:The idea is that we just use recursion, no level is unique, everything is discoverable with the same process.
Additional Notes
Currently we have
Property Attributes
im thinking we could define all core ideas in one format.For
$attributes
the format could be{discovery-path}[:[{datatype}]:[{unit}]:[{flags}]:[{format}]]
Flags: r=retained, s=settable, !=not. eg.value
,value:string
,value::°C
,value:number:°C
,value:::!s!r
.$attributes: ["display-name:string", "version:string", "temp:number"]
The idea here is that all the meta data about the attribute is known upfront and makes the discover process easier.This reduces the needed number of subscriptions and complexity of discovery.
This is just a thought and doesnt have to be done like this.
The
discovery-path
and$name
do not need to align ? eg.temp-node-path/$name: "temp-node"
Hope to see your thoughts, remember these are raw ideas, not all of it makes sense :P