参考贴:
https://bbs.hassbian.com/thread-6019-1-1.html
https://bbs.hassbian.com/thread-7331-1-1.html
https://bbs.hassbian.com/thread-5391-1-1.html
https://bbs.hassbian.com/thread-7218-1-1.html
效果:
起因:
想把家里所有红外遥控收起来,统一用HA
但在HA里一直没找到什么好办法模拟真实遥控的键位
参考土豆哥的贴,我以前就是这么处理的
然后红外部分无反馈(空调、电视),天猫魔盒倒是可以ping反馈开机,这样用HA的时候怕误触开机
另外好几个遥控在一起很占HA的界面(当你接入的东西多了就会发现是要取舍的,虽然刚开始我也是拼命往里集成,目前ui-lovelace.yaml已经1200+行了)
前置:
控客pro自学码
会使用插件(均给出了项目地址,自行学习)
理解基本语法、缩进
用到的插件:
resources:
# [url]https://github.com/thomasloven/lovelace-toggle-lock-entity-row[/url]
- url: /local/custom-lovelace/toggle-lock-entity-row.js?track=true
type: js
# [url]https://github.com/thomasloven/lovelace-card-tools[/url]
- url: /local/custom-lovelace/card-tools.js?track=true
type: js
# [url]https://github.com/thomasloven/lovelace-state-switch[/url]
- url: /local/custom-lovelace/state-switch.js?track=true
type: js
# [url]https://github.com/thomasloven/lovelace-card-modder[/url]
- url: /local/custom-lovelace/card-modder.js?track=true
type: js
# [url]https://github.com/custom-cards/vertical-stack-in-card[/url]
- url: /local/custom-lovelace/vertical-stack-in-card.js?track=true
type: js
# [url]https://github.com/custom-cards/button-card[/url]
- url: /local/custom-lovelace/button-card.js?track=true
type: module
---------------以下供参考---------------
- type: 'custom:card-modder' #card-modder插件 实现半透明蒙版
style:
--paper-card-background-color: rgba(67, 73, 84, 0.5) #卡片背景颜色
--paper-item-icon-color: white #图标颜色
--primary-text-color: white #实体文字颜色
-webkit-backdrop-filter: blur(5px) #给上一层增加模糊滤镜
backdrop-filter: blur(5px) #给上一层增加模糊滤镜
color: white #标题文字颜色
border-radius: 15px #圆角
card:
type: custom:vertical-stack-in-card #vertical-stack-in-card插件 以下所有卡片嵌套在一起
title: "遥控器"
cards:
- type: entities
entities:
- input_select.remote_livingroom #自己在其他位置建立这个input_select
- type: custom:state-switch #state-switch插件 根据input_select选择进行显示
entity: input_select.remote_livingroom #state-switch 参数
states:
空调:
type: entities #支持中文,但缩进不支持 - (这个人的插件多数缩进不支持 - sensor.xxxx这种写法)
show_header_toggle: false
entities:
- entity: input_boolean.remote_livingroom_ac_lock
name: 空调控制锁
type: custom:toggle-lock-entity-row #toggle-lock-entity-row 给开关上锁
- entity: input_number.remote_temp_livingroom
- entity: input_select.remote_mode_livingroom
- entity: input_select.remote_fanspeed_livingroom
- entity: script.remote_konke_turnoff_ac
电视:
type: vertical-stack #vertical-stack 垂直分布
cards:
######################第1行##########################
- type: horizontal-stack #horizontal-stack 水平分布
cards:
- type: "custom:button-card" #button-card插件
color_type: blank-card #空白卡
- type: "custom:button-card"
color_type: blank-card
- type: "custom:button-card"
color_type: blank-card
- type: "custom:button-card"
color_type: card
color: rgb(255, 20, 20)
icon: mdi:power
lock: true #给开关额外加一个锁
size: 150%
styles:
card:
- height: 40px #卡高度
tap_action: #点击后要执行的操作
action: call-service
service: script.remote_konke_tv_on_off
######################第2行##########################
- type: horizontal-stack
cards:
- type: "custom:button-card"
color_type: card
color: rgb(105, 163, 201)
icon: mdi:volume-plus
size: 100%
styles:
card:
- height: 40px
tap_action:
action: call-service
service: script.remote_konke_tv_vol_add
- type: "custom:button-card"
color_type: blank-card
- type: "custom:button-card"
color_type: blank-card
- type: "custom:button-card"
color_type: blank-card
######################第3行##########################
- type: horizontal-stack
cards:
- type: "custom:button-card"
color_type: blank-card
- type: "custom:button-card"
color_type: card
color: rgb(105, 163, 201)
icon: mdi:volume-off
styles:
card:
- height: 40px
tap_action:
action: call-service
service: script.remote_konke_tv_vol_mute
- type: "custom:button-card"
color_type: blank-card
- type: "custom:button-card"
color_type: card
color: rgb(105, 163, 201)
icon: mdi:format-list-checks
styles:
card:
- height: 40px
tap_action:
action: call-service
service: script.remote_konke_tv_signal
######################第4行##########################
- type: horizontal-stack
cards:
- type: "custom:button-card"
color_type: card
color: rgb(105, 163, 201)
icon: mdi:volume-minus
styles:
card:
- height: 40px
tap_action:
action: call-service
service: script.remote_konke_tv_vol_sub
- type: "custom:button-card"
color_type: blank-card
- type: "custom:button-card"
color_type: blank-card
- type: "custom:button-card"
color_type: blank-card
天猫魔盒:
type: vertical-stack
cards:
######################第1行##########################
- type: horizontal-stack
cards:
- type: "custom:button-card"
color_type: blank-card
- type: "custom:button-card"
color_type: blank-card
- type: "custom:button-card"
color_type: blank-card
- type: "custom:button-card"
color_type: blank-card
- type: "custom:button-card"
color_type: card
color: rgb(255, 20, 20)
icon: mdi:power
lock: true
styles:
card:
- height: 40px
tap_action:
action: call-service
service: script.remote_konke_tmallbox_on_off
######################第2行##########################
- type: horizontal-stack
cards:
- type: "custom:button-card"
color_type: card
color: rgb(105, 163, 201)
icon: mdi:volume-plus
styles:
card:
- height: 40px
tap_action:
action: call-service
service: script.remote_konke_tmallbox_vol_add
- type: "custom:button-card"
color_type: blank-card
- type: "custom:button-card"
color_type: blank-card
- type: "custom:button-card"
color_type: card
color: rgb(105, 163, 201)
icon: mdi:arrow-up-box
styles:
card:
- height: 40px
tap_action:
action: call-service
service: script.remote_konke_tmallbox_up
- type: "custom:button-card"
color_type: blank-card
######################第3行##########################
- type: horizontal-stack
cards:
- type: "custom:button-card"
color_type: blank-card
- type: "custom:button-card"
color_type: blank-card
- type: "custom:button-card"
color_type: card
color: rgb(105, 163, 201)
icon: mdi:arrow-left-box
styles:
card:
- height: 40px
tap_action:
action: call-service
service: script.remote_konke_tmallbox_left
- type: "custom:button-card"
color_type: card
color: rgb(105, 163, 201)
icon: mdi:circle-slice-8
styles:
card:
- height: 40px
tap_action:
action: call-service
service: script.remote_konke_tmallbox_ok
- type: "custom:button-card"
color_type: card
color: rgb(105, 163, 201)
icon: mdi:arrow-right-box
styles:
card:
- height: 40px
tap_action:
action: call-service
service: script.remote_konke_tmallbox_right
######################第4行##########################
- type: horizontal-stack
cards:
- type: "custom:button-card"
color_type: card
color: rgb(105, 163, 201)
icon: mdi:volume-minus
styles:
card:
- height: 40px
tap_action:
action: call-service
service: script.remote_konke_tmallbox_vol_sub
- type: "custom:button-card"
color_type: blank-card
- type: "custom:button-card"
color_type: blank-card
- type: "custom:button-card"
color_type: card
color: rgb(105, 163, 201)
icon: mdi:arrow-down-box
styles:
card:
- height: 40px
tap_action:
action: call-service
service: script.remote_konke_tmallbox_down
- type: "custom:button-card"
color_type: blank-card
######################第5行##########################
- type: horizontal-stack
cards:
- type: "custom:button-card"
color_type: card
color: rgb(105, 163, 201)
icon: mdi:keyboard-return
styles:
card:
- height: 40px
tap_action:
action: call-service
service: script.remote_konke_tmallbox_back
- type: "custom:button-card"
color_type: card
color: rgb(105, 163, 201)
icon: mdi:home
styles:
card:
- height: 40px
tap_action:
action: call-service
service: script.remote_konke_tmallbox_home
- type: "custom:button-card"
color_type: card
color: rgb(105, 163, 201)
styles:
card:
- height: 40px
icon: mdi:menu
tap_action:
action: call-service
service: script.remote_konke_tmallbox_menu
|