-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support all attributes of channel builder (#178)
Note, some (all?) bindings provide default values for some channel attributes, e.g. `acceptedItemType`, `label`, etc. when they are not specified. This will cause thing builder to update/replace the created thing instead of leaving it unchanged. The update will cause the Thing status will change to OFFLINE, then back ONLINE. By specifying those values during the channel creation, the Thing builder will see that the new Thing being built is exactly the same as the existing Thing, and will not update the existing thing, thereby avoiding the change in Thing status. Demonstration: ```ruby things.build do thing "mqtt:topic:mything", broker: "mqtt:broker:mybroker" do channel "signal", "number", config: { stateTopic: "xxxx" } end end # Once built, the binding will set a default label and acceptedItemType ... # Try to recreate, Thing will be updated because the specified channel attributes are "different" from the existing thing things.build do thing "mqtt:topic:mything", broker: "mqtt:broker:mybroker" do channel "signal", "number", config: { stateTopic: "xxxx" } end end ``` MQTT will add a default label and acceptedItemType: "Number" to the above channel, so when we try to recreate it again, the thing builder noticed that the channels have different attributes, so the builder will update the Thing instead of leaving it alone. To avoid this problem: ```ruby things.build do thing "mqtt:topic:mything", broker: "mqtt:broker:mybroker" do channel "signal", "number", "custom label", config: { stateTopic: "xxxx" }, accepted_item_type: "Number" end end ... # Try to recreate, Thing will not need to be updated because now all attributes match things.build do thing "mqtt:topic:mything", broker: "mqtt:broker:mybroker" do channel "signal", "number", "custom label", config: { stateTopic: "xxxx" }, accepted_item_type: "Number" end end ``` Signed-off-by: Jimmy Tanagra <[email protected]>
- Loading branch information
Showing
4 changed files
with
224 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters