- 积分
- 186
- 金钱
- 160
- 威望
- 0
- 贡献
- 0
- HASS币
- 0
注册会员
- 积分
- 186
- 金钱
- 160
- HASS币
- 0
|
发表于 2024-9-22 18:34:38
|
显示全部楼层
本帖最后由 老皇历 于 2024-9-22 20:39 编辑
求救:我的时间节气为啥有个白背景,怎么也搞不了,请大佬看看问题在哪?
这一段的代码是完全搬的,只不过没有自己的节日,就删了后面的代码:
- type: image
info1: '************************************************************'
info2: '********************** 时间/日期 ***********************'
info3: '* jieqi_tiaozheng: 1 是节气调整值,不准的时候修改此项 *'
info4: '* 除时间外其余日期都是本地计算(时间是秒级刷新这里做不到) *'
- type: custom:button-card
style:
left: 150px
top: 95px
variables:
jieqi_tiaozheng: 1
styles:
grid:
- grid-template-areas: |
"time time time time"
"date week jieqi jieqi"
"year mon mon day"
"line line line line"
"shengri shengri shengri shengri"
"jieri jieri jieri jieri"
- grid-template-columns: 80px 58px 16px 72px
- grid-template-rows: 70px 22px 22px 10px 22px 22px
- text-align: left
- font-weight: bold
- font-size: 16px
card:
- width: 250px
- height: 188px
custom_fields:
time:
- font-size: 57px
- font-weight: 430px
- text-align: center
jieqi:
- text-align: right
day:
- text-align: right
custom_fields:
time: '[[[return states[''sensor.time''].state]]]'
date: |
[[[
let date = new Date(), month = date.getMonth()+1, day = date.getDate();
if (month < 10) month = `0${month}` ;
if (day < 10) day = `0${day}` ;
return `${month}月${day}日`;
]]]
week: |
[[[
var day = new Date().getDay();
var week = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六")[day]
return week;
]]]
jieqi: |
[[[
var now =new Date();
var year=now.getYear(), mon=now.getMonth(), day=now.getDate()+variables.jieqi_tiaozheng;
var solarTerm = new Array("小寒", "大寒", "立春", "雨水", "惊蛰", "春分", "清明", "谷雨","立夏", "小满", "芒种", "夏至", "小暑", "大暑", "立秋", "处暑","白露", "秋分", "寒露", "霜降", "立冬", "小雪", "大雪", "冬至");
var sTermInfo = new Array(0, 21208, 42467, 63836, 85337, 107014, 128867, 150921, 173149, 195551, 218072, 240693,263343, 285989, 308563, 331033, 353350, 375494, 397447, 419210, 440795, 462224, 483532, 504758);
var solarTerms = "",num1=1, num2=1;
while (solarTerms==""){ num1 = num1+1;
var temp1 = new Date((31556925974.7*(year-1900)+sTermInfo[mon*2+1] * 60000)+Date.UTC(1900,0,6,2,5));
var temp2 = temp1.getUTCDate();
if (temp2 == day) solarTerms = solarTerm[mon*2+1];
temp1 = new Date((31556925974.7*(year-1900)+sTermInfo[mon*2]*60000)+Date.UTC(1900,0,6,2,5));
temp2 = temp1.getUTCDate();
if(temp2==day) solarTerms = solarTerm[mon*2];
if(day>1){day=day-1;} else { mon=mon-1;if(mon<0){year=year-1; mon=11;}day=31; }}
return solarTerms+" 第"+(num1-1)+"天";
]]]
year: |
[[[ return states['sensor.holiday'].attributes.农历.slice(0,4)]]]
mon: |
[[[ return states['sensor.holiday'].attributes.农历.slice(5,9)]]]
day: |
[[[
let tzArr = ['子','丑','寅','卵','辰','巳','午','未','申','酉','戌','亥'];
let skArr = ['一','二','三','四','五','六','七','八'];
var h = new Date().getHours();
var m = new Date().getMinutes();
if (h%2 ==0) var shike = skArr[parseInt(m/15)] ;
if (h%2 ==1) var shike = skArr[parseInt(m/15)+4];
return tzArr[parseInt(h/2)] + '时' + shike +'刻';
]]]
line:
card:
type: custom:button-card
styles:
card:
- width: 228px
- border-top: 1px solid white
- margin-top: 18px
shengri: |
[[[
var jieri1 = states['sensor.holiday'].attributes.纪念日 ;
var jieri2 = states['sensor.holiday'].attributes.最近的纪念日 ;
var jieri3 = states['sensor.holiday'].attributes.最近的纪念日还有 ;
if (jieri1 != undefined ) return`${jieri1}`;
if (jieri1 == undefined ) return`${jieri2} ${jieri3}`;
]]]
jieri: |
[[[
var jieri1 = states['sensor.holiday'].attributes.节日 ;
var jieri2 = states['sensor.holiday'].attributes.最近的节日 ;
var jieri3 = states['sensor.holiday'].attributes.最近的节日还有 ;
if (jieri1 != undefined ) return`${jieri1}`;
if (jieri1 == undefined ) return`${jieri2} ${jieri3}`;
]]]
l另外,还缺customize.yaml文件没有上传!
|
|