wonderslug / MMM-HomeAssistantDisplay

A Magic Mirror Module to display information from Home Assistant.
MIT License
83 stars 6 forks source link

Line Feed in displayTemplate #5

Closed holdestmade closed 2 years ago

holdestmade commented 2 years ago

Hi, thanks for this module, it's working great.

Was wondering if it is possible to create a list on separate lines, rather than on one line ?

This displayTemplate renders all on one line:

Grass: Zero, Tree: Very Low, Weed: Zero

What I'd like is:

Grass: Zero
Tree: Very Low
Weed: Zero

I've tried \n but doesn't work

        {       
            module: "MMM-HomeAssistantDisplay",
            position: "top_right",
            config: {
                host: "192.168.1.40",
                token: "xxxxxxx",
                port: 8123,
                title: "Pollen",
                useModuleTigger: false,
                class: "pollen_today",
                sections: [{
                    triggerEntities: [
                        "sensor.pollen_grass_today",
                        "sensor.pollen_tree_today",
                        "sensor.pollen_weed_today"
                    ],
                    displayTemplate: `
                        Grass: {{ states.sensor.pollen_grass_today.state }}, 
                        Tree: {{ states.sensor.pollen_tree_today.state }}, 
                        Weed: {{ states.sensor.pollen_weed_today.state }}
                        `,
                    class: "pollen_today"
                }]
            },
        },
holdestmade commented 2 years ago

It's ok I figured it out, just use multiple sections !

        {       
            module: "MMM-HomeAssistantDisplay",
            position: "top_right",
            config: {
                host: "192.168.1.40",
                token: "xxxxxxx",
                port: 8123,
                title: "Pollen",
                useModuleTigger: false,
                class: "pollen_today",
                sections: [{
                    triggerEntities: [
                        "sensor.pollen_grass_today"
                    ],
                    displayTemplate: `
                        Grass: {{ states.sensor.pollen_grass_today.state }}
                        `,
                    class: "pollen_today"
                },
                {
                    triggerEntities: [
                        "sensor.pollen_tree_today"
                    ],
                    displayTemplate: `
                        Tree: {{ states.sensor.pollen_tree_today.state }}
                        `,
                    class: "pollen_today"
                },
                {
                    triggerEntities: [
                        "sensor.pollen_weede_today"
                    ],
                    displayTemplate: `
                        Weed: {{ states.sensor.pollen_weed_today.state }}
                        `,
                    class: "pollen_today"
                }
            ]
            },
        },