diff --git a/docs/config-ref.md b/docs/config-ref.md index 7b1214c..661418b 100644 --- a/docs/config-ref.md +++ b/docs/config-ref.md @@ -68,10 +68,18 @@ definition. Apart from `sort_by` no other option requires referencing of this id | `prefix` | string | optional | to be applied _before_ all cell contents | `suffix` | string | optional | to be appended _after_ all cell contents | `multi_delimiter` | string | optional | defaults to ' ', concat multiple selector-data using this string +| `fmt` | string | optional | format using predefined 'formatters' *Use `modify` with _caution_ and on your own risk only. This will directly execute code using `eval()`, which is by definition a safety risk. Especially avoid processing any third party APIs / contents with `flex-table-card` using the `modify` parameter, *only apply this parameter, if you are 100% sure about the contents and origin of the data.* Apart from that `modify` is very powerful, see [advanced cell formatting](https://github.com/custom-cards/flex-table-card/blob/master/docs/example-cfg-advanced-cell-formatting.md). + +Currently the available formatters are: `full_datetime`, `hours_passed`, `hours_mins_passed`, `number`. Feel free to contribute, just share your best `modify` line to allow others to use them, too. + + + + + [Return to main README.md](../README.md) diff --git a/docs/example-cfg-advanced-cell-formatting.md b/docs/example-cfg-advanced-cell-formatting.md index 7e36c61..effbd39 100644 --- a/docs/example-cfg-advanced-cell-formatting.md +++ b/docs/example-cfg-advanced-cell-formatting.md @@ -1,5 +1,64 @@ ## Examples - Advanced Cell Content Formatting & Modification +Om top of the in following described method there is also now the option +to choose from predefined format styles for each cell in a column. This +is simply done by addin the `fmt` property to your column and choosing +one of the available formatters. As of now there are not many, but as +these are essentially hidden `modify:` scripts I have some hopes that people +will share their coolest formattings - making it available to everyone +through `flex-table-card` . + +``` yaml +type: custom:flex-table-card +title: Battery Levels (Top 10) +clickable: true +max_rows: 30 +sort_by: state+ +entities: + include: sensor.*_battery_level(_[0-9]+)? +columns: + - data: name + name: NodeID + - name: Battery Level (%) + data: state + fmt: number + suffix: '%' + align: right + - data: last_updated + name: Hours Passed + fmt: hours_passed + + +# make every cell/row 'clickable': show entity-popup for more entity details +clickable: true + +entities: + exclude: + - zwave.unknown_device_* + - zstick_gen5 + include: zwave.* + +columns: + # 1st + 2nd column are + , remember to set 'name' for a + # human-readable / fancy header content + - name: NodeID + data: node_id + - name: Name + data: name + + # 'receivedTS' and 'sentTS' are strings like: '2020-12-24 00:40:57:758' + # using 'modify' and a JavaScript expression the strings can be converted to + # hours using 'Date.parse' and friends + - data: receivedTS + modify: Math.round((Date.now() - Date.parse(x)) / 36000.) / 100. + name: Recv. Age (h) + - data: sentTS + modify: Math.round((Date.now() - Date.parse(x)) / 36000.) / 100. + name: Sent Age (h) +``` + + + **Monitoring and identifying nodes, which are not communicating anymore** with the Z-Wave controller, can be extracted and also sorted according to their last sent/received message with the following config: