Fix#2283Fix#4050
This PR is fixing two things in the computation of the displayState:
- If a transformation is present in the state pattern, it has now priority over options provided by the state description
- If no transformation is present in state pattern but options are provided by the state description, the provided state pattern is applied to the matching option
Also remove a deprecated call to transform.
If there is no transformation but options are provided without any matching with the current state and there is a pattern provided, then this pattern is used to format the output.
Signed-off-by: Laurent Garnier <lg.hc@free.fr>
AFAIK these annotations are not used when using declarative services.
I stubled upon these annotations when feature validation failed while creating #3817.
Xtext now uses Guice 7 which is using jakarta.inject imports.
Only si.uom:si-units:2.1 still imports javax.inject but it will also switch to jakarta.inject when 2.2 gets released.
Signed-off-by: Wouter Born <github@maindrain.net>
* Support mired units
Mired are fairly common to describe the color temperature of
lightbulbs (slightly less common than Kelvin), but are very
useful for various calculations when adjusting the color
temperature, as well as being necessary for various integerations
that require mired units.
This commit makes them a well-known unit (previously they were
still usable, using "MK^-1"), as well as making them easier to
work with on QuantityType. The hiccup is that Mireds aren't
technically a Temperature dimension, because they're a reciprocal.
So add a `inverse` method that delegates to javax.measure's
same method, and then use it as necessary when doing unit
conversions and comparisons. Unfortunately, because the
dimension changes, the return value of a conversion won't
necessarily be the same type, an additional method is added
for callers that are willing to handle the change in
dimension. This is implemented for all callers that can use
it in core.
Signed-off-by: Cody Cutrer <cody@cutrer.us>
Unlike the sitemap SSE subscriptions generic event subscriptions did not implement a connection lost monitor.
Signed-off-by: Jan N. Klug <github@klug.nrw>
* Add more null annotations
* Fix mock name
Adds null annotations to most of the tests as well as a few other classes.
Also fixes a few other SAT findings.
Fixes ~300 SAT findings in total.
Signed-off-by: Wouter Born <github@maindrain.net>
* Display raw item state when formatting fails
With the addition of Profiles, there are situations where a Channel sends format information that
does not match the type. For example, "Timestamp on update" always sends a DateTime, but the channel
may specify a different format (e.g., if it is a battery level, "%.0f %%"). In such a case, we
attempt to format the DateTime according to the pattern, it (predictably and correctly) fails, and
this results in an error in the UI and a warning in the log.
While this is an expected error if a user uses an incorrect format code in an Item's metadata (user
error), it is somewhat unexpected if a user is choosing an option as presented in the UI. Because
this is purely a formatting issue, one solution is to direct users to add a formatting code if they
see an error. However, the disadvantage of this approach is that it doesn't work "out of the box."
This patch attempts to address the issue by displaying the raw Item state when formatting fails
instead of displaying "Err". This should provide a more balanced approach with a predictable
outcome. In addition, when a user is intentionally changing the pattern via metadata and gets it
wrong, they should still see info in the log that helps them get to the root of the problem, but
I've changed it from warn to info so it will be a little less noisy for those who choose to ignore
it.
This solution was discussed in https://github.com/openhab/openhab-core/issues/2037 and
https://community.openhab.org/t/timestamps-not-rendering-consistently-in-ui-3-0-2/121891/2
Thank you to @Rossko57 and @cweitkamp for their help in figuring it out, and in suggesting the
solution.
Signed-off-by: Brian Warner <brian@bdwarner.com>
(I included these fixes in #1735 but extracted them in a stanalone
PR because it's easier to review and a little more urgent.)
As a result of the refactoring in #1713, the operations annotated with
`@RolesAllowed` containing `Role.USER` are not anymore automatically
considered accessible to all users, regardless of their actual roles.
4 operations are therefore now denied to admins if they only have the
`Role.ADMIN` role, as the first admininistrator is created only with
that role the UI encounters unexpected access denied errors and breaks.
(See https://github.com/openhab/openhab-webui/issues/422).
Closes https://github.com/openhab/openhab-webui/issues/422.
Signed-off-by: Yannick Schaus <github@schaus.net>
* Migrates all tests to the JUnit 5 Jupiter API
* Updates bnd to 5.1.2
* Updates maven-surefire-plugin to 3.0.0-M5
* Updates Mockito to 3.4.6
* Updates Hamcrest to 2.2
* Removes org.openhab.core.boot POM dependencies
Signed-off-by: Wouter Born <github@maindrain.net>
* Migrate to JAX-RS Whiteboard
* Upgrade Jackson and Swagger TP feature dependencies
The upstream JAX-RS Whiteboard feature is not used because the version ranges currently do not work with Karaf on Windows.
See: https://issues.apache.org/jira/browse/KARAF-6536
* Update Felix logback to 1.0.2
This version adds the jul-to-slf4j bridge (FELIX-6027).
JUL is used by CXF and using the bridge we can use logback to reduce the verbosity of the info logging whenever org.apache.cxf.endpoint.ServerImpl creates endpoints.
* Update Aries Whiteboard to 1.0.8
* Removes the hated default web application (ARIES-1931)
* Improves performance
* Uses CXF 3.2.12
* Don't reuse SSE event builders
SSE event builders are not thread-safe.
It also causes the wrong default values being used.
Also-by: Markus Rathgeb <maggu2810@gmail.com>
Signed-off-by: Wouter Born <github@maindrain.net>