-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[intellicenter2] Initial contribution #13334
base: main
Are you sure you want to change the base?
Conversation
39798d3
to
4643a69
Compare
@jlaur This is ready for a review -- how can I get this assigned for a review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution! I have just started a review, but will need to do it in an incremental way to not keep you waiting for too long. So I have provided some initial feedback, which I hope you can use to get started, while I will continue my review as soon as possible.
_Give some details about what this binding is meant for - a protocol, system, specific device._ | ||
|
||
_If possible, provide some resources like pictures (only PNG is supported currently), a video, etc. to give an impression of what can be done with this binding._ | ||
_You can place such resources into a `doc` folder next to this README.md._ | ||
|
||
_Put each sentence in a separate line to improve readability of diffs._ | ||
|
||
## Supported Things | ||
|
||
_Please describe the different supported things / devices including their ThingTypeUID within this section._ | ||
_Which different types are supported, which models were tested etc.?_ | ||
_Note that it is planned to generate some part of this based on the XML files within ```src/main/resources/OH-INF/thing``` of your binding._ | ||
|
||
- `bridge`: Short description of the Bridge, if any | ||
- `sample`: Short description of the Thing with the ThingTypeUID `sample` | ||
|
||
## Discovery | ||
|
||
_Describe the available auto-discovery features here._ | ||
_Mention for what it works and what needs to be kept in mind when using it._ | ||
|
||
## Binding Configuration | ||
|
||
_If your binding requires or supports general configuration settings, please create a folder ```cfg``` and place the configuration file ```<bindingId>.cfg``` inside it._ | ||
_In this section, you should link to this file and provide some information about the options._ | ||
_The file could e.g. look like:_ | ||
|
||
``` | ||
# Configuration for the IntelliCenter2 Binding | ||
# | ||
# Default secret key for the pairing of the IntelliCenter2 Thing. | ||
# It has to be between 10-40 (alphanumeric) characters. | ||
# This may be changed by the user for security reasons. | ||
secret=openHABSecret | ||
``` | ||
|
||
_Note that it is planned to generate some part of this based on the information that is available within ```src/main/resources/OH-INF/binding``` of your binding._ | ||
|
||
_If your binding does not offer any generic configurations, you can remove this section completely._ | ||
|
||
## Thing Configuration | ||
|
||
_Describe what is needed to manually configure a thing, either through the UI or via a thing-file._ | ||
_This should be mainly about its mandatory and optional configuration parameters._ | ||
|
||
_Note that it is planned to generate some part of this based on the XML files within ```src/main/resources/OH-INF/thing``` of your binding._ | ||
|
||
### `sample` Thing Configuration | ||
|
||
| Name | Type | Description | Default | Required | Advanced | | ||
|-----------------|---------|---------------------------------------|---------|----------|----------| | ||
| hostname | text | Hostname or IP address of the device | N/A | yes | no | | ||
| password | text | Password to access the device | N/A | yes | no | | ||
| refreshInterval | integer | Interval the device is polled in sec. | 600 | no | yes | | ||
|
||
## Channels | ||
|
||
_Here you should provide information about available channel types, what their meaning is and how they can be used._ | ||
|
||
_Note that it is planned to generate some part of this based on the XML files within ```src/main/resources/OH-INF/thing``` of your binding._ | ||
|
||
| Channel | Type | Read/Write | Description | | ||
|---------|--------|------------|-----------------------------| | ||
| control | Switch | RW | This is the control channel | | ||
|
||
## Full Example | ||
|
||
_Provide a full usage example based on textual configuration files._ | ||
_*.things, *.items examples are mandatory as textual configuration is well used by many users._ | ||
_*.sitemap examples are optional._ | ||
|
||
## Any custom content here! | ||
|
||
_Feel free to add additional sections for whatever you think should also be mentioned about your binding!_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please document the binding in this file.
*/ | ||
package org.openhab.binding.intellicenter2.internal; | ||
|
||
import org.apache.commons.lang3.builder.ToStringBuilder; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this dependency, see #7722.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...va/org/openhab/binding/intellicenter2/internal/discovery/IntelliCenter2DiscoveryService.java
Outdated
Show resolved
Hide resolved
...va/org/openhab/binding/intellicenter2/internal/discovery/IntelliCenter2DiscoveryService.java
Outdated
Show resolved
Hide resolved
} | ||
} | ||
} catch (Exception e) { | ||
logger.error("Unable to discover IntelliCenter2 hardware for {}", discoveryArg, e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this will not prevent the binding from working, log level should be reduced.
"Unable to connect to host " + config.hostname); | ||
} catch (Exception e) { | ||
logger.error("Error initializing.", e); | ||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.HANDLER_INITIALIZING_ERROR, e.getMessage()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This thing status detail is not correct, i.e. it doesn't correspond to the status. Please see https://www.openhab.org/docs/concepts/things.html#status-details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
String msg = String.format("unknown host name: %s", config.hostname); | ||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, msg); | ||
} catch (IOException e) { | ||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be COMMUNICATION_ERROR. In this case, how will the binding come online?
} catch (Exception ignored) { | ||
} | ||
} | ||
updateStatus(ThingStatus.OFFLINE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not needed.
updateProperty("propertyName", systemInfo.getPropertyName()); | ||
updateProperty("version", systemInfo.getVersion()); | ||
logger.info("Bridge is ONLINE."); | ||
if (!systemInfo.getIntellicenterVersion().equals("1.064")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the difference between systemInfo.getVersion()
and systemInfo.getIntellicenterVersion()
? Would it make sense to keep both as properties?
* | ||
* @see Circuit | ||
*/ | ||
@SuppressWarnings("UnstableApiUsage") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have provided some additional comments after second review session. In general the code looks good!
* | ||
* @see IntelliBrite | ||
*/ | ||
@SuppressWarnings("UnstableApiUsage") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason for this?
updateState(channelUID, OnOffType.from(pool.isHeating())); | ||
break; | ||
default: | ||
logger.error("Unable to update state for {}", channelUID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not prevent the binding from working, so could be reduced to log level WARN. See https://next.openhab.org/docs/developer/guidelines.html#f-logging
@Override | ||
public void handleCommand(@NonNull ChannelUID channelUID, @NonNull Command command) { | ||
super.handleCommand(channelUID, command); | ||
switch (channelUID.getId()) { | ||
case CHANNEL_PUMP_GPM: | ||
if (command instanceof DecimalType) { | ||
// var request = ICRequest.setParamList( | ||
// new RequestObject(getObjectName(), Map.of(Attribute.GPM, command.toString()))); | ||
// getProtocol().submit(request); | ||
} | ||
break; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be removed, or did you mean to implement something in this override?
// get an updated model from IC | ||
final ICProtocol protocol = getProtocol(); | ||
if (protocol == null) { | ||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.HANDLER_INITIALIZING_ERROR); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a valid combination, it should most likely be CONFIGURATION_ERROR, assuming that protocol being null is caused by missing reference to parent bridge handler. See https://www.openhab.org/docs/concepts/things.html#status-details
getProtocol().subscribe(this, model.asRequestObject()); | ||
updateStatus(ThingStatus.ONLINE); | ||
updateState(model); | ||
} catch (Exception e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need to catch Exception
here, or could you handle only specializations?
logger.trace("Sending request {}", jsonRequest); | ||
write(jsonRequest); | ||
} catch (Exception e) { | ||
logger.error("Error writing request {}", jsonRequest); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this log needed - where will the exception thrown below be caught?
subscriptions.get(request.getObjectName()).add(listener); | ||
String response = getUnchecked(submit(ICRequest.requestParamList(request))).getResponse(); | ||
if (!"200".equals(response)) { | ||
logger.error("Error subscribing listener {} for request {}", listener, request); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose this should not prevent the binding from working, so probably log level can be reduced?
protected void updateState(ChannelUID channelUID, Body pool) { | ||
switch (channelUID.getId()) { | ||
case CHANNEL_CURRENT_TEMPERATURE: | ||
updateState(channelUID, new DecimalType(pool.getCurrentTemperature())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe channel type is defined as "Number:Temperature", so you need QuantityType here for correctly supporting UoM:
updateState(channelUID, new DecimalType(pool.getCurrentTemperature())); | |
updateState(channelUID, new QuantityType<>(pool.getCurrentTemperature()), SIUnits.CELSIUS); |
updateState(channelUID, new DecimalType(pool.getCurrentTemperature())); | ||
break; | ||
case CHANNEL_TARGET_TEMPERATURE: | ||
updateState(channelUID, new DecimalType(pool.getTargetTemperature())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And the same here.
...main/java/org/openhab/binding/intellicenter2/internal/handler/IntelliCenter2PoolHandler.java
Outdated
Show resolved
Hide resolved
@valdisrigdon do you need anything to proceed with this PR? |
@isiepel nope, I just need time to respond and update based on all the feedback. |
Hey guys, do you need help merging suggested changes / getting this over the line? |
@gutermhub I would love some help merging the suggested changes and getting this over the line. I've been running with this build and it's been super stable. |
Anything specific you need help with? There are some review comments to address, you also need to get the PR updated from the main branch. |
Unless someone want to continue on this PR, i'm about to close this due to inactivty. There are some comments open without repsonses for over two years. |
Could you keep it open? I just picked this up the other day after upgrading to 4.2.0. I'll push up the changes and address the comments soon. |
Ah great, will leave this open. |
4643a69
to
ea1aefc
Compare
<parent> | ||
<groupId>org.openhab.addons.bundles</groupId> | ||
<artifactId>org.openhab.addons.reactor.bundles</artifactId> | ||
<version>4.3.0-SNAPSHOT</version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<version>4.3.0-SNAPSHOT</version> | |
<version>5.0.0-SNAPSHOT</version> |
Adds a new binding for the IntelliCenter 2 pool automation system from
Pentair.
This adds a new binding for Pentair pool automation systems using IntelliCenter 2. This is different from the Pentair binding as the protocol is completely different and does not require any additional hardware to activate.
I have been running a version of this binding on 3.2 for a few months without any issues.