I have this that is almost the way I want it:
But I would like to move 0/188 and Fart/Dybde close to each other, and preferably get rid of all the frames. This is the code I have:
views:
- type: custom:masonry-layout
card_margin: -10px
path: dypriggmobil
title: Dypriggmobil
icon: mdi:cellphone
cards:
- type: custom:button-card
variables:
rød_bakgrunn: red
grønn_bakgrunn: green
gul_bakgrunn: yellow
hvit_bakgrunn: white
hvit_skrift: white
svart_skrift: black
stor_skrift: 250px
liten_skrift: 200px
dypriggdybde: '[[[ return states[''sensor.dypriggdybde'']?.state; ]]]'
dypriggbunnavstand: '[[[ return states[''sensor.dypriggbunnavstand'']?.state; ]]]'
custom_fields:
dypriggbunnavstand: |
[[[
return `<span style="align: center;">${ Math.round(states['sensor.dypriggbunnavstand'].state) }</span> `
]]]
show_icon: false
show_name: false
styles:
card:
- border-style: none
- background-color: >
[[[ if ((variables.dypriggdybde == 0)) return
variables.hvit_bakgrunn; if ((variables.dypriggdybde != 0) &&
(variables.dypriggbunnavstand <= 5)) return
variables.rød_bakgrunn; if ((variables.dypriggdybde != 0) &&
(variables.dypriggbunnavstand >= 10)) return
variables.grønn_bakgrunn; if ((variables.dypriggdybde != 0) &&
(5 < variables.dypriggbunnavstand < 10)) return
variables.gul_bakgrunn; ]]]
- height: 385px
grid:
- grid-template-areas: '"dypriggbunnavstand"'
- height: 390px
custom_fields:
dypriggbunnavstand:
- color: >
[[[ if ((variables.dypriggdybde != 0) &&
(variables.dypriggbunnavstand <= 5)) return
variables.hvit_skrift; if ((variables.dypriggdybde != 0) &&
(variables.dypriggbunnavstand > 10)) return
variables.hvit_skrift;
if ((variables.dypriggdybde != 0) && (5 > variables.dypriggbunnavstand < 10)) return variables.svart_skrift;
if ((variables.dypriggdybde == 0)) return variables.hvit_skrift;
]]]
- font-size: >
[[[ if (variables.dypriggbunnavstand > 100) return
variables.liten_skrift; if (variables.dypriggbunnavstand <
100) return variables.stor_skrift; ]]]
- type: custom:vertical-stack-in-card
cards:
- show_name: true
show_icon: false
type: custom:button-card
variables:
color_background: red
color_text: white
value: '[[[ return states[''sensor.dypriggdybde'']?.state; ]]]'
styles:
card:
- height: 50px
- border-style: none
- background-color: >
[[[ if (variables.value == 0) return
variables.color_background; ]]]
name:
- color: >
[[[ if (variables.value == 0) return variables.color_text;
]]]
tap_action:
action: perform-action
data:
topic: madmax/dypriggdybde
payload: '0'
perform_action: mqtt.publish
hold_action:
action: none
icon: ''
icon_height: 50px
name: '0'
- show_name: true
show_icon: false
type: custom:button-card
variables:
color_background: red
color_text: white
value: '[[[ return states[''sensor.dypriggdybde'']?.state; ]]]'
styles:
card:
- height: 50px
- border-style: none
- background-color: >
[[[ if (variables.value == 5) return
variables.color_background; ]]]
name:
- color: >
[[[ if (variables.value == 5) return variables.color_text;
]]]
tap_action:
action: perform-action
data:
topic: madmax/dypriggdybde
payload: '5'
perform_action: mqtt.publish
hold_action:
action: none
icon: ''
icon_height: 40px
name: '5'
- show_name: true
show_icon: false
type: custom:button-card
variables:
color_background: red
color_text: white
value: '[[[ return states[''sensor.dypriggdybde'']?.state; ]]]'
styles:
card:
- height: 50px
- border-style: none
- background-color: >
[[[ if (variables.value == 10) return
variables.color_background; ]]]
name:
- color: >
[[[ if (variables.value == 10) return variables.color_text;
]]]
tap_action:
action: perform-action
data:
topic: madmax/dypriggdybde
payload: '10'
perform_action: mqtt.publish
hold_action:
action: none
icon: ''
icon_height: 40px
name: '10'
- show_name: true
show_icon: false
type: custom:button-card
variables:
color_background: red
color_text: white
value: '[[[ return states[''sensor.dypriggdybde'']?.state; ]]]'
styles:
card:
- height: 50px
- border-style: none
- background-color: >
[[[ if (variables.value == 15) return
variables.color_background; ]]]
name:
- color: >
[[[ if (variables.value == 15) return variables.color_text;
]]]
tap_action:
action: perform-action
data:
topic: madmax/dypriggdybde
payload: '15'
perform_action: mqtt.publish
hold_action:
action: none
icon: ''
icon_height: 40px
name: '15'
- show_name: true
show_icon: false
type: custom:button-card
variables:
color_background: red
color_text: white
value: '[[[ return states[''sensor.dypriggdybde'']?.state; ]]]'
styles:
card:
- height: 50px
- border-style: none
- background-color: >
[[[ if (variables.value == 20) return
variables.color_background; ]]]
name:
- color: >
[[[ if (variables.value == 20) return variables.color_text;
]]]
tap_action:
action: perform-action
data:
topic: madmax/dypriggdybde
payload: '20'
perform_action: mqtt.publish
hold_action:
action: none
icon: ''
icon_height: 40px
name: '20'
- show_name: true
show_icon: false
type: custom:button-card
variables:
color_background: red
color_text: white
value: '[[[ return states[''sensor.dypriggdybde'']?.state; ]]]'
styles:
card:
- height: 50px
- border-style: none
- background-color: >
[[[ if (variables.value == 25) return
variables.color_background; ]]]
name:
- color: >
[[[ if (variables.value == 25) return variables.color_text;
]]]
tap_action:
action: perform-action
data:
topic: madmax/dypriggdybde
payload: '25'
perform_action: mqtt.publish
hold_action:
action: none
icon: ''
icon_height: 40px
name: '25'
- show_name: true
show_icon: false
type: custom:button-card
variables:
color_background: red
color_text: white
value: '[[[ return states[''sensor.dypriggdybde'']?.state; ]]]'
styles:
card:
- height: 50px
- border-style: none
- background-color: >
[[[ if (variables.value == 30) return
variables.color_background; ]]]
name:
- color: >
[[[ if (variables.value == 30) return variables.color_text;
]]]
tap_action:
action: perform-action
data:
topic: madmax/dypriggdybde
payload: '30'
perform_action: mqtt.publish
hold_action:
action: none
icon: ''
icon_height: 40px
name: '30'
- show_name: true
show_icon: false
type: custom:button-card
variables:
color_background: red
color_text: white
value: '[[[ return states[''sensor.dypriggdybde'']?.state; ]]]'
styles:
card:
- height: 50px
- border-style: none
- background-color: >
[[[ if (variables.value == 35) return
variables.color_background; ]]]
name:
- color: >
[[[ if (variables.value == 35) return variables.color_text;
]]]
tap_action:
action: perform-action
data:
topic: madmax/dypriggdybde
payload: '35'
perform_action: mqtt.publish
hold_action:
action: none
icon: ''
icon_height: 40px
name: '35'
- show_name: true
show_icon: false
type: custom:button-card
variables:
color_background: red
color_text: white
value: '[[[ return states[''sensor.dypriggdybde'']?.state; ]]]'
styles:
card:
- height: 50px
- border-style: none
- background-color: >
[[[ if (variables.value == 40) return
variables.color_background; ]]]
name:
- color: >
[[[ if (variables.value == 40) return variables.color_text;
]]]
tap_action:
action: perform-action
data:
topic: madmax/dypriggdybde
payload: '40'
perform_action: mqtt.publish
hold_action:
action: none
icon: ''
icon_height: 40px
name: '40'
show_state: false
horizontal: true
- type: custom:vertical-stack-in-card
cards:
- type: custom:button-card
custom_fields:
fart: |
[[[
return `<span style="align: center; font-size: 120px; line-height: 0.">${ Math.round(states['sensor.fart'].state) } </span>`
]]]
show_icon: false
show_name: false
styles:
card:
- height: 200px
- border-style: none
grid:
- grid-template-areas: '"fart"'
- grid-template-columns: 1fr
- type: custom:button-card
variables:
stor_skrift: 120px
liten_skrift: 100px
dyp: '[[[ return states[''sensor.dybde'']?.state; ]]]'
custom_fields:
dybde: |
[[[
return `<span style="align: center; line-height: 1;">${Math.round(states['sensor.dybde'].state) } </span>`
]]]
show_icon: false
show_name: false
styles:
card:
- height: 200px
- border-style: none
grid:
- grid-template-areas: '"dybde"'
- grid-template-columns: 1fr
custom_fields:
dybde:
- font-size: >
[[[ if (variables.dyp > 100) return
variables.liten_skrift; if (variables.dyp < 100) return
variables.stor_skrift; ]]]
horizontal: true
- type: custom:vertical-stack-in-card
cards:
- type: custom:button-card
name: Fart
show_icon: false
show_name: true
styles:
card:
- height: 35px
- border-style: none
name:
- font-size: 31px
- color: black
- type: custom:button-card
name: Dybde
show_icon: false
show_name: true
styles:
card:
- height: 35px
- border-style: none
name:
- font-size: 31px
- color: black
horizontal: true
- type: custom:button-card
custom_fields:
klokke: |
[[[
return `<span style="align: center; font-size: 80px">${states['sensor.time'].state}</span>`
]]]
show_icon: false
show_name: false
styles:
card:
- border-style: none
- height: 100px
grid:
- grid-template-areas: '"klokke"'
- grid-template-columns: 1fr
layout:
max_cols: 1
I thought the card_margin at the top should move cards closer to each other, but it doesn’t do anything. Can somebody please tell me what I’m doing wrong?






