OK, here’s another question. Is there a way to use the default widget config from the Item in the code above? Or is this a case where it has to be defined. I tried to replace the config from one of the components with just item: NameOfItem after modifying that Item to override the default List Widget and it came up blank.
Do the default widgets only come into play when adding widgets from the model?
Yes, I wish we had dynamic resolving of default widgets too but since they’re stored in metadata and can’t be retrieved efficiently right now (we don’t want a call to the API to figure out the default control multiple times in the page, that would have poor performance), maybe that’s something that could be retrieved early, cached and somehow kept current in the future… then that could become possible.
Thanks, I’m becoming smarter and smarter on OH 3 and the new UI every day. I hope to start really contributing to the wiki pages here very soon with what I’ve learned.
Very cool! It’s probably easy to feel overwhelmed at first, but with decent tutorials and docs, one can start with little things, like changing the color or a button or similar, to understand the concepts, and go on from there
And if we manage to get good design talent on board, given that you have the ability to heavily alter the CSS styling if you want to, why not, I believe it’s not completely out of reach to have a least some of the “inspirational” concepts below imitated and offered as community contributions (to some extent, of course):
I dont know of this is the right place for this question here?
When i take a look on the examples and past them in a widget to examing on how to make a widget, it is dificult to link the code to what is hapening in the preview.
Sometimes it is, yep - theres a lot of configuration and nesting involved until you see something in the preview - especially on the more complex ones. Using the code-editor tooltips on the components config will help here.
What would be your suggestion to make it easier to understand?
More sophisticated widget examples will come up in the future which should help you, getting a better understanding of the YAML-structure and the component-configuration.
Until then, have a look at the framework7 docs and just play around with what you see there - it helped me a lot.
Maybe just a dashed rectangle in the view to indicate ware in the code you are
In drawing programs like autocad or revit, when you select someting it change color or gives connetors to indicate on your screen your selection.
Or another way is when you select something in the view the code is higlhighted.
Generally a good Idea and worth posting this as an enhancement suggestion on the github page - but this might have implications to the code-editors performance and someone have to build it of course.
In the meantime you could use the build-in Chrome dev-tools to inspect (and highlight) your code. It helps a lot!
i am trying to set the backgroud color of oh-cell. Is it at all possible? I see a Highlight color option but it doesnt seem to do anything… even if i click on the cell with a valid action set. pls help
thanks! by hit and trial, i discovered that in an oh-cell the color property works only if there is an item property defined, even if it is null. but the oh-cell doesnt really expose item as a configurable prop in the UI. as compared to the oh-cell, the oh-label-cell type does have an item property exposed. might be worth looking into.
You’re trying to display an image inside the oh-button component I suppose. oh-button (and the f7-component it’s based on) doesn’t support slots - so this will not work.
Generally the oh-button component only supports icons from the f7- and the material-iconset, which I attached an example below.
For explanation to the oh-image component you’re trying to use - the ‘/static/’ path corresponds with the ‘/etc/openhab/html/’ folder of your installation. And you don’t need the equal sign in that case, because you’re not accessing a prop, item or variable. So this would work, if you place an image in the above mentioned path:
To reach your initial goal, you have to use a small workaround. (see the third button example in the code below) Be aware that there is a slight distinction with this workaround in the ‘hover’ and ‘pressed’-state of the button.
You also can leave your icon inside the ‘/etc/openhab/icons/classic/’ folder then, as ‘oh-icon’ is looking for icons there and in the integrated OH-iconset.
The new mainui is great, many thanks for this and also for the good article how to create widgets. This was a good starting point.
Does anyone know if it is possible to use javascript or angularjs to dynamically build e.g. f7-rows. I used this on habpanel to extract parts of a json string for my heating control.
first of all it would be very helpfull if you use code-fences to make your code readable. I also think, that it wouldn’t help you if anybody here present you a ready-2-go soloution, so I´ll try it with some general tips, that helped me…
Read Part 1 and Part 2 of this writeup again and try to understand the general mechanic of slots and components.
Have a look in the f7-vue-documentation to see what components the framework offers (even if not all of them interacting with OH currently). The global f7-docs could also be helpfull (for things like css classes etc.)
Start small. Instead of modifying already existing (complex) code examples, try to set yourself small goals as a starting point (maybe bringing 4 customs buttons in one row) and work up from there.
To at least briefly address your current problem (as far as it´s possible in that code mess ). It seems you are wrapping all the columns (in which the 1 - 4 buttons are) inside the row from my button-example.
The f7-row in the example acts just as a horizontal wrapper for the contents of the “fake-button” so it replaces a button in the keypad example, not a whole row. The component order here should be then:
Pure javascript can’t be used AFAIK. There are just some ‘javascript-like’ functions that you can use at the moment as @ysc mentioned here. But these are too limited for your use-case, I think.
I tried to do a similar thing with a dynamic created button-list and ended creating a bunch of placeholder components (which of course could be f7-rows) and triggered their visibility with expressions.
What also might work for you (even if its not customizable and limited to the use in a modal overlay) is adding an ‘action: group’, which creates a list item component for each group member. (see this discussion)
I tried to use code-fence, but my cromium browser is having a hard time with it.
I’ve read it several times, but I can’t get a clear view of it yet. (but i also find this with other programming languages and is a more common problem with the current manuals, they explain all the features, but not how to use them. )
it is not always clear how to use this in yaml, the different examples show different possibilities.