本帖最后由 angelyangw 于 2019-4-18 10:09 编辑
更新:2019-4-18
1. 使用useful-markdown-card,链接:https://github.com/thomasloven/lovelace-useful-markdown-card
2. 不用再额外新建sensor,只使用https://bbs.hassbian.com/thread-5028-1-1.html中的sensor即可
3. 更改lovelace设置
更新后效果如下图:
更新后的lovelace设置为:
type: 'custom:useful-markdown-card'
content: |
### [[ sensor.artifacts.attributes.friendly_name ]]
### [[ sensor.artifacts.state ]]
[[ sensor.artifacts.attributes.description ]]
![aaa]([[ sensor.artifacts.attributes.cover_image ]])
title: 每日故宫
之前写过一个每日推荐文物的sensor,具体可以参考链接https://bbs.hassbian.com/thread-5028-1-1.html,结合lovelace的picture-element弄出来一个新的样式,见图
需要添加几个sensor,编辑sensor.yaml
- platform: template
sensors:
artifacts_name:
friendly_name: "Artifacts Name"
value_template: "藏品名称: {{ states.sensor.artifacts.attributes.friendly_name }}"
- platform: template
sensors:
artifacts_age:
friendly_name: "Artifacts Age"
value_template: "藏品年代: {{ states.sensor.artifacts.state }}"
- platform: template
sensors:
artifacts_description:
friendly_name: "artifacts description"
value_template: >-
{%- if states.sensor.artifacts.attributes.description == '' -%}
藏品介绍:暂无
{%- else -%}
藏品介绍:{{ states.sensor.artifacts.attributes.description }}
{%- endif -%}
然后编辑ui-lovelace.yaml
elements:
- entity: sensor.artifacts
image: /local/artifacts/today_cover_img.jpg
style:
height: 100%
left: 0%
top: 0%
transform: none
width: 100%
z-index: 0
type: image
- entity: sensor.artifacts_name
style:
background-color: 'rgba(245, 245, 245, 0.4)'
border-color: IndianRed4
border-left-style: solid
color: 'rgb(115, 122, 130)'
font-family: Trebuchet MS
font-size: 100%
font-weight: bold
left: 0%
pointer-events: none
text-shadow: 1px 0px black
top: 0%
transform: none
z-index: 1
type: state-label
- entity: sensor.artifacts_age
style:
background-color: 'rgba(245, 245, 245, 0.4)'
border-color: Beige
border-left-style: solid
color: 'rgb(115, 122, 130)'
font-family: Trebuchet MS
font-size: 100%
font-weight: bold
left: 0%
pointer-events: none
text-shadow: 1px 0px black
top: 5%
transform: none
z-index: 2
type: state-label
- entity: sensor.artifacts_description
style:
background-color: 'rgba(245, 245, 245, 0.4)'
border-color: goldenrod
border-left-style: solid
color: 'rgb(115, 122, 130)'
font-family: Trebuchet MS
font-size: 100%
font-weight: bold
left: 0%
pointer-events: none
text-shadow: 1px 0px black
top: 10%
transform: none
z-index: 2
type: state-label
image: /local/artifacts/today_cover_img.jpg
type: picture-elements
|