Shure thing
In button_card templates add the following.
widgets:
aspect_ratio: 1
variables:
forecast1pic: |
[[[
var state = states['weather.smhi_home'].attributes.forecast[1]['condition'];
if (state == "cloudy") return 'url("/local/w/cloudy.png")';
else if (state == "clear-night") return 'url("/local/w/moon-phase.png")';
else if (state == "fog") return 'url("/local/w/fog.png")';
else if (state == "hail") return 'url("/local/w/snow.png")';
else if (state == "lightning") return 'url("/local/w/lightning.png")';
else if (state == "lightning-rainy") return 'url("/local/w/lightning.png")';
else if (state == "partlycloudy") return 'url("/local/w/partiallycloudy1.png")';
else if (state == "pouring") return 'url("/local/w/rainy.png")';
else if (state == "rainy") return 'url("/local/w/rainy.png")';
else if (state == "snowy") return 'url("/local/w/snow.png")';
else if (state == "snowy-rainy") return 'url("/local/w/sleet.png")';
else if (state == "sunny") return 'url("/local/w/sunny.png")';
else if (state == "windy") return 'url("/local/w/windy.png")';
else if (state == "windy-variant") 'url("/local/w/windy.png")';
else if (state == "exceptional") return 'url("/local/w/sunny.png")';
]]]
forecast2pic: |
[[[
var state = states['weather.smhi_home'].attributes.forecast[2]['condition'];
if (state == "cloudy") return 'url("/local/w/cloudy.png")';
else if (state == "clear-night") return 'url("/local/w/moon-phase.png")';
else if (state == "fog") return 'url("/local/w/fog.png")';
else if (state == "hail") return 'url("/local/w/snow.png")';
else if (state == "lightning") return 'url("/local/w/lightning.png")';
else if (state == "lightning-rainy") return 'url("/local/w/lightning.png")';
else if (state == "partlycloudy") return 'url("/local/w/partiallycloudy1.png")';
else if (state == "pouring") return 'url("/local/w/rainy.png")';
else if (state == "rainy") return 'url("/local/w/rainy.png")';
else if (state == "snowy") return 'url("/local/w/snow.png")';
else if (state == "snowy-rainy") return 'url("/local/w/sleet.png")';
else if (state == "sunny") return 'url("/local/w/sunny.png")';
else if (state == "windy") return 'url("/local/w/windy.png")';
else if (state == "windy-variant") 'url("/local/w/windy.png")';
else if (state == "exceptional") return 'url("/local/w/sunny.png")';
]]]
forecast3pic: |
[[[
var state = states['weather.smhi_home'].attributes.forecast[3]['condition'];
if (state == "cloudy") return 'url("/local/w/cloudy.png")';
else if (state == "clear-night") return 'url("/local/w/moon-phase.png")';
else if (state == "fog") return 'url("/local/w/fog.png")';
else if (state == "hail") return 'url("/local/w/snow.png")';
else if (state == "lightning") return 'url("/local/w/lightning.png")';
else if (state == "lightning-rainy") return 'url("/local/w/lightning.png")';
else if (state == "partlycloudy") return 'url("/local/w/partiallycloudy1.png")';
else if (state == "pouring") return 'url("/local/w/rainy.png")';
else if (state == "rainy") return 'url("/local/w/rainy.png")';
else if (state == "snowy") return 'url("/local/w/snow.png")';
else if (state == "snowy-rainy") return 'url("/local/w/sleet.png")';
else if (state == "sunny") return 'url("/local/w/sunny.png")';
else if (state == "windy") return 'url("/local/w/windy.png")';
else if (state == "windy-variant") 'url("/local/w/windy.png")';
else if (state == "exceptional") return 'url("/local/w/sunny.png")';
]]]
forecast4pic: |
[[[
var state = states['weather.smhi_home'].attributes.forecast[4]['condition'];
if (state == "cloudy") return 'url("/local/w/cloudy.png")';
else if (state == "clear-night") return 'url("/local/w/moon-phase.png")';
else if (state == "fog") return 'url("/local/w/fog.png")';
else if (state == "hail") return 'url("/local/w/snow.png")';
else if (state == "lightning") return 'url("/local/w/lightning.png")';
else if (state == "lightning-rainy") return 'url("/local/w/lightning.png")';
else if (state == "partlycloudy") return 'url("/local/w/partiallycloudy1.png")';
else if (state == "pouring") return 'url("/local/w/rainy.png")';
else if (state == "rainy") return 'url("/local/w/rainy.png")';
else if (state == "snowy") return 'url("/local/w/snow.png")';
else if (state == "snowy-rainy") return 'url("/local/w/sleet.png")';
else if (state == "sunny") return 'url("/local/w/sunny.png")';
else if (state == "windy") return 'url("/local/w/windy.png")';
else if (state == "windy-variant") 'url("/local/w/windy.png")';
else if (state == "exceptional") return 'url("/local/w/sunny.png")';
]]]
forecast5pic: |
[[[
var state = states['weather.smhi_home'].attributes.forecast[5]['condition'];
if (state == "cloudy") return 'url("/local/w/cloudy.png")';
else if (state == "clear-night") return 'url("/local/w/moon-phase.png")';
else if (state == "fog") return 'url("/local/w/fog.png")';
else if (state == "hail") return 'url("/local/w/snow.png")';
else if (state == "lightning") return 'url("/local/w/lightning.png")';
else if (state == "lightning-rainy") return 'url("/local/w/lightning.png")';
else if (state == "partlycloudy") return 'url("/local/w/partiallycloudy1.png")';
else if (state == "pouring") return 'url("/local/w/rainy.png")';
else if (state == "rainy") return 'url("/local/w/rainy.png")';
else if (state == "snowy") return 'url("/local/w/snow.png")';
else if (state == "snowy-rainy") return 'url("/local/w/sleet.png")';
else if (state == "sunny") return 'url("/local/w/sunny.png")';
else if (state == "windy") return 'url("/local/w/windy.png")';
else if (state == "windy-variant") 'url("/local/w/windy.png")';
else if (state == "exceptional") return 'url("/local/w/sunny.png")';
]]]
ypos: |
[[[
if (states["sensor.time"].state.split(":")[0] == "06"){
return "49";}
else if (states["sensor.time"].state.split(":")[0] == "07"){
return "47.9";}
else if (states["sensor.time"].state.split(":")[0] == "08"){
return "46.8";}
else if (states["sensor.time"].state.split(":")[0] == "09"){
return "45.8";}
else if (states["sensor.time"].state.split(":")[0] == "10"){
return "45.4";}
else if (states["sensor.time"].state.split(":")[0] == "11"){
return "45.1";}
else if (states["sensor.time"].state.split(":")[0] == "12"){
return "45";}
else if (states["sensor.time"].state.split(":")[0] == "13"){
return "45.1";}
else if (states["sensor.time"].state.split(":")[0] == "14"){
return "45.4";}
else if (states["sensor.time"].state.split(":")[0] == "15"){
return "45.8";}
else if (states["sensor.time"].state.split(":")[0] == "16"){
return "46.8";}
else if (states["sensor.time"].state.split(":")[0] == "17"){
return "47.9";}
else if (states["sensor.time"].state.split(":")[0] == "18"){
return "49";}
else if (states["sensor.time"].state.split(":")[0] == "19"){
return "50.6";}
else if (states["sensor.time"].state.split(":")[0] == "21"){
return "54.8";}
else if (states["sensor.time"].state.split(":")[0] == "22") {
return "56.9";}
else if (states["sensor.time"].state.split(":")[0] == "23") {
return "59.4";}
else if (states["sensor.time"].state.split(":")[0] == "24") {
return "60.6";}
]]]
xpos: |
[[[
return states["sensor.time"].state.split(":")[0] * 4.16;
]]]
line: |
[[[
if (states['sun.sun'].attributes.next_rising.substr(11,2) == "06"){
return "49";}
]]]
show_icon: false
show_state: true
show_name: true
tap_action:
animation_card: |
[[[
const animation_speed_ms = 900;
const animation = `card_bounce ${animation_speed_ms}ms cubic-bezier(0.22, 1, 0.36, 1)`;
this.shadowRoot.getElementById("card").style.animation = animation;
window.setTimeout(() => {
this.shadowRoot.getElementById("card").style.animation = "none";
}, animation_speed_ms)
]]]
styles:
card:
- background-color: rgba(0,0,0,0.4)
- font-color: rgb(255,255,255,0.9)
- text-shadow: 0px 0px 1px black
- letter-spacing: 0.05vw
name:
- color: rgb(255,255,255,0.6)
extra_styles: |
@keyframes card_bounce {
0% {
transform: scale(1);
}
15% {
transform: scale(0.9);
}
25% {
transform: scale(1);
}
30% {
transform: scale(0.98);
}
100% {
transform: scale(1);
}
}
Calendar/event widget:
type: custom:button-card
view_layout:
grid-area: three
entity: sensor.dayoftheweek
template:
- widgets
tap_action:
action: fire-dom-event
browser_mod:
command: popup
title: Kalender
hide_header: false
card:
type: vertical-stack
cards:
- type: calendar
entities:
- calendar.ical_daniel_kalender
initial_view: dayGridMonth
style: |
ha-card {
box-shadow: none;
}
show_state: false
name: Händelser
styles:
name:
- position: absolute
- top: 20px
- left: 20px
- color: red
- font-weight: bold
- text-transform: uppercase
custom_fields:
planned:
- position: absolute
- top: 15px
- left: 4px
event1title:
- position: absolute
- top: 85px
- left: 20px
- color: rgb(255,255,255,0.6
- font-weight: bold
- text-transform: uppercase
event1:
- position: absolute
- top: 107px
- left: 20px
event1time:
- position: absolute
- color: rgb(255,255,255,0.6)
- top: 132px
- left: 20px
- font-size: 14px
event2title:
- position: absolute
- top: 166px
- left: 20px
- color: rgb(255,255,255,0.6)
- font-weight: bold
- text-transform: uppercase
event2:
- position: absolute
- color: rgb(255,255,255,0.9)
- top: 188px
- left: 20px
event2time:
- position: absolute
- top: 212px
- left: 20px
- color: rgb(255,255,255,0.6)
- font-size: 14px
custom_fields:
planned:
card:
type: markdown
style: |
ha-card {
--ha-card-background: transparent;
color: rgb(255,255,255,0.6);}
}
content: >
<font size="3"> {% set midnight = now().replace(hour=0, minute=0,
second=0, microsecond=0).timestamp() %}
{% set event = state_attr('calendar.ical_daniel_kalender', 'start_time')
| as_timestamp %}
{% set delta = ((event - midnight) // 86400) | int %}
{% if delta == 0 %}
Du har en händelse idag!
{% else %}
Inget planerat idag.
{% endif %}
event1title: |
[[[
var gsDayNames = [
'Söndag',
'Måndag',
'Tisdag',
'Ondag',
'Torsdag',
'Fredag',
'Lördag'
];
var date = states['sensor.ical_daniel_kalender_event_0'].attributes.start;
var d = new Date(date);
var dayName = gsDayNames[d.getDay()];
return dayName
]]]
event1: >
[[[ return states['sensor.ical_daniel_kalender_event_0'].attributes.summary;
]]]
event1time: |
[[[
return "Kl: " + (states['sensor.ical_daniel_kalender_event_0'].attributes.start).substr(11,5);
]]]
event2title: |
[[[
var gsDayNames = [
'Söndag',
'Måndag',
'Tisdag',
'Ondag',
'Torsdag',
'Fredag',
'Lördag'
];
var date = states['sensor.ical_daniel_kalender_event_1'].attributes.start;
var d = new Date(date);
var dayName = gsDayNames[d.getDay()];
return dayName
]]]
event2: >
[[[ return states['sensor.ical_daniel_kalender_event_1'].attributes.summary;
]]]
event2time: |
[[[
return "Kl: " + (states['sensor.ical_daniel_kalender_event_1'].attributes.start).substr(11,5);
]]]
Sun widget (if someone could help me to calculate a more realistic curve that would be awesome, now it just looks cool
type: custom:button-card
view_layout:
grid-area: four
template:
- widgets
tap_action:
action: none
styles:
custom_fields:
suntop:
- position: absolute
- top: 2%
- left: 2%
- font-size: 14px
sunbottom:
- position: absolute
- bottom: 2%
- left: 2%
- font-size: 14px
sun:
- position: absolute
- width: 100%
- height: 100%
- top: 0%
custom_fields:
suntop: |
[[[
if (states['sun.sun'].state == 'below_horizon'){
return `<div align="left"> <ha-icon icon="ios:sunrise" style="width: 25px; height: px; color:rgb(255,255,255,0.5); padding: 10px;"> </ha-icon><b>SOL</b></font><br> <p style="margin-left:10px; margin-top:-5px; font-size:36px">${states['sun.sun'].attributes.next_rising.substr(11,5)}</font></div>`;
}
else {
return `<div align="left"> <ha-icon
icon="ios:sunset"
style="width: 25px; height: px; color:rgb(255,255,255,0.5); padding: 10px;">
</ha-icon><b>SOL</b></font><br>
<p style="margin-left:10px; margin-top:-5px; font-size:36px">${states['sun.sun'].attributes.next_setting.substr(11,5)}</div>`; }
]]]
sunbottom: |
[[[
if (states['sun.sun'].state == 'below_horizon'){
return `<div align="left"> <ha-icon icon="ios:sunset" style="width: 25px; height: px; color:rgb(255,255,255,0.5); padding: 10px;"> </ha-icon></font> ${states['sun.sun'].attributes.next_setting.substr(11,5)}</div>`;
}
else {
return `<div align="left"> <ha-icon
icon="ios:sunrise"
style="width: 25px; height: px; color:rgb(255,255,255,0.5); padding: 10px;">
</ha-icon></font> ${states['sun.sun'].attributes.next_rising.substr(11,5)}</div>`; }
]]]
sun: |
[[[
return `
<svg width="100%" height="100%">
<defs>
<filter id="f2" x="-50%" y="-50%" width="200%" height="200%">
<feOffset result="offOut" in="SourceGraphic" dx="0" dy="0" />
<feGaussianBlur result="blurOut" in="offOut" stdDeviation="4" />
<feBlend in="SourceGraphic" in2="blurOut" mode="normal" />
</filter>
<linearGradient id="grad1" x1="0%" y1="0%" x2="100%" y2="0%">
<stop offset="0%" style="stop-color:rgb(0,0,0);stop-opacity:0" />
<stop offset="50%" style="stop-color:rgb(255,255,255);stop-opacity:1" />
<stop offset="100%" style="stop-color:rgb(0,0,0);stop-opacity:0" />
</linearGradient>
</defs>
<circle cx="50%" cy="125%" r="80%" stroke="url(#grad1)" stroke-width="1.2%" fill="none" />
<line x1="100%" y1="${variables.line}%" x2="0" y2="${variables.line}%" style="stroke:rgb(255,255,255,0.0);stroke-width:0.5%" />
<circle cx="${variables.xpos}%" cy="${variables.ypos}%" rx="5" r="10" fill="rgb(255,255,255,1" filter="url(#f2)"/>
`;
]]]