Forum Discussion
Hi Malcolm, this block will output close to what you want. You'll need to update the list of fields on line 2, and replace 'c' on lines 3 and 5 with the appropriate step letter in your pipeline:
{# Define the list of fields to use -#}
{% set fields = ['doorbell_camera', 'indoor_camera', 'outdoor_camera', 'takeout_camera', 'door_window_sensor'] -%}
{% for field in fields if c[field]|int > 0 -%}
{# Format/capitalize the field name -#}
{{field.split('_') | map('capitalize')|join(' ') }}: {{c[field]}}{{ ' | ' if not loop.last }}
{%- endfor -%}
Sample output:
Doorbell Camera: 1 | Takeout Camera: 3 | Door Window Sensor: 2
The field names don't have the exact formatting (e.g. no slashes) since that info isn't available on the jinja field name.
Hope that helps!
------------------------------
Doug Henning
------------------------------
- MalcolmMcDonald2 years agoQrew Cadet
Actual genius .. thank you Mr. Henning!
And for future searchers on this topic .. I had quite a number of "illegal" characters in the field name, but the pipeline field picker showed me what to do .. so for eg - Doorlock(Brass-15) shows as {{a.doorlock_brass_15}} .. ie the jinja needs the open parenthesis as an underscore, but drops the close parenthesis entirely.
------------------------------
Malcolm McDonald
------------------------------