How to reuse tabbed and chart pages?

Hi,

for different sensors (water, gas, energy, rain, …) I always create the same pages: A tabbed page with 3 chart pages in the tabs (annual, monthly, daily).

But these are 4 pages for every sensor. It would be much better to have parameterized pages that can be reused.

Does anyone know of a way how this could be implemented?

I’m also missing something lika a day, week, month, year, decade button in the aggregate charts.
I think we need to request this. Not sure how we can do that.

Pages can take advantage of the vars system for widgets. So in a page you can have multiple widgets that all use the same variable. When you are linking to a page from some other widget it is possible to set those page variables using the actionPageDefineVars object.

Here’s and example. I have a page that generates a list of items. I want to be able to click on each item in that list and open the same page but using that item. So each item in the list looks like this:

- component: oh-list-item
  config:
    action: navigate
    actionPage: page:details_page
    actionPageDefineVars:
      pageItem: =loop.sensorGroup.name
    footer: =loop.sensorGroup.name
    name: sensorSelectRadio
    title: =loop.sensorGroup.label

The action for this item is to navigate to a page called details_page. When it does, it also sets the pageItem item variable for that page as the name of an item.

On details_page there’s a widget that is defined like this:

config:
  label: Sensor Details
blocks:
  - component: oh-block
    config: {}
    slots:
      default:
        - component: oh-grid-row
          config: {}
          slots:
            default:
              - component: oh-grid-col
                config: {}
                slots:
                  default:
                    - component: widget:sensor_details
                      config:
                        sensor: =vars.pageItem || 'gBasicSensor'
masonry: null
grid: []
canvas: []

That widget has a sensor property and that sensor property will be set to the page variable pageItem (or a default value if pageItem does not exist). So, when this page is called by a click on one of the list items above it gets opened and passed the value from the list to the page’s widget using the pageItem variable.