Skip to main content

Dynamic Values

Many layers have a value field that defines their main value. Good examples are the text or the color layer. They can be given static values directly in the layout or values from external data through a client template, as described in the client_template concept page.

However, it is also possible, to assign a dynamic value to a layer. This can be done with evaluables. Each evaluable can be assigned to a value field, though mostly it will be value expressions or transformation expressions.

The core difference between assigning a static and a dynamic value is, that the dynamic value will update itself. For example, if the context query is chosen for a value expression, the mos runtime will analyze the query, and if any used table is updated, the query will automatically run again. This is valid for every context that can change during runtime, like user settings, variables etc.

Examples

Goal: Display the current device time.

{
"type": "text",
"value": {
"transform": "formatDate",
"left": {
"context": "date"
},
"right": {
"value": "HH:MM"
}
}
}

Goal: Display the current outdoor temperature, which is stored in a db_table and updated from an external source.

{
"type": "text",
"value": {
"context": "query",
"table": "weather",
"query": "currentWeather",
"field": "temperature"
}
}