利用搬瓦工官方API,每15秒获取一次服务器信息,展示到HASS前端,基本上就是探针的作用了。
实现效果(两种)如图:
第一张效果图前端卡片代码如下,其中的数值根据自己服务器实际情况更改即可,需要用到的前端集成有:https://github.com/benct/lovelac ... -row#entity-objects https://github.com/custom-cards/bar-card 。使用前请自行安装。
type: entities
show_header_toggle: false
title: Bandwagon 服务器
icon: mdi:server
entities:
- type: custom:multiple-entity-row
entity: sensor.bwh
attribute: vps_status
icon: mdi:restart
name: 状况
show_state: false
entities:
- attribute: vps_status
name: Status
- attribute: vps_suspended_status
name: Suspended
styles:
width: 100px
text-align: center
- type: custom:multiple-entity-row
entity: sensor.bwh
attribute: load_average
icon: mdi:run
name: 负载
- type: custom:bar-card
entities:
- entity: sensor.bwh
attribute: ram_used
name: 内存
max: 512
entity_row: true
height: 25px
color: green
unit_of_measurement: MB
positions:
icon: 'off'
indicator: inside
style: |-
bar-card-background {
margin-left: 200px;
}
bar-card-value {
margin-right: auto;
font-size: 13px;
font-weight: bold;
text-shadow: 1px 1px #0005;
}
severity:
- color: Red
from: 460.8
to: 512
- color: Orange
from: 307.2
to: 460.8
- color: Green
from: 0
to: 307.2
- type: custom:bar-card
entities:
- entity: sensor.bwh
attribute: swap_used
name: SWAP
max: 256
entity_row: true
height: 25px
color: green
unit_of_measurement: MB
positions:
icon: 'off'
indicator: inside
style: |-
bar-card-background {
margin-left: 200px;
}
bar-card-value {
margin-right: auto;
font-size: 13px;
font-weight: bold;
text-shadow: 1px 1px #0005;
}
severity:
- color: Red
from: 204.8
to: 256
- color: Orange
from: 153.6
to: 204.8
- color: Green
from: 0
to: 153.6
- type: custom:bar-card
entities:
- entity: sensor.bwh
attribute: month_data_used
name: 流量
max: 300
entity_row: true
height: 25px
color: green
unit_of_measurement: GB
positions:
icon: 'off'
indicator: inside
style: |-
bar-card-background {
margin-left: 200px;
}
bar-card-value {
margin-right: auto;
font-size: 13px;
font-weight: bold;
text-shadow: 1px 1px #0005;
}
severity:
- color: Red
from: 240
to: 300
- color: Orange
from: 180
to: 240
- color: Green
from: 0
to: 180
第二张效果图前端卡片代码如下,需要用到的前端集成有:https://github.com/benct/lovelac ... -row#entity-objects 。使用前请自行安装。
type: entities
show_header_toggle: false
title: Bandwagon 服务器
icon: mdi:server
entities:
- type: custom:multiple-entity-row
entity: sensor.bwh
attribute: vps_status
icon: mdi:power
name: 状况
show_state: false
entities:
- attribute: vps_status
name: Status
- attribute: vps_suspended_status
name: Suspended
styles:
width: 100px
text-align: right
- type: custom:multiple-entity-row
entity: sensor.bwh
attribute: load_average
icon: mdi:reload
name: 负载
- type: custom:multiple-entity-row
entity: sensor.bwh
icon: mdi:memory
name: 内存
show_state: false
entities:
- attribute: ram_used
name: RAM used
unit: MB
- attribute: swap_used
name: SWAP used
unit: MB
styles:
width: 100px
text-align: right
- type: custom:multiple-entity-row
entity: sensor.bwh
icon: mdi:harddisk
name: 磁盘
show_state: false
entities:
- attribute: disk_used
name: Disk used
unit: GB
- attribute: disk_plan
name: Disk plan
unit: GB
styles:
width: 100px
text-align: right
- type: custom:multiple-entity-row
entity: sensor.bwh
icon: mdi:database-arrow-down-outline
name: 流量
show_state: false
entities:
- attribute: month_data_used
name: Data used
unit: GB
- attribute: month_data_plan
name: Data plan
unit: GB
styles:
width: 100px
text-align: right
NODE-RED流下载,参数设置请去搬瓦工后台获取:
BWH_FLOW.json.zip
(2.85 KB, 下载次数: 31)
|