Giter VIP home page Giter VIP logo

Comments (12)

lolodomo avatar lolodomo commented on August 15, 2024

Is it specific to MQTT things ?
Is it specific to sitemap UIs, I mean do you get the unit for this item in Main UI ?

PS: As I am not using MQTT, I will not be of a big help.

from openhab-core.

dilyanpalauzov avatar dilyanpalauzov commented on August 15, 2024

All my things are MQTT-based.

from openhab-core.

lolodomo avatar lolodomo commented on August 15, 2024

Maybe a change in MQTT stuff.
Was it OK in 4.2 milestones ?

@mherwege : maybe a link with your change openhab/openhab-addons#16866 ?

from openhab-core.

lolodomo avatar lolodomo commented on August 15, 2024

And please comment if this is specific to sitemap UIs or the same even in Main UI.

from openhab-core.

mherwege avatar mherwege commented on August 15, 2024

Without defining a unit on the MQTT channel, the MQTT binding is providing a default state description pattern of %.1f as the channel has no info about the dimension. If you add a unit definition to the channel it will be solved.
It indeed is caused by openhab/openhab-addons#16866, but I still think it is an improvement, as a default state description pattern of %s (as itwas before) creates many more issues downstream.

from openhab-core.

lolodomo avatar lolodomo commented on August 15, 2024

Considering @mherwege answer, I propose to close the issue.
In case it is not closed, @openhab/core-maintainers please rename this issue into "After upgrade to 4.2 units are not rendered implicitly for MQTT things" and move it in the addons repo.

from openhab-core.

dilyanpalauzov avatar dilyanpalauzov commented on August 15, 2024

I have an EnOcean device. This Item:

Number:Energy e1_energy "Енергия" ["Energy", "Measurement"] {channel="enocean:measurementSwitch:ABC:01234:totalusage"}

and this Thing from jsondb, excerpt from a bigger definition

        {
          "uid": "enocean:measurementSwitch:ABC:01234:totalusage",
          "id": "totalusage",
          "channelTypeUID": "enocean:totalusage",
          "itemType": "Number:Energy",
          "kind": "STATE",
          "label": "",
          "defaultTags": [],
          "properties": {},
          "configuration": {},
          "autoUpdatePolicy": "DEFAULT"
        },

in a Sitemap file as

Text item=e1_energy

shows in implicit format [%.1f kWh]

For the MQTT-Thing, but not the MQTT-broker binding itself, if unit="V" is part of the mqtt-thing definition, and the item has no state presentation, in the Sitemap on Android it is shown as "Integet V", so there is no "[%.1f V]" to print one digit after the decimal separator. The value is rounded. The statement, that the default in such cases is %.1f UNIT is not correct, the default state presentation for MQTT things, bound to items, is rounded value Integer, followed by unitname.

When I remove [%.1f V] from an Number:ElectricPotential item, bound to an mqtt-thing with unit=V, and put this item on the Overview page (MAin UI), then again it shown as [rounded Integer V],

If the same Number:ElectricPotential item, without presentation, with an mqtt-thing having unit="V", currently the Main UI does not show the unit (volts). My statement is, that OpenHAB 4.1 under the same conditions has shown the implicit unit in the Sitemap.

from openhab-core.

mherwege avatar mherwege commented on August 15, 2024

The statement, that the default in such cases is %.1f UNIT is not correct, the default state presentation for MQTT things, bound to items, is rounded value Integer, followed by unitname.

I stand corrected. The default is indeed %.0f %unit% for channels with a unit defined.
It worked before in 4.1 in the case no unit was defined because the state description was just %s. But that lead to problems when a unit is defined in 4.2 (showing the unit twice).
If no unit is defined, the channel will be assumed to represent a plain Number, hence no unit visible because the channel default state description will be %.0f, which you can then override for the item to include the unit.
So, yes, this is a breaking change. Restoring 4.1 behavior would need reverting the PR referred to, and other core PR’s. I believe the current behavior is much more consistent and logical, so I don’t think we should do that. Just adapt your configuration to your needs.

from openhab-core.

dilyanpalauzov avatar dilyanpalauzov commented on August 15, 2024

There are two ways to imply volts for an entry in a sitemap, without using state presentations:

  • if the mqtt thing has unit="V', or
  • the item is of type Number:ElectricPotential

I think any of these options should be sufficient to render V implicitly in the state presentation. That is, only the secont point, excluding the first point, should by default render V.

from openhab-core.

dilyanpalauzov avatar dilyanpalauzov commented on August 15, 2024

So, for items of type number with dimension, linked to channels, the default state presentation does not include the unit. Buf for items of type number with dimensions, not linhed to a channel, the default state presentation does render the unit: #4071 (comment) implied from the dimension, when the channel has no unit itself . I do not think this is very logical.

from openhab-core.

mherwege avatar mherwege commented on August 15, 2024

It is very logical. The channel can provide a default state description, and for the MQTT binding it always does. That has higher precedence than the default state description for items, as it is assumed the channel knows better what the default should be. Still higher priority are state descriptions defined on the Item or the Sitemap.
MQTT used to provide %s as default for anything. It now provides a meaningful default for the type of the channel. But if you not provide a unit on a Number type channel, the default will not include a unit.
These precedence rules have been in place since a long time. The MQTT binding caused problems because, while it always provided a default, it provided the wrong one.

from openhab-core.

J-N-K avatar J-N-K commented on August 15, 2024

You should not send values without a number to an item with a dimension. It is only for backward compatibility that the "item unit" is added.

Once you configure the MQTT channels correctly (with a unit) it should work, as @mherwege explained. If it does not work, then the MQTT binding is supplying a wrong state description and needs a fix. This is not a core bug.

from openhab-core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.