本帖最后由 ciasdmxhxjjpd@c 于 2022-4-4 14:59 编辑
优化了下输出显示
在 开发者工具里调试
{% set value_json =
{
"gongli": 20220404,
"week": "星期一",
"nongli": "壬寅年三月初四(2022)",
"xingzuo": "白羊座",
"nianci": "壬寅年癸卯月丁亥日",
"do": "开市|立券|交易|挂匾|祭祀|祈福|开光|入宅|移徙|安床|拆卸|动土|上梁|进人口",
"nodo": "嫁娶|行丧|架马|作梁|理发|牧养|安葬|纳畜|伐木",
"shengxiao": "虎",
"jieqi": "春分后",
"runnian": "否",
"festivals_nl": "",
"festivals_gl": "",
"to_today": "今天"
}
%}
- platform: mqtt
name: "Chinese Calendar"
state_topic: "/node-red/huangli/"
value_template: '{{ value_json.nongli[:3] }} {{ value_json.nongli[3:7] }}'
- platform: mqtt
name: "Solar Calendar"
state_topic: "/node-red/huangli/"
value_template: '{{ as_timestamp(value_json.gongli) | timestamp_custom("%Y-%m-%d") }} {{ value_json.week }}'
|