-
-
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
[tellstick] Add support for Tellstick local API #10020
Conversation
Signed-off-by: Jan Gustafsson <[email protected]>
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections | ||
.unmodifiableSet(Stream.of(DIMMER_THING_TYPE, SWITCH_THING_TYPE, SENSOR_THING_TYPE, RAINSENSOR_THING_TYPE, | ||
WINDSENSOR_THING_TYPE, POWERSENSOR_THING_TYPE, TELLDUSCOREBRIDGE_THING_TYPE, | ||
TELLDUSLIVEBRIDGE_THING_TYPE, TELLDUSLOCALBRIDGE_THING_TYPE).collect(Collectors.toSet())); |
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.
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections | |
.unmodifiableSet(Stream.of(DIMMER_THING_TYPE, SWITCH_THING_TYPE, SENSOR_THING_TYPE, RAINSENSOR_THING_TYPE, | |
WINDSENSOR_THING_TYPE, POWERSENSOR_THING_TYPE, TELLDUSCOREBRIDGE_THING_TYPE, | |
TELLDUSLIVEBRIDGE_THING_TYPE, TELLDUSLOCALBRIDGE_THING_TYPE).collect(Collectors.toSet())); | |
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(DIMMER_THING_TYPE, SWITCH_THING_TYPE, SENSOR_THING_TYPE, RAINSENSOR_THING_TYPE, | |
WINDSENSOR_THING_TYPE, POWERSENSOR_THING_TYPE, TELLDUSCOREBRIDGE_THING_TYPE, | |
TELLDUSLIVEBRIDGE_THING_TYPE, TELLDUSLOCALBRIDGE_THING_TYPE); |
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.
Fixed for all Sets!
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.
Fixed for all sets!
private List<DeviceStatusListener> deviceStatusListeners = new Vector<>(); | ||
private final HttpClient httpClient; | ||
|
||
private static final int REFRESH_DELAY = 10; |
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.
It's good practice to append the unit to the field name e.g. TIMEOUT_SEC.
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.
Fixed!
private ScheduledFuture<?> pollingJob; | ||
private ScheduledFuture<?> immediateRefreshJob; |
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 put all fields to the top.
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.
Fixed!
|
||
@Override | ||
public void dispose() { | ||
logger.debug("Local Handler disposed."); |
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.
Can this message be replaced by using the debugger or by increasing the framework's log level? See point 4 https://www.openhab.org/docs/developer/guidelines.html#f-logging
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 removed it!
|
||
@Override | ||
public void initialize() { | ||
logger.debug("Initializing Telldus Local bridge handler."); |
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.
See above. Remove logging.
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 removed it!
* | ||
* @author Jan Gustafsson - Initial contribution | ||
*/ | ||
public class TelldusLocalException extends TellstickException { |
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 add the NonNullByDefault annotation.
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.
Fixed!
* | ||
* @author Jan Gustafsson - Initial contribution | ||
*/ | ||
public class LocalDataTypeValue { |
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.
You could move this into a package called dto
or append DTO
to the class name to get rid of the checkstyle warning about missing NonNullByDefault annotation.
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.
Fixed!
<config-description> | ||
<parameter name="ipAddress" type="text" required="true"> | ||
<label>Local IP Address</label> | ||
<description>The local IP address of the Tellstick.</description> |
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.
You could specify <context>network-address</context>
to get a free validation.
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!
<description>The local IP address of the Tellstick.</description> | ||
</parameter> | ||
<parameter name="accessToken" type="text" required="true"> | ||
<context>credentials</context> |
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.
Are you sure this conext exists?
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.
No, I have removed it!
<label>Access Token</label> | ||
<description>The access token.</description> | ||
</parameter> | ||
<parameter name="refreshInterval" type="integer" required="false"> |
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.
<parameter name="refreshInterval" type="integer" required="false"> | |
<parameter name="refreshInterval" type="integer" required="false" min="0" unit="ms"> |
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.
Fixed!
Signed-off-by: Jan Gustafsson <[email protected]>
df8ee1d
to
c6e85a5
Compare
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.
The titel of this PR will show up in the OH changelog. Can you make it a bit more self-explanatory?
for (TellstickLocalSensorDTO sensor : previouslist.getSensors()) { | ||
sensor.setUpdated(false); | ||
} | ||
logger.trace("Update sensors, reset updated flag1"); |
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.
Can this message be replaced by using the debugger or by increasing the framework's log level? See point 4 https://www.openhab.org/docs/developer/guidelines.html#f-logging
Please check all.
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.
Fixed!
} | ||
this.deviceList = newList; | ||
} else { | ||
logger.trace("updateDevices, Updating devices."); |
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.
Can this message be replaced by using the debugger or by increasing the framework's log level? See point 4 https://www.openhab.org/docs/developer/guidelines.html#f-logging
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.
Fixed!
private static final long serialVersionUID = 3067179547449454711L; | ||
|
||
@Override | ||
public @NonNull String 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 is added automatically.
public @NonNull String getMessage() { | |
public String 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.
Fixed!
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 got a compilation error if I remove it:
ERROR] /Users/jannegpriv/git/openhab-master3/git/openhab-addons/bundles/org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal/local/TelldusLocalException.java:[35,12] The default '@org.eclipse.jdt.annotation.NonNull' conflicts with the inherited '@org.eclipse.jdt.annotation.Nullable' annotation in the overridden method from org.tellstick.device.TellstickException
Signed-off-by: Jan Gustafsson <[email protected]>
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.
LGTM
…API. (openhab#10020) * Fix for openhab#9841. Signed-off-by: Jan Gustafsson <[email protected]> Signed-off-by: John Marshall <[email protected]>
…API. (openhab#10020) * Fix for openhab#9841. Signed-off-by: Jan Gustafsson <[email protected]>
…API. (openhab#10020) * Fix for openhab#9841. Signed-off-by: Jan Gustafsson <[email protected]>
Fixes #9841
Support for local API according to:
https://tellstick-server.readthedocs.io/en/v1.0.12/api.html
Signed-off-by: Jan Gustafsson [email protected]
Link to community thread where I posted a jar-file for test:
https://community.openhab.org/t/tellstick-local-api/90204/4
This binding was not updated to use Null anntotations, I have therfor not added that in my PR.
The local API only returns JSON format and the live API is implemented to handle XML format, in the future the live API should probably be updated to use JSON as well (since live API seems to support both XML and JSON).