Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[systeminfo] dynamic channels #13562

Merged
merged 13 commits into from
Nov 4, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,14 @@ private boolean addDynamicChannels() {
newChannelGroups.addAll(0, thingTypeProvider.getChannelGroupDefinitions(thing.getThingTypeUID()));
ThingTypeUID thingTypeUID = new ThingTypeUID(BINDING_ID, THING_TYPE_COMPUTER_ID + idExtString);
if (thingTypeProvider.updateThingType(thingTypeUID, newChannelGroups)) {
logger.trace("Channel groups where added, changing the thing type");
logger.trace("Channel groups were added, changing the thing type");
changeThingType(thingTypeUID, thing.getConfiguration());
return true;
} else {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.HANDLER_INITIALIZING_ERROR,
"@text/offline.cannot-initialize");
return false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you return false, this will trigger the additional code in initialize that finally sets the status to ONLINE.
So either you have to return true there or you return false but do not set the status to OFFLINE there.
Something looks not coherent.

Copy link
Contributor Author

@mherwege mherwege Nov 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lolodomo Indeed, didn't think it through well enough. I think the new commit should fix that. Not setting the status here would force me to set it in the initialize method, and I don't know in initialize if the handler is being recreated. It shouldn't set it if it is being recreated.

}
return true;
}

List<Channel> newChannels = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ channel-type.systeminfo.information.label = Display Information
channel-type.systeminfo.information.description = Product, manufacturer, SN, width and height of the display in cm
channel-type.systeminfo.ip.label = IP Address
channel-type.systeminfo.ip.description = Host IP address of the network
channel-type.systeminfo.cpuLoad.label = CPU Load
channel-type.systeminfo.cpuLoad.description = CPU load in percent
channel-type.systeminfo.load.label = Load
channel-type.systeminfo.load.description = Load in percent
channel-type.systeminfo.loadAverage.label = Load Average
channel-type.systeminfo.loadAverage.description = Load as a number of processes for the last 1,5 or 15 minutes
channel-type.systeminfo.load_process.label = Load
Expand All @@ -86,6 +86,8 @@ channel-type.systeminfo.packetsReceived.label = Packets Received
channel-type.systeminfo.packetsReceived.description = Number of packets received
channel-type.systeminfo.packetsSent.label = Packets Sent
channel-type.systeminfo.packetsSent.description = Number of packets sent
channel-type.systeminfo.path.label = Path
channel-type.systeminfo.path.description = The full path
channel-type.systeminfo.path_process.label = Path
channel-type.systeminfo.path_process.description = The full path
channel-type.systeminfo.remainingCapacity.label = Remaining Capacity
Expand Down