Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Eclipse SmartHome » properties vs config in DiscoveryResultBuilder
properties vs config in DiscoveryResultBuilder [message #1694593] Wed, 06 May 2015 13:48 Go to next message
Marcel Verpaalen is currently offline Marcel VerpaalenFriend
Messages: 59
Registered: September 2014
Member
Seems the with the addition of real properties support the DiscoveryResultBuilder has bit of strange/inconsistent way of setting things.

The withProperties actually does not set the propeties but it sets configuration. There is currently no way to sset the properties outside of the name property, which is defined with the .withLabel

Wouldn't it be better to rename the .withproperties to .withconfiguration, and allow the withproperties to actually set the property. note that this would break existing bindings,

e.g.
	Map<String, Object> properties = new HashMap<>(2);
			properties.put(MaxBinding.IP_ADDRESS, IpAddress);
			properties.put(MaxBinding.SERIAL_NUMBER, cubeSerialNumber);
			ThingUID uid = new ThingUID(MaxBinding.CUBEBRIDGE_THING_TYPE, cubeSerialNumber);
			if (uid != null) {
				DiscoveryResult result = DiscoveryResultBuilder.create(uid).withProperties(properties)
						.withLabel("MAX! Cube LAN Gateway").build();
				thingDiscovered(result);
}

I would also suggest we update the descriptions to so we add configuration
    /**
     * Adds a property to the desired result
     * 
     * @param property of the desired result
     * @return the updated builder
     */
    public DiscoveryResultBuilder withProperty(String key, Object value) {
        this.properties.put(key, value);
        return this;
    }

Re: properties vs config in DiscoveryResultBuilder [message #1694692 is a reply to message #1694593] Thu, 07 May 2015 08:23 Go to previous messageGo to next message
Kai Kreuzer is currently offline Kai KreuzerFriend
Messages: 673
Registered: December 2011
Senior Member
Marcel, I fully agree, I came across the same inconsistency yesterday Smile
Note that in contrast to your example above, I would still see the IP address to be a configuration parameter, not a (static) property as it could be potentially changed later.
What we would have to discuss is whether properties are synched into Things automatically (if there is an updated discovery result) - this is currently done for the configuration parameters e.g. in order to update an IP address if it has changed through DHCP. For properties, it is not expected that they change, so what is the best way to deal with diffs from new discovery results?
Re: properties vs config in DiscoveryResultBuilder [message #1694730 is a reply to message #1694692] Thu, 07 May 2015 12:43 Go to previous messageGo to next message
Marcel Verpaalen is currently offline Marcel VerpaalenFriend
Messages: 59
Registered: September 2014
Member
Personally I don't like the current difference between a property and configuration. The key difference is in whether the user can update it or not, and if it should be persisted or not.
In other words, it is not so clear whether we are talking smarthome configuration or physical thing configuration.

e.g. take the serial number, it now is defined as a configuration, as it is they key on how a thing is uniquely identified and you want to be able to 'configure' it through the interface when manually adding a new Thing. However, the serialnumber obviously is not something you actually want to 'configure'/change on the device. Result of it is now in ESH we have it both as configuration as well as property.

This indeed is even the case for an IP address, which is something you want to configure manually because you need to inform the binding what ip to use, but the physical device maybe wants to have only the configuration if the IP is static or dynamic, and the IP it gets is actually a property of latest DHCP results.

Also when I look at the properties in ESH I think they are currently too simplistic, meaning that similar to the configuration I would like to have it context or grouping, label, description etc so that it can properly be displayed in the UI. Obvious this can all be copied to the properties logic, but I feel we then are duplicating lot of logic, instead of giving maybe one or two additional options to a configuration to determine whether it is a configuration or property in the current sense of ESH

wrt your last remark, I think there is no need to have a sync from properties i into Things automatically (if there is an updated discovery result) . I think in the very specific case where properties are changing, the Thinghandler should identify/update that rather than using discovery for that purpose
Re: properties vs config in DiscoveryResultBuilder [message #1694736 is a reply to message #1694730] Thu, 07 May 2015 13:13 Go to previous messageGo to next message
Kai Kreuzer is currently offline Kai KreuzerFriend
Messages: 673
Registered: December 2011
Senior Member
Actually, initially we had config parameters that were "read-only" instead of properties. But for defining thing types, this meant a very bloated XML as for a config parameter you have to provide many more details than for a property. And we also did not want to have them listed with the configuration (remember that config descriptions are not only for things, but a general concept in ESH), but rather have them describe the Things in some more detail (actually, the main driver was to be able to determine the vendor and model in order to render nice images etc.). IP addresses are definitely not a property as they are something external and can change. Serial numbers are. But you are right - requiring the user to enter a serial number for manual definition of a Thing is then not possible at the moment...

I would not want to blow them up to also have context, grouping etc. Do you really see a need for this?

Regarding the discovery result: When adding config parameters besides properties, we will have to rethink the representationProperty as this could potentially be a property or a config parameter - this is indeed very confusing...

Regards,
Kai
Re: properties vs config in DiscoveryResultBuilder [message #1694785 is a reply to message #1694736] Thu, 07 May 2015 20:51 Go to previous messageGo to next message
Chris Jackson is currently offline Chris JacksonFriend
Messages: 256
Registered: December 2013
Senior Member
I just thought I'd add my input...

I originally thought that properties were read-only information that was configured internally for the thing, but was not visible to the user at all. I intended on using this for static configuration information that is needed to tell the binding something detailed about the way the thing works - but this isn't something the user needs to see, and it's best hidden... I'm now realising that this isn't quite the intention (Kai - this might be part of the reason for the confusion in the other thread).

However, I'm wondering why we need properties that are defined like this? With the new parameter groups (which I hope will be merged tomorrow:)) we can now group 'parameters', and set them as read-only if we want. This is actually what I was planning for thing status information (like version numbers that get read out of a device - it's nominally static, but if the firmware gets updated, then it might change very occasionally). I think this really blurs the lines between parameters and properties and I'm not sure I see a great need for properties as defined here - I'd probably just use parameters...

Re: properties vs config in DiscoveryResultBuilder [message #1694835 is a reply to message #1694785] Fri, 08 May 2015 11:26 Go to previous messageGo to next message
Marcel Verpaalen is currently offline Marcel VerpaalenFriend
Messages: 59
Registered: September 2014
Member
Kai,

What I would suggest then is keep properties extremely limited, indeed just for very limited set of predefined values. Then these few can then be nicely rendered etc, and no need for extensive additional features around the update logic/information to the framework etc.

For all my other ones I think I'll use the suggestion of Chris, as I do think we want to give them proper readable names (parameters currently are only camelcase names) , grouping etc.

I see for the MAX! binding many similarities to what Chris has done for zwave in openhab.
There are certain grouped sets of parameters, part of them read-only, others changeable and controlling the device behavior.
For the MAX! binding, I'm close to finishing the display of all changeable parameters. After completion of that I'll will start create the logic to actually make the configuration updates through the UI and configure the devices without the need for the vendor application.

[Updated on: Fri, 08 May 2015 14:31]

Report message to a moderator

Re: properties vs config in DiscoveryResultBuilder [message #1694871 is a reply to message #1694835] Fri, 08 May 2015 15:06 Go to previous messageGo to next message
Kai Kreuzer is currently offline Kai KreuzerFriend
Messages: 673
Registered: December 2011
Senior Member
Marcel Verpaalen wrote on Fri, 08 May 2015 13:26
What I would suggest then is keep properties extremely limited, indeed just for very limited set of predefined values.

Agreed. I actually see it as a means to provide some more details about the thing type without having to introduce a dedicated thing type. So two models of a device can share the same thing type and can still be differentiated by applications through reading the model id and vendor.
They definitely shouldn't be used for anything that is not completely static.
Re: properties vs config in DiscoveryResultBuilder [message #1695057 is a reply to message #1694871] Mon, 11 May 2015 15:54 Go to previous messageGo to next message
Kai Kreuzer is currently offline Kai KreuzerFriend
Messages: 673
Registered: December 2011
Senior Member
I have a suggestion on this topic:
How about keeping the DiscoveryResult with properties only and automatically checking, which key is a configuration parameter when copying the values to the Thing. So if a key is a configuration parameter, it will be used as such. All others will end up as Thing properties.
This should keep backward compatibility and is probably easiest to implement.
What do others think?

Best regards,
Kai
Re: properties vs config in DiscoveryResultBuilder [message #1701088 is a reply to message #1695057] Thu, 09 July 2015 09:09 Go to previous messageGo to next message
Karel Goderis is currently offline Karel GoderisFriend
Messages: 198
Registered: March 2014
Senior Member
I think that you suggestion is fine Wink
Re: properties vs config in DiscoveryResultBuilder [message #1701760 is a reply to message #1701088] Wed, 15 July 2015 12:55 Go to previous message
Kai Kreuzer is currently offline Kai KreuzerFriend
Messages: 673
Registered: December 2011
Senior Member
Ok, I have created https://bugs.eclipse.org/bugs/show_bug.cgi?id=472733 for this.
Previous Topic:Which web server is used for openHAB2?
Next Topic:Alarm clock binding
Goto Forum:
  


Current Time: Fri Apr 26 00:28:52 GMT 2024

Powered by FUDForum. Page generated in 0.04289 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top