-
Notifications
You must be signed in to change notification settings - Fork 787
Conversation
@J-N-K We plan to do the ESH 0.10.0 release next week - if there's a chance for you to finish this off by Monday, we should get it in. |
I don't think so. I'm waiting for response from the owner of these devices if the implementation is working. I can't test that in my own setup. |
We now have confirmation that the code itself works. I'll finish documentation and tasks after #6626 is merged as this will create merge conflicts otherwise. |
Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
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.
some minor comments
.../main/java/org/eclipse/smarthome/binding/onewire/internal/handler/EDSSensorThingHandler.java
Outdated
Show resolved
Hide resolved
.../main/java/org/eclipse/smarthome/binding/onewire/internal/handler/EDSSensorThingHandler.java
Show resolved
Hide resolved
.../main/java/org/eclipse/smarthome/binding/onewire/internal/handler/EDSSensorThingHandler.java
Outdated
Show resolved
Hide resolved
...ing.onewire/src/main/java/org/eclipse/smarthome/binding/onewire/internal/device/EDS006x.java
Show resolved
Hide resolved
Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
|
||
private final OwDeviceParameterMap temperatureParameter = new OwDeviceParameterMap() { | ||
{ | ||
set(THING_TYPE_OWSERVER, new OwserverDeviceParameter("/temperature")); |
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.
Wouldn't it be much more readable to add another OwDeviceParameterMap
constructor that takes a thing type and a OwserverDeviceParameter
as an argument?
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'm still think of other bridge types which would require other device parameters (e.g. a bridge that directly uses the DS9490 USB Onewire-Master would need the register inside the device instead of a path). This would require something like
private final OwDeviceParameterMap temperatureParameter = new OwDeviceParameterMap() {
{
set(THING_TYPE_OWSERVER, new OwserverDeviceParameter("/temperature"));
set(THING_TYPE_DS9490R, new Ds9490RDeviceParameter(0x4711));
}
I don't think that can be done with constructors.
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.
If we agree that this will never happen, the code could be refactored and simplified. But that is quite large (not sure if we would need a CQ for that).
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.
Or we add a constructor:
public OwDeviceParameterMap(final Map<ThingTypeUID, OwDeviceParameter> map) {
this.map.putAll(map);
}
Then you could add multiple key value pairs on construction or a single one.
private final OwDeviceParameterMap temperatureParameter = new OwDeviceParameterMap(Collections.singletonMap(THING_TYPE_OWSERVER, new OwserverDeviceParameter("/temperature")));
I don't understand the current implementation of the set
method of OwDeviceParameterMap
.
There is a check if the key is already contained to call replace
or put
.
Why not calling put
without additional checks?
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 that really more readable for let's say three parameter sets? Looking at this discussion it seems that double-brace-method is most clear if we stay away from Guava and don't have Java 9 at hand.
Another argument not to change it now: This is the way it is for all other devices. As I said before: we could think of removing the map totally and giving up the idea of other bridges. With the coming changes in #6764 it 's becoming more and more difficult and would require a rewrite of large parts of the OWFS code to get the same functionality. But IMO this is out of scope of this PR.
Regarding the latter remark: I don't remember. Probably it wasn't a HashMap in a previous version during development. I have removed the check.
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.
@J-N-K You can leave it as it is if you want.
But AFAIK using that code you create for every variable a new inner anonymous class. So instead of using the OwDeviceParameterMap
class and create a new instance of it, you create a new class and a new instance of that anonymous class for every variable (there should be class files with a '$' for every instance in your jar).
I personally see no reason for new classes as it can be handled all using the OwDeviceParameterMap
class (that only wraps a map).
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 would leave it as it is now and keep it on my not-so-high priority list to refactor that for all devices in the future.
*/ | ||
@NonNullByDefault | ||
public class EDSSensorThingHandler extends OwBaseThingHandler { | ||
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = new HashSet<>(Arrays.asList(THING_TYPE_EDS_ENV)); |
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 use: Collections.singleton(THING_TYPE_EDS_ENV)
@NonNullByDefault | ||
public class EDSSensorThingHandler extends OwBaseThingHandler { | ||
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = new HashSet<>(Arrays.asList(THING_TYPE_EDS_ENV)); | ||
private static final Set<OwSensorType> SUPPORTED_SENSOR_TYPES = new HashSet<>(Arrays.asList(OwSensorType.EDS0064, |
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.
Another option would be
Stream.of(OwSensorType.EDS0064, OwSensorType.EDS0065, OwSensorType.EDS0066, OwSensorType.EDS0067, OwSensorType.EDS0068).collect(Collectors.toSet());
but it does not harm.
But perhaps you should wrap it by Collections.unmodifiableSet
, so the static final Set cannot be changed at runtime.
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 changed that. What exactly is the difference between the two? Is Stream.of(..).collect()
more efficient?
Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
add EDS006x
partly implements #6177
Depends on #6626
Signed-off-by: Jan N. Klug jan.n.klug@rub.de