效果图:
- vultr官网的操作
首先到Vultr官网获取api key,如图:
- 点击左边栏的Account
- 点击API
- 复制API KEY和允许所有IPv4访问你的API
- 获取subscription的ID号,例如
https://my.vultr.com/subs/?SUBID=12345678
,12345678就是subscriptionID号了,每台主机的ID号都不同。
- HA端设置
我已经做成了package,以下是通用部分代码。要全代码请下载package包。
为了防止vps主机服务器被误操作关机,我用了custom-ui的确认控制功能,如果需要操作开关机必须先点击一下图标解锁后再点击一次图标进行操作。
binary_sensor:
- platform: vultr
name: vps_jp
subscription: 12345678 #改成你的SUBID
- platform: vultr
name: vps_sg
subscription: 87654321 #改成你的SUBID
sensor:
- platform: vultr
name: vps_jp_{}
subscription: 12345678 #改成你的SUBID
- platform: vultr
name: vps_sg_{}
subscription: 87654321 #改成你的SUBID
switch:
- platform: vultr
name: vps_jp
subscription: 12345678 #改成你的SUBID
- platform: vultr
name: vps_sg
subscription: 87654321 #改成你的SUBID
group:
vps:
name: "VPS面板"
control: hidden
entities:
- switch.vps_jp
- binary_sensor.vps_jp
- sensor.vps_jp_current_bandwidth_used
- sensor.vps_jp_pending_charges
- switch.vps_sg
- binary_sensor.vps_sg
- sensor.vps_sg_current_bandwidth_used
- sensor.vps_sg_pending_charges
homeassistant:
#更改为你的API KEY
vultr:
api_key: PA6PM0A6577ELSJM1U1GPCTNJG7RG21783KB
- 参考文档
https://home-assistant.io/components/#search/vultr
https://github.com/andrey-git/home-assistant-custom-ui/blob/master/docs/features.md
文档更新时间: 2018-03-21 04:09 作者:Tristan