用了Floorplan的插件,要花点时间配置调试一下,SVG和CSS放附件里了
type: custom:floorplan-card
full_height: true
config:
image: /local/TV_remote/TV_remote.svg
stylesheet: /local/TV_remote/TV_remote.css
console_log_level: info
defaults:
hover_action: hover-info
hover_info_filter:
- min_mireds
- max_mireds
- icon
- order
- color_mode
tap_action: more-info
functions: |
>
return {
remote_command: (element) => {
var element_id = element.id
var command = element_id.substr(element_id.lastIndexOf('.')+1);
console.log(command);
return command;
},
};
rules:
- entity: media_player.sony_bravia_tv
element: TV_power_light
state_action:
action: call-service
service: floorplan.style_set
service_data:
element: TV_power_light
style: >-
${(entity.state === "playing"||entity.state === "paused") ?
"fill:green;opacity:1;":"fill:red;opacity:1;"}
tap_action: false
hover_action: false
- elements:
- tv_remote.button.Num0
- tv_remote.button.Num1
- tv_remote.button.Num2
- tv_remote.button.Num3
- tv_remote.button.Num4
- tv_remote.button.Num5
- tv_remote.button.Num6
- tv_remote.button.Num7
- tv_remote.button.Num8
- tv_remote.button.Num9
- tv_remote.button.TvPower
- tv_remote.button.VolumeUp
- tv_remote.button.VolumeDown
- tv_remote.button.ChannelUp
- tv_remote.button.ChannelDown
- tv_remote.button.Up
- tv_remote.button.Down
- tv_remote.button.Left
- tv_remote.button.Right
- tv_remote.button.Pause
- tv_remote.button.Rewind
- tv_remote.button.Prev
- tv_remote.button.Next
- tv_remote.button.Forward
- tv_remote.button.Mute
- tv_remote.button.Confirm
- tv_remote.button.AndroidMenu
- tv_remote.button.Return
- tv_remote.button.Home
- tv_remote.button.Options
entity: remote.sony_bravia_tv
tap_action:
action: call-service
service: remote.send_command
service_data:
command: ${functions.remote_command(element)}
hover_action: false
|