rossko57
(Rossko57)
December 16, 2021, 9:53pm
22
The channel linking process has a feature (in my view poorly designed) where the binding can ‘suggest’ - in practice, silently force - a suitable pattern into metadata.
That should happen only once, at linking time.
You should be able to hand-edit a more suitable pattern after that one-time action.
Clearly that can lead to an issue where a switch type channel is linked to a DateTime Item, and a ‘switch’ suitable pattern is forced on the DateTime.
Open issue -
opened 09:36PM - 30 Dec 20 UTC
bug
I'm using openHAB 3.0 with docker on a linux host system.
My use case is an a… larm indicating that the humidity in my bathroom is over a certain upper value. When this happens the bathroom fan is turned on to bring the humidity down. The fan should stay on until the humidity drops below a certain lower value.
For this I configured a switch item carrying the alarm value and linked it to the humidity sensor with a channel configured for the hysteresis profile.
The expected outcome should be a switch item handling the alarm value with the hysteresis in place. The current outcome is that the item goes into an error state.
The item configuration is:

The channel link configuration is:

As you can see in the screen shots, the state is "Err". The probable cause might be the following log entry:
```
2020-12-30 00:41:22.012 [WARN ] [e.internal.SseItemStatesEventBuilder] - Exception while formatting value 'OFF' of item Badezimmer_Sicherheit_Feuchtigkeitsalarm with format '%.0f': f != java.lang.String
```
Unrelated to that -
The timestamp profile itself had a weird bug where it kept forcing Item update if something else changed it - such as you might get when linking two timestamps to same Item.
That one at least has been fixed recently -
opened 06:55PM - 01 Jul 20 UTC
closed 09:05AM - 18 May 21 UTC
Example Item, using channel profile **timestamp-update** -
`DateTime testTime… "testing" {channel="openweathermap:weather-and-forecast:api:foss:current#condition" [profile="timestamp-update"]}`
Expectation - when that channel updates, the Item state will be updated with a timestamp. That works well enough -
```
2020-07-01 19:01:56.453 [vent.ItemStateChangedEvent] - testTime changed from 2020-07-01T17:41:27.007+0100 to 2020-07-01T19:01:56.368+0100`
```
But, postUpdating the Item with some other value somehow causes the profile to immediately overwrite the state with a completely new value of "now"
```
2020-07-01 19:35:22.903 [vent.ItemStateChangedEvent] - testTime changed from 2020-07-01T19:01:56.368+0100 to 2011-01-01T10:10:10.000+0000
2020-07-01 19:35:22.934 [vent.ItemStateChangedEvent] - testTime changed from 2011-01-01T10:10:10.000+0000 to 2020-07-01T19:35:22.910+0100
```
Expectation here is that profile does nothing until the next real update of the associated channel. It should not destroy any manually set value of the Item. It certainly should not "invent" a new timestamp unrelated to its channel activity.
A nastier consequence; it is reasonable to link more than one channel with timestamp profile to a single Item, say to record the most recent event for any one of a set of sensors.
`DateTime testTime {channel="x:x:x:x" [profile="timestamp-update"], channel="z:z:z:z" [profile="timestamp-update"]}`
This results in disaster, the two profiles enter a loop of warring updates every few milliseconds
```
2020-07-01 19:47:25.926 [.ItemChannelLinkAddedEvent] - Link 'testTime-openweathermap:weather-and-forecast:api:foss:current#condition-id' has been added.
2020-07-01 19:47:25.940 [vent.ItemStateChangedEvent] - testTime changed from 2020-07-01T19:44:47.686+0100 to 2020-07-01T19:47:25.924+0100
2020-07-01 19:47:25.950 [vent.ItemStateChangedEvent] - testTime changed from 2020-07-01T19:47:25.924+0100 to 2020-07-01T19:47:25.934+0100
2020-07-01 19:47:25.957 [vent.ItemStateChangedEvent] - testTime changed from 2020-07-01T19:47:25.934+0100 to 2020-07-01T19:47:25.949+0100
2020-07-01 19:47:25.966 [vent.ItemStateChangedEvent] - testTime changed from 2020-07-01T19:47:25.949+0100 to 2020-07-01T19:47:25.958+0100
2020-07-01 19:47:25.975 [vent.ItemStateChangedEvent] - testTime changed from 2020-07-01T19:47:25.958+0100 to 2020-07-01T19:47:25.965+0100
```
This presumably also affects **timestamp-change**, and potentially other profiles.
but I wonder if an unnoticed effect of that was also re-forcing target Item pattern.
EDIT - ah I was just reminded of a nasty consequence of the ‘link forcing a pattern’ strategy. A binding may also suggest ‘state option’ metadata. e.g. a motion sensor switch sets [ON = motion, OFF=idle]. That is really going to screw up when used with a DateTime. You might check your misbehaving Item(s) for that metadata, too.