OH3 Widget popover question

Hi,

just getting into the Pages/Widgets feature. Just created a floorplan with markers. Clicking on them opens a popover. Now the following question: is there a way to pass a variable (or something like name of marker calling the popover would be enough) to the popover? I have a few markers showing different values. Clicking on them should open a popover which allows to do some settings (matching the markers corresponding items). It would be easy to create a own widget for each marker but isn’t there a better solution?

ok already figuerd it out after re-reading the wiki-pages here for the 6-time. Got it working with Yannick example of the keypad. (did try it similar way already but did not work but with the example its clear) If someone encounter same:
ex. use this inside the config part of a marker etc.

  action: popover
  actionModal: widget:rollershutter_popup
  actionModalConfig:
    item: Tester

define inside the widget under the “props/parameter” label your item like

- context: item
  description: An item to control
  label: Item
  name: item
  required: false
  type: TEXT

and use it inside your widget like

=items[props.item].state

So i can now finally have a multiple marker which open (when clicking on them) a popover using already the right item (with only one widget)
Once you get into the YAML and understanding it, it’s getting simpler every time. I like it.

//EDIT:
You can also set more items. Just use the item-name you set (unde props in your widget) inside the actionModalConfig like:

  actionModalConfig:
    item_1: TestItem1
    item_2: TestItem2

In this manner you can also pass other values or things like variables (instead of the item i use props)

2 Likes

Thanks. You figured it out. The docs are being worked on but there’s still a lot to write on that matter.

I’ve not yet migrated those Pages. If you can go and add what you’ve learned to them that would be greatly appreciated.

can I also send params to a page? e.g. set the oh-time-series within a Chart page through a parameter?

When I add a

props:
parameters:
- context: item

it gets removed from my chart page after saving.

Chart pages are still largely ignoring expressions so props wouldn’t be useful anyways.
But that’s something that would have to be improved in the next months, so you could have “generic” pages with props and e.g. open them in an action context, in a popup or even standard navigation, with the prop values assigned by the “caller”.

It’s been planned from the start but still needs work.
That’s why the description of the target props when you select a page-or-widget-related action hint at pages defining props too.
image

I see. Thanks Yannick!

Does someone knows how to get the actionModalConfig part defined via items file?
I tried this but does not accept:

value: oh-label-item
config:
  action: popup
  actionModal: widget:rlk_datetime_standalone
  actionModalConfig:
    item: HomematicIP_Thermostat_Badezimmer_Profile_Override_EndDateTime
    label: Endzeitpunkt
DateTime                    HomematicIP_Thermostat_Badezimmer_Profile_Override_EndDateTime        "Profil Soll Ende [%1$td.%1$tm.%1$tY %1$tH:%1$tM]"              <calendar>       (gBadezimmerThermostat)                                                                                                                              ["Point","None"]                 {stateDescription="" [pattern="%1$td.%1$tm.%1$tY %1$tH:%1$tM"], listWidget="oh-label-item" [action="popup",actionModal="widget:rlk_datetime_standalone",actionModalConfig=""[item="HomematicIP_Thermostat_Badezimmer_Profile_Override_EndDateTime"]]}
Configuration model 'test.items' has errors, therefore ignoring it: [11,534]: mismatched input '[' expecting ']'

Would be something like:

component: oh-cell
config:
  action: popup
  actionModal: widget:caddx_graphic_portrait_V6
  actionModalConfig:
    alarmFeedback: Alarm_Feedback
    sendCommand: CaddxBridge_SendCommand
    tooltipEnable: true
  title: Alarm

where each line refers to a props setting in your widget.

OK, but how do I use this via items file?

Would not expect that you can. What are you trying to achieve?

That part is probably wrong. Metadata takes the format:

<namespace>="<value>"[<key1>="<value1>",<key2>="<value2>",...]

The config part (i.e. the stuff in [ ]) is an array of key/value pairs. Metadata is not recursive so you can’t put separate metadata inside the config.

In short, get rid of those extraneous "".

actionModealConfig=[item="HomaticIP_T

Trying the following:

DateTime                    HomematicIP_Thermostat_Badezimmer_Profile_Override_EndDateTime        "Profil Soll Ende [%1$td.%1$tm.%1$tY %1$tH:%1$tM]"              <calendar>       (gBadezimmerThermostat)                                                                                                                              ["Point","None"]                 {stateDescription="" [pattern="%1$td.%1$tm.%1$tY %1$tH:%1$tM"],listWidget="oh-label-item"[action="popup",actionModal="widget:rlk_datetime_standalone",item="HomematicIP_Thermostat_Badezimmer_Profile_Override_EndDateTime",label="Endzeitpunkt"]}

This causes the generation of the following code if checking in MainUI:

value: oh-label-item
config:
  action: popup
  actionModal: widget:rlk_datetime_standalone
  item: HomematicIP_Thermostat_Badezimmer_Profile_Override_EndDateTime
  label: Endzeitpunkt

The log shows also a message:

[WARN ] [e.internal.SseItemStatesEventBuilder] - Attempting to send a state update of an item which doesn't exist: undefined

I think I would need to add the cascaded attributes via items file somehow.

@rlkoshak this is a potential workaround for the missing send button of the list widget I thought about.

I didn’t say to remove the actionModalConfig in it’s entirety. Just the double quotes after the =.

The error is probably unrelated. You’ll see that error when you have an Item that doesn’t exist trying to be displayed on a MainUI page.

I don’t see how.

Not sure if I get your point. removing “” after stateDescription does not work and brings syntax errors in the log.

Similar for actionModal config. None of the following worked, all have brought up syntax errors (just pasting the relevant part)

actionModalConfig=""[
actionModalConfig=[
actionModalConfig[

As this is already nested within [], I am not sure how to correctly define this.

Only workaround I got it working: Define the item via MainUI. As I have all items via items file, this is not appreciated.

It should be possible to define in .items files. But I don’t really support .items files any more (far more time is wasted solving syntax errors that are impossible to make in the UI than any perceived benefit from using .items files) so have few further ideas. All I can say is

Syntax Correct
actionModalConfig=""[ Definitely Wrong
actionModalConfig[ Definitely Wrong
actionModalConfig=[ Possibly Correct

If it still doesn’t parse, there is something else wrong with the syntax.

The [ ] denotes an array. The value for a key/value pair in metadata config should allow an array. However, you are not actually defining an array here but a map. So maybe if needs to be actionModalConfig={...} instead. I’ve no ideas beyond that.