Dynamic Selector

Dynamic Selector allows you to query data based on the digital twin structure and datapoint properties without the need of naming and listing datapoints.

e.g. you could select all temperatures within your equipment automatically

df = wizata_dsapi.api().query(
  datapoints=[{
              "category": "Temperature"
            }],
  twin="DYNAMICTWIN",
  start='now-1d',
  end='now'
)

Important ❗ - The query must be filter on a twin (hardware id or uuid) and it look for datapoint attached not only on that specific twin but also on all subsequent childrens of that twin.

Structure & Usages

A dynamic selector can be declared as a dict or directly as an object instance of wizata_dsapi.DynamicSelector

e.g. here is a complete Dynamic Selector reference and its equivalent as a dict

wizata_dsapi.DynamicSelector(
  category="Temperature",
  unit="°C",
  twin_type="Motor",
  business_type=wizata_dsapi.BusinessType.TELEMETRY,
  rename="temperature_c",
  agg_method="mean"
)
{
	"category":"Temperature",
	"unit":"°C",
	"twin_type":"Motor",
	"business_type":"telemetry",
	"rename":"temperature_c",
	"agg_method":"mean"
}

Description of all filters and selection capabilities:

PropertyTypeDescription
categorystr or uuidfilter based on name or id of a datapoint category.
unitstr or uuidfilter based on symbol or id of a datapoint unit
twin_typestrfilter based on a Twin Type name on twin on which is attached the datapoint. It will not look for children of that twin (except if correct type).
business_typestr or BusinessTypefilter based on a datapoint business type.
renamestrrename results columns on dataframe to a specific name and if multiple add 1,2,3, ... (e.g. "rename": "tmp" -> tmp1, tmp2 ...tmpX)
agg_methodstr ("mean")aggregate columns together if multiple columns are found.

Multiple Selectors

It is totally possible to use multiple selectors within a query, e.g. the following query returns average temperature of motors and average speed of pump of twin 'DYNAMICTWIN'

df = wizata_dsapi.api().query(
  datapoints=[
              {
                  "category":"Temperature",
                  "twin_type":"Motor",
                  "rename":"temperature_motor",
                  "agg_method":"mean"
                },
              {
                  "category": "Speed",
                  "twin_type": "Pump",
                  "rename": "speed_pump",
                  "agg_method":"mean"
                }
            ],
  twin="DYNAMICTWIN",
  start='now-1d',
  interval=60000,
  agg_method="mean",
  end='now'
)

Combine with static selection

The query can also be combining normal datapoint/template selection and dynamic selector :

df = wizata_dsapi.api().query(
  datapoints=[
              {
                  "category":"Temperature",
                  "twin_type":"Motor",
                  "rename":"temperature_motor",
                  "agg_method":"mean"
                },
              "dummy_sensor_1",
              "dummy_sensor_2"
            ],
  twin="DYNAMICTWIN",
  start='now-1d',
  interval=60000,
  agg_method="mean",
  end='now'
)

Attention, if your datapoint is part of the dynamic selector and a static selection, it will appear only once in the result.