As I don’t wanna mess up this thread anymore, I created a seperate topic for this question:
You missed the quotes at the ON/OFF string in your expression - the above code should work in a oh-label-card like this (as said, it only works for the content part of the widget and not for the title and footer)
Generally no - the standard widgets uses pre-defined styles so that other styles gets overwritten.
What exactly do you want to achieve?
Assuming you want to align your text left or right inside the widget - you could recreate your above shown variant of the ‘oh-label-card’ like this and changing the style attribute inside the ‘text’ slot to your liking:
@RGroll thanks very much for the example - that is great!
I guess I’m just trying to understand the extent of customization that can be done to a default widget.
Not sure if you’d be able to point me in the direction of some documentation, from my understanding for OH3 the F7 framework has been adopted. Would be beneficial to understand the framework itself and how the YAML files are structured for use within OH.
Assuming that you’ve already read the documentation threads (1, 2 and 3) a usefull next step would be digging into the f7-documentation itself, which you can find here and here - on a detailed component level.
It would also be usefull to look into the above mentioned widgets and try to understand what was done there and maybe adapting them to your liking to get comfortable with the YAML-syntax of the widgets.
Last but not least, It helps keeping an eye on the openhab-webui github repo and try to keep yourself updated with the latest changes and the examples that comes with the commits. @ysc for example is doing a great job providing examples to nearly everything he implements into the MainUI.
Hope this helps a bit.
P.S. Here you can find the standard widget-components (in raw vue-markup) that are currently implemented into the UI. This might also help to see what components were used.
I’d think that it should affect both tbh - the UoM (e.g. Number:Temperature) influences both states (the raw and display-state) and adds the respective scheme and value symbol (at least, if no stateDescription is given) - so this part is correct. But if you additionally set ‘%.2f °C’ as the state description, it should change the displayState to your desired value & symbol. At least, this is how it works in my setup and how I understand this article in the docs.
This is how the states behave in the different scenarios for me:
UoM_with_state_description [%.2f °C]
Number_with_state_description [%.2f °C]
I don’t work with the semantic model that much tbh and only uses textual configuration (and try to avoid QuantityTypes in the most cases as it makes it hard to using Math functions) - so don’t count too much on my words.
Maybe someone else has an idea what’s going on in your case?!
I don’t know what is the ‘intended’ behaviour tbh. At least it’s somewhat strange, that the behaviour seems to differ from my setup to yours. Personally I would say, that everything that works is fine.
But we could try to find the reason for the differences in our setups. I’m on build 2103 and using only textual configuration for my things and items. This is how my config looks for this test-item (I used some temp item from the OWM-binding for testing)
It’s interesting that there is a state description meta data even though I deleted it from the Ui. Also, it is not the one I set earlier so I guess it is automatically added somehow? Could you check what getting your item in the REST results in?
The string comparison indeed works, but it is very cumbersome as I can compare ‘3.00 °C’ < ‘9.99 °C’ but as soon as the number of digits change it won’t work as it is only comparing character wise.
Is there a math method usable in the yaml code?
You are right - good find with the digits.
You generally can use Math methods in YAML for example =Math.round(items.XY.state) works - sadly it won’t work here as it takes the value into account which messes up the calculation obviously.
This is the reason for me, I mostly renounce from using types or at least defining a separate stateDescription without the value symbol for calculations like %.0f - so that =Math.round(items.XY.displayState) would work.
I have tried with some Math expressions like Math.unit.parse(items.XY.state) and trying to get the value but I always get “undefined” as result.
Changing the state description will also change the display of items on label cards.
Maybe @ysc can help here? Sorry for pinging you Yannick - I hope it’s OK…
Can you give us an example of a Number:Temperature item comparison in the widget YAML?