先看效果
步骤:
- 新建卡片时选择“Markdown 卡片”
- 代码在文章最下方,当然你也可以自己修改
- 点击保存/完成
### {% if now().hour >= 6 and now().hour < 9 -%}
早上好,
{%- elif now().hour >= 9 and now().hour < 12 -%}
上午好,
{%- elif now().hour >= 12 and now().hour < 13 -%}
中午好,
{%- elif now().hour >= 13 and now().hour < 18 -%}
下午好,
{%- elif now().hour >= 18 and now().hour < 23 -%}
晚上好,
{%- else -%}
夜深了,请注意休息哦!
{%- endif %} {{user}},今天是{{now().strftime('%Y-%m-%d')}}
{% set stop_time = as_timestamp(state_attr("calendar.zhong_guo", "start_time")) - as_timestamp(now()) %}
{% set days = (stop_time // (60 * 60 * 24)) %}
{% set hours = (stop_time// (60 * 60)) - days * 24 %}
{% set minutes = (stop_time // 60) - (days * 24 * 60) %}
{% set days = ((stop_time // (60 * 60 * 24))) %}
{% set minutes = (minutes) - (hours * 60) %}
{% macro phrase(value, name) %}
{%- set value = value | int %}
{{-'{}{}'.format(value,name) if value | int > 0 else''}}
{%- endmacro %}
{% set text = [ phrase(days,'天'), phrase(hours,'小时'), phrase(minutes,'分钟') ] | select('!=','') | list | join('') %}
### 距离{{state_attr("calendar.zhong_guo", "message")}}还有:{{text}}