homeassistant — 三种卡片在lovelace中显示实体的某个属性值

以小米zigbee版智能插座(型号:lumi.plug.v1)为例

插座已接入多功能网关(网关型号lumi.gateway.v3)

使用homeassistant官方的Xiaomi Gateway (Aqara)组件集成

(使用Xiaomi Miio集成的话,zigbee有开关和功率两个实体,之前的版本如果使用了Xiaomi Gateway (Aqara)集成,再用Xiaomi Miio会报错,这就是我为什么不直接使用Miio集成的原因。目前的版本已经OK了,使用两个集成不冲突)

 集成后发现插座设备下只有一个开关实体,此实体属性中有显示功率值:

在实体属性列表中看到,功率的名称为:load_power

方式一:使用lovelace自带实体卡片

自带的实体卡片,可以显示包含实体某个属性值在内的丰富的实体信息

添加一个实体卡片:

 选择一个已接入的智能插座实体,属性栏可以选择功率等属性,还可以自定义属性值的单位:

 配合网格卡片-实体卡片套娃模式效果更加:

type: grid
columns: 3
cards:
  - type: entity
    entity: switch.plug_158d000
    name: 电脑
    unit: 瓦
    attribute: load_power
    state_color: true
  - type: entity
    entity: switch.plug_158d000
    name: 吸尘器
    unit: 瓦
    attribute: load_power
    state_color: true
  - type: entity
    entity: switch.plug_158d000
    name: 主卧路由器
    unit: 瓦
    attribute: load_power
    state_color: true
  - type: entity
    entity: switch.plug_158d000
    name: 沙发插座
    unit: 瓦
    attribute: load_power
    state_color: true
  - type: entity
    entity: switch.plug_158d000
    name: 床头柜插座
    unit: 瓦
    attribute: load_power
    state_color: true
  - type: entity
    entity: switch.plug_158d000
    name: 电视
    unit: 瓦
    attribute: load_power
    state_color: true
square: false

效果:

方式二:使用HACS卡片Multiline Entity Card

此卡片可以调用属性值,卡片名称:Multiline Entity Card

相比lovelace自带实体卡片,此卡片相当于实体卡片简配版

项目地址:https://github.com/jampez77/Multiline-Entity-Cardhttps://github.com/jampez77/Multiline-Entity-Card

使用HACS可以直接搜索出Multiline Entity Card安装,但发现我的环境无法自动安装

于是手动在github打包下载拷贝到新建的config\www\community\Multiline-Entity-Card文件夹中

重载hass后

按项目中实例在lovelace中添加自定义卡片

type: 'custom:multiline-entity-card'
name: "电脑功率"
entity: switch.plug_158d000
attribute: load_power
show_icon: true
show_name: true

单Multiline Entity Card效果:

家里有6个zigbee插座,想显示在一起

于是配合网格卡片使用,效果更加:

type: grid
columns: 3
cards:
  - type: custom:multiline-entity-card
    entity: switch.plug_158d000
    name: 电脑
    attribute: load_power
    show_icon: true
    show_name: true
  - type: custom:multiline-entity-card
    entity: switch.plug_158d0001
    name: 吸尘器
    attribute: load_power
    show_icon: true
    show_name: true
  - type: custom:multiline-entity-card
    entity: switch.plug_158d000
    name: 主卧路由器
    attribute: load_power
    show_icon: true
    show_name: true
  - type: custom:multiline-entity-card
    entity: switch.plug_158d000
    name: 沙发
    attribute: load_power
    show_icon: true
    show_name: true
  - type: custom:multiline-entity-card
    entity: switch.plug_158d000
    name: 床头柜
    attribute: load_power
    show_icon: true
    show_name: true
  - type: custom:multiline-entity-card
    entity: switch.plug_158d0003
    name: 电视
    attribute: load_power
    show_icon: true
    show_name: true
square: false

效果:

插座开关关闭状态的话,会显示未知,如果是打开状态就会显示实时功率。

方式三:multiple-entity-row卡片:

项目地址:

GitHub - benct/lovelace-multiple-entity-row: Show multiple entity states and attributes on entity rows in Home Assistant's Lovelace UIShow multiple entity states and attributes on entity rows in Home Assistant's Lovelace UI - GitHub - benct/lovelace-multiple-entity-row: Show multiple entity states and attributes on entity rows in Home Assistant's Lovelace UIhttps://github.com/benct/lovelace-multiple-entity-row这个卡片显然高级一点

该项目中给的例子:

我的需求就是开关和功率两个,换成自己的实体,

 这样,原本开关和功率两个实体列表就可以变成一个列表了,省了一些地方。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值