forked from openhab/openhab-addons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[digitalstrom] Adoptions due to API changes in DSS Update 1.19.2 (ope…
…nhab#12033) * added support for DSUID in DSS response data while being compatible to removed DSID which might still be in use due to older firmware versions. * fixed a NPE and also fixed json parameter naming. * applied improvements from DSUID class * fixed variable name, made dsid member final, added author Signed-off-by: Alexander Friese <af944580@googlemail.com> Signed-off-by: Andras Uhrin <andras.uhrin@gmail.com>
- Loading branch information
Showing
7 changed files
with
118 additions
and
15 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
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
65 changes: 65 additions & 0 deletions
65
...nhab/binding/digitalstrom/internal/lib/structure/devices/deviceparameters/impl/DSUID.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/** | ||
* Copyright (c) 2010-2022 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.impl; | ||
|
||
/** | ||
* The {@link DSUID} represents the digitalSTROM-Device unique identifier. | ||
* | ||
* @author Alexander Friese - initial contributor | ||
*/ | ||
public class DSUID { | ||
|
||
private final String dsuid; | ||
private final String DEFAULT_DSUID = "3504175fe0000000000000000000000001"; | ||
|
||
/** | ||
* Creates a new {@link DSUID}. | ||
* | ||
* @param dsuid to create | ||
*/ | ||
public DSUID(String dsuid) { | ||
var trimmedDsuid = dsuid != null ? dsuid.trim() : ""; | ||
if (trimmedDsuid.length() == 34) { | ||
this.dsuid = trimmedDsuid; | ||
} else { | ||
this.dsuid = DEFAULT_DSUID; | ||
} | ||
} | ||
|
||
/** | ||
* Returns the dSUID as {@link String}. | ||
* | ||
* @return dsuid | ||
*/ | ||
public String getValue() { | ||
return dsuid; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (obj instanceof DSUID) { | ||
return ((DSUID) obj).getValue().equals(this.getValue()); | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return dsuid.hashCode(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return dsuid; | ||
} | ||
} |
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