Iāve modified the room card to show data from the plaato keg management integration.
More details:
- The 1st (top right) sensor will be filled with color to match the percent left in the keg.
- The 2nd sensor showing gallons of beer left will also be filled with color to match the percent left in the keg.
- The 3rd icon is for the binary leak detection sensor. It will turn red and change the icon if it detects a leak.
I apologize for a ton of repeated yaml for each scale, havenāt spent any time looking into making it a configurable custom card. Hopefully it inspires someone else.
cards:
- type: 'custom:button-card'
template:
- card_room
- grey_no_state
name: >
[[[
return entity.attributes.beer_name
]]]
label: >
[[[
var current = Date.now();
var previous = Date.parse(entity.attributes.keg_date);
var msPerMinute = 60 * 1000;
var msPerHour = msPerMinute * 60;
var msPerDay = msPerHour * 24;
var msPerMonth = msPerDay * 30;
var msPerYear = msPerDay * 365;
var elapsed = current - previous;
var relativeTime = '';
if (elapsed < msPerMinute) {
relativeTime = Math.round(elapsed/1000) + ' seconds';
}
else if (elapsed < msPerHour) {
relativeTime = Math.round(elapsed/msPerMinute) + ' minutes';
}
else if (elapsed < msPerDay ) {
relativeTime = Math.round(elapsed/msPerHour ) + ' hours';
}
else if (elapsed < msPerMonth) {
relativeTime = Math.round(elapsed/msPerDay) + ' days';
}
else if (elapsed < msPerYear) {
relativeTime = Math.round(elapsed/msPerMonth) + ' months';
}
else {
relativeTime = Math.round(elapsed/msPerYear ) + ' years';
}
return "Connected on " + new Date(previous).toDateString() + "<br />Serving gas for " + relativeTime
]]]
icon: mdi:molecule-co2
entity: sensor.plaato_keg_co2_tank_percent_beer_left
styles:
label:
- font-size: 18px
- text-align: left
name:
- font-size: 30px
custom_fields:
i1:
- border-radius: "10%"
- width: "80%"
- height: "80%"
- line-height: 0
variables:
entity_1:
color: yellow
entity_id: sensor.plaato_keg_co2_tank_percent_beer_left
tap_action:
action: more-info
entity_2:
color: yellow
entity_id: sensor.plaato_keg_co2_tank_beer_left
tap_action:
action: more-info
custom_fields:
i1:
card:
type: "custom:button-card"
show_icon: false
show_name: true
entity: >
[[[
if (variables.entity_1.entity_id) {
return variables.entity_1.entity_id;
}
]]]
state:
- name: >
[[[
return states[variables.entity_1.entity_id].state + "% <br />remaining"
]]]
operator: default
styles:
card:
- background: >
[[[
return "linear-gradient(to top, rgba(var(--color-" + variables.entity_1.color + "),0.6) " + entity.state + "%, rgba(45, 45, 45, 0.9) " + entity.state + "%)"
]]]
name:
- font-weight: bold
- grid-area: initial
- color: white
i2:
card:
type: "custom:button-card"
show_icon: false
show_name: true
entity: >
[[[
if (variables.entity_2.entity_id) {
return variables.entity_2.entity_id;
}
]]]
state:
- name: >
[[[
return states[variables.entity_2.entity_id].state + " " + states[variables.entity_2.entity_id].attributes.unit_of_measurement + " <br />remaining"
]]]
operator: default
styles:
card:
- background: >
[[[
return "linear-gradient(to top, rgba(var(--color-" + variables.entity_2.color + "),0.6) " + entity.state + "%, rgba(45, 45, 45, 0.9) " + entity.state + "%)"
]]]
name:
- font-weight: bold
- grid-area: initial
- color: white
- type: 'custom:button-card'
template:
- card_room
- blue_no_state
name: >
[[[
return entity.attributes.beer_name
]]]
label: >
[[[
var current = Date.now();
var previous = Date.parse(entity.attributes.keg_date);
var msPerMinute = 60 * 1000;
var msPerHour = msPerMinute * 60;
var msPerDay = msPerHour * 24;
var msPerMonth = msPerDay * 30;
var msPerYear = msPerDay * 365;
var elapsed = current - previous;
var relativeTime = '';
if (elapsed < msPerMinute) {
relativeTime = Math.round(elapsed/1000) + ' seconds';
}
else if (elapsed < msPerHour) {
relativeTime = Math.round(elapsed/msPerMinute) + ' minutes';
}
else if (elapsed < msPerDay ) {
relativeTime = Math.round(elapsed/msPerHour ) + ' hours';
}
else if (elapsed < msPerMonth) {
relativeTime = Math.round(elapsed/msPerDay) + ' days';
}
else if (elapsed < msPerYear) {
relativeTime = Math.round(elapsed/msPerMonth) + ' months';
}
else {
relativeTime = Math.round(elapsed/msPerYear ) + ' years';
}
return "Kegged on " + new Date(previous).toDateString() + "<br />On tap for " + relativeTime
]]]
icon: mdi:water
entity: sensor.plaato_keg_water_keg_percent_beer_left
styles:
label:
- font-size: 18px
- text-align: left
name:
- font-size: 30px
custom_fields:
i1:
- border-radius: "10%"
- width: "80%"
- height: "80%"
- line-height: 0
variables:
entity_1:
color: blue
entity_id: sensor.plaato_keg_water_keg_percent_beer_left
tap_action:
action: more-info
entity_2:
color: blue
entity_id: sensor.plaato_keg_water_keg_beer_left
tap_action:
action: more-info
entity_3:
color: green
entity_id: binary_sensor.plaato_keg_water_keg_leaking
templates:
- red_on
- green_off
tap_action:
action: more-info
entity_4:
color: green
entity_id: sensor.plaato_keg_water_keg_last_pour_amount
templates:
- red_on
- green_off
tap_action:
action: more-info
custom_fields:
i1:
card:
type: "custom:button-card"
show_icon: false
show_name: true
entity: >
[[[
if (variables.entity_1.entity_id) {
return variables.entity_1.entity_id;
}
]]]
state:
- name: >
[[[
return states[variables.entity_1.entity_id].state + "% <br />remaining"
]]]
operator: default
styles:
card:
- background: >
[[[
return "linear-gradient(to top, rgba(var(--color-" + variables.entity_1.color + "),0.6) " + entity.state + "%, rgba(45, 45, 45, 0.9) " + entity.state + "%)"
]]]
name:
- font-weight: bold
- grid-area: initial
- color: white
i2:
card:
type: "custom:button-card"
show_icon: false
show_name: true
entity: >
[[[
if (variables.entity_2.entity_id) {
return variables.entity_2.entity_id;
}
]]]
state:
- name: >
[[[
return states[variables.entity_2.entity_id].state + " " + states[variables.entity_2.entity_id].attributes.unit_of_measurement + " <br />remaining"
]]]
operator: default
styles:
card:
- background: >
[[[
return "linear-gradient(to top, rgba(var(--color-" + variables.entity_2.color + "),0.6) " + entity.state + "%, rgba(45, 45, 45, 0.9) " + entity.state + "%)"
]]]
name:
- font-weight: bold
- grid-area: initial
- color: white
i3:
card:
icon: >
[[[
if (states[variables.entity_3.entity_id].state === "on") {
return "mdi:water-alert"
}
return "mdi:water-check"
]]]
i4:
card:
type: "custom:button-card"
show_icon: false
show_name: true
entity: >
[[[
if (variables.entity_4.entity_id) {
return variables.entity_4.entity_id;
}
]]]
state:
- name: >
[[[
return "Last pour:<br />" + states[variables.entity_4.entity_id].state + " " + states[variables.entity_4.entity_id].attributes.unit_of_measurement
]]]
operator: default
styles:
card:
- background: >
[[[
return "var(--color-" + variables.entity_4.color + ")"
]]]
name:
- font-weight: bold
- grid-area: initial
- color: var(--color-primary-text)
- type: 'custom:button-card'
template:
- card_room
- yellow_no_state
name: >
[[[
return entity.attributes.beer_name
]]]
label: >
[[[
var current = Date.now();
var previous = Date.parse(entity.attributes.keg_date);
var msPerMinute = 60 * 1000;
var msPerHour = msPerMinute * 60;
var msPerDay = msPerHour * 24;
var msPerMonth = msPerDay * 30;
var msPerYear = msPerDay * 365;
var elapsed = current - previous;
var relativeTime = '';
if (elapsed < msPerMinute) {
relativeTime = Math.round(elapsed/1000) + ' seconds';
}
else if (elapsed < msPerHour) {
relativeTime = Math.round(elapsed/msPerMinute) + ' minutes';
}
else if (elapsed < msPerDay ) {
relativeTime = Math.round(elapsed/msPerHour ) + ' hours';
}
else if (elapsed < msPerMonth) {
relativeTime = Math.round(elapsed/msPerDay) + ' days';
}
else if (elapsed < msPerYear) {
relativeTime = Math.round(elapsed/msPerMonth) + ' months';
}
else {
relativeTime = Math.round(elapsed/msPerYear ) + ' years';
}
return "Kegged on " + new Date(previous).toDateString() + "<br />On tap for " + relativeTime
]]]
icon: mdi:beer
entity: sensor.plaato_keg_keg_2_percent_beer_left
styles:
label:
- font-size: 18px
- text-align: left
name:
- font-size: 30px
custom_fields:
i1:
- border-radius: "10%"
- width: "80%"
- height: "80%"
- line-height: 0
variables:
entity_1:
color: yellow
entity_id: sensor.plaato_keg_keg_2_percent_beer_left
tap_action:
action: more-info
entity_2:
color: yellow
entity_id: sensor.plaato_keg_keg_2_beer_left
tap_action:
action: more-info
entity_3:
color: green
entity_id: binary_sensor.plaato_keg_keg_2_leaking
templates:
- red_on
- green_off
tap_action:
action: more-info
entity_4:
color: green
entity_id: sensor.plaato_keg_keg_2_last_pour_amount
tap_action:
action: more-info
custom_fields:
i1:
card:
type: "custom:button-card"
show_icon: false
show_name: true
entity: >
[[[
if (variables.entity_1.entity_id) {
return variables.entity_1.entity_id;
}
]]]
state:
- name: >
[[[
return states[variables.entity_1.entity_id].state + "% <br />remaining"
]]]
operator: default
styles:
card:
- background: >
[[[
return "linear-gradient(to top, rgba(var(--color-" + variables.entity_1.color + "),0.6) " + entity.state + "%, rgba(45, 45, 45, 0.9) " + entity.state + "%)"
]]]
name:
- font-weight: bold
- grid-area: initial
- color: white
i2:
card:
type: "custom:button-card"
show_icon: false
show_name: true
entity: >
[[[
if (variables.entity_2.entity_id) {
return variables.entity_2.entity_id;
}
]]]
state:
- name: >
[[[
return states[variables.entity_2.entity_id].state + " " + states[variables.entity_2.entity_id].attributes.unit_of_measurement + " <br />remaining"
]]]
operator: default
styles:
card:
- background: >
[[[
return "linear-gradient(to top, rgba(var(--color-" + variables.entity_2.color + "),0.6) " + entity.state + "%, rgba(45, 45, 45, 0.9) " + entity.state + "%)"
]]]
name:
- font-weight: bold
- grid-area: initial
- color: white
i3:
card:
icon: >
[[[
if (states[variables.entity_3.entity_id].state === "on") {
return "mdi:water-alert"
}
return "mdi:water-check"
]]]
i4:
card:
type: "custom:button-card"
show_icon: false
show_name: true
entity: >
[[[
if (variables.entity_4.entity_id) {
return variables.entity_4.entity_id;
}
]]]
state:
- name: >
[[[
return "Last pour:<br />" + states[variables.entity_4.entity_id].state + " " + states[variables.entity_4.entity_id].attributes.unit_of_measurement
]]]
operator: default
styles:
card:
- background: >
[[[
return "var(--color-" + variables.entity_4.color + ")"
]]]
name:
- font-weight: bold
- grid-area: initial
- color: var(--color-primary-text)
- type: 'custom:button-card'
template:
- card_room
- yellow_no_state
name: >
[[[
return entity.attributes.beer_name
]]]
label: >
[[[
var current = Date.now();
var previous = Date.parse(entity.attributes.keg_date);
var msPerMinute = 60 * 1000;
var msPerHour = msPerMinute * 60;
var msPerDay = msPerHour * 24;
var msPerMonth = msPerDay * 30;
var msPerYear = msPerDay * 365;
var elapsed = current - previous;
var relativeTime = '';
if (elapsed < msPerMinute) {
relativeTime = Math.round(elapsed/1000) + ' seconds';
}
else if (elapsed < msPerHour) {
relativeTime = Math.round(elapsed/msPerMinute) + ' minutes';
}
else if (elapsed < msPerDay ) {
relativeTime = Math.round(elapsed/msPerHour ) + ' hours';
}
else if (elapsed < msPerMonth) {
relativeTime = Math.round(elapsed/msPerDay) + ' days';
}
else if (elapsed < msPerYear) {
relativeTime = Math.round(elapsed/msPerMonth) + ' months';
}
else {
relativeTime = Math.round(elapsed/msPerYear ) + ' years';
}
return "Kegged on " + new Date(previous).toDateString() + "<br />On tap for " + relativeTime
]]]
icon: mdi:beer
entity: sensor.plaato_keg_keg_3_percent_beer_left
styles:
label:
- font-size: 18px
- text-align: left
name:
- font-size: 30px
custom_fields:
i1:
- border-radius: "10%"
- width: "80%"
- height: "80%"
- line-height: 0
variables:
entity_1:
color: yellow
entity_id: sensor.plaato_keg_keg_3_percent_beer_left
tap_action:
action: more-info
entity_2:
color: yellow
entity_id: sensor.plaato_keg_keg_3_beer_left
tap_action:
action: more-info
entity_3:
color: green
entity_id: binary_sensor.plaato_keg_keg_3_leaking
templates:
- red_on
- green_off
tap_action:
action: more-info
entity_4:
color: green
entity_id: sensor.plaato_keg_keg_3_last_pour_amount
tap_action:
action: more-info
custom_fields:
i1:
card:
type: "custom:button-card"
show_icon: false
show_name: true
entity: >
[[[
if (variables.entity_1.entity_id) {
return variables.entity_1.entity_id;
}
]]]
state:
- name: >
[[[
return states[variables.entity_1.entity_id].state + "% <br />remaining"
]]]
operator: default
styles:
card:
- background: >
[[[
return "linear-gradient(to top, rgba(var(--color-" + variables.entity_1.color + "),0.6) " + entity.state + "%, rgba(45, 45, 45, 0.9) " + entity.state + "%)"
]]]
name:
- font-weight: bold
- grid-area: initial
- color: white
i2:
card:
type: "custom:button-card"
show_icon: false
show_name: true
entity: >
[[[
if (variables.entity_2.entity_id) {
return variables.entity_2.entity_id;
}
]]]
state:
- name: >
[[[
return states[variables.entity_2.entity_id].state + " " + states[variables.entity_2.entity_id].attributes.unit_of_measurement + " <br />remaining"
]]]
operator: default
styles:
card:
- background: >
[[[
return "linear-gradient(to top, rgba(var(--color-" + variables.entity_2.color + "),0.6) " + entity.state + "%, rgba(45, 45, 45, 0.9) " + entity.state + "%)"
]]]
name:
- font-weight: bold
- grid-area: initial
- color: white
i3:
card:
icon: >
[[[
if (states[variables.entity_3.entity_id].state === "on") {
return "mdi:water-alert"
}
return "mdi:water-check"
]]]
i4:
card:
type: "custom:button-card"
show_icon: false
show_name: true
entity: >
[[[
if (variables.entity_4.entity_id) {
return variables.entity_4.entity_id;
}
]]]
state:
- name: >
[[[
return "Last pour:<br />" + states[variables.entity_4.entity_id].state + " " + states[variables.entity_4.entity_id].attributes.unit_of_measurement
]]]
operator: default
styles:
card:
- background: >
[[[
return "var(--color-" + variables.entity_4.color + ")"
]]]
name:
- font-weight: bold
- grid-area: initial
- color: var(--color-primary-text)