Closed isalkind closed 6 months ago
This isn't working for me in the settings editor - I think because you haven't added all the _apply parameters to the layout, e.g. getOn
and setOn
are here:
{
"type": "fieldset",
"expandable": true,
"title": "MQTT Topics",
"condition": {
"functionBody": "return model.type && model.type !== 'null';"
},
"items": [
"topics.setOn",
"topics.getOn",
You also haven't specified conditions - so if they were added they would be present for every accessory type:
"getWhite": {
"type": "string",
"description": "Topic used to notify mqttthing of white level (0-255) - can be used with getRGB for RGBW with separately-published white level",
"condition": {
"functionBody": "return ['lightbulb','lightbulb-White','lightbulb-RGB'].includes(model.type);"
}
},
"getWhite_apply": {
"type": "string"
},
They also need descriptions.
Thanks,
David
These changes have no impact in the setting editor. They simply allow an apply function to exist in the settings file and not be overwritten if the settings editor is used.
Ah, I understand - thanks.
Apply functions could only be updated via the config file and these custom entries where overwritten if changes where made to the accessory through the UI.
The changes in this PR were made to allow a separate entry for the topic apply function (still only visible in the config file), but these changes are not overwritten by changes made through the UI.
This is a workaround for apply functions not being supported by
config-ui-x
(see: https://github.com/arachnetech/homebridge-mqttthing/blob/master/docs/Configuration.md#apply-functions). This non-support currently causes topics to be overwritten if a manual update is applied to the config file and then an update is made viaconfig-ui-x
. With the updates in this PR, apply functions can be written directly to the configuration file and will not be lost ifconfig-ui-x
is used at some later point to make changes. The apply function is still not visible inconfig-ui-x
and can only be updated through directly editing the config file.To maintain these changes, for every
topic
entry that is created inconfig.schema.json
a correspondingtopic_apply
entry must be created.The referenced documentation would need to be updated if these changes are accepted.