Make two actions under widget

I need make two actions under my widget when icon is clicked - open window a start a rule.

Open window I have already implemented, but to start a rule I need set any item to any value, but I think oh-icon doesn’t support more actions. How to do it ?

Actual code is :

                        - component: oh-icon
                          config:
                            action: popup
                            actionModal: page:page_aa2a78d3a1
                            icon: sma_auto_2
                            outline: true
                            style:
                              margin-top: -5%
                            width: 75%

open the window from the rule. A widget only supports one action. But a rule can do any number of actions.

ok, so in the widget I will set any item which start rule.

Please what is a instruction in DSL to call a page? (in my case page_aa2a78d3a1)

You can set the action in the widget to call the rule. You didn’t need a separate item.

You need to configure MainUI with a command Item under Help and About → Listen for UI commands to. Help & About Page | openHAB describes what the command needs to be.

sorry I really do not understand what you mean. As I wrote, I want make two actions when oh-icon is clicked.

Information was - you must do it via rule.

So my idea is, that oh-icon will set any item to state “start” and this “start” will run a rule where more actions is. Problem is, what is correct DSL instruction which will do the same as this :

action: popup
actionModal: page:page_aa2a78d3a1

edit: or is there any “special” instruction to start a rule directly ? but it looks complicated

Once MainUI is configured to listen for commands from an Item, let’s call the Item Foo.

Then the the code is just:

Foo.sendCommand("popup:page_aa2a78d3a1")

as described in the docs I linked to:

Currently, the supported commands are:

popup:$target, popover:$target and sheet:$target: Open a $target, which can be a page ($target is page: + a page ID), a custom widget ($target is widget: + widget ID) or any oh- component ($target is the component name), in a popup, popover or sheet.

For example, to open oh-clock-card inside a popup, send popup:oh-clock-card to the UI command Item.

Or you can use @JustinG’s approach to do two actions.

Is this working only for oh-link or also for oh-icon ?

Now I have in my widget a custom icon where I want implement a two actions

It is easiest to configure if the parent component is an oh-link. I can’t see any reason why it would matter at all what type of component you use for the child, so:

- component: oh-link
  slots:
    default:
      - component: oh-icon

should work just fine.

I did it like this :

                            - component: oh-link
                              config:
                                action: variable
                                actionVariable: EVCS_Refresh
                                actionVariableValue: Refresh
                                style:
                                  pointer-events: none
                              slots:
                                default:
                                  - component: oh-icon

EVCS_Refresh must be defined on the start :

    - context: item
      description: EVCS_Refresh
      label: EVCS_Refresh
      name: EVCS_Refresh
      required: true
      type: TEXT  

or it will change directly a item with this name ?

edit:

sorry I think I found it:

                            - component: oh-link
                              config:
                                action: command
                                actionCommand: Refresh
                                actionItem: =props.EVCS_Refresh
                                style:
                                  pointer-events: none
                              slots:
                                default:
                                  - component: oh-icon
1 Like