最近使用了台式机自带的WOL,灰常好用,比硬件方便多了,而且延迟超小。。
switch:
# - platform: template
# switches:
# computer:
# value_template: "{% if is_state('device_tracker.superz', 'home') %}on{% else %}off{% endif %}"
# turn_on:
# service: script.turn_on
# data:
# entity_id: script.wake_on_lan
# turn_off:
# service: script.turn_on
# data:
# entity_id: script.shutdown
# icon_template: >-
# {% if is_state('binary_sensor.mycomputer', 'on') %}
# mdi:laptop
# {% else %}
# mdi:laptop-off
# {% endif %}
- platform: wake_on_lan
mac_address: "40:8D:5C:DC:XX:XX"
name: computer
host: 192.168.31.188
turn_off:
- service: hassio.addon_stdin
data:
addon: core_rpc_shutdown
input: mypc
#如果路由器不支持device_tracker的话,可以使用ping的方式判断电脑状态
# binary_sensor:
# - platform: ping
# name: my_computer
# host: 192.168.31.188
# count: 2
# scan_interval: 120
# script:
# wake_on_lan:
# sequence:
# - alias: 开
# service: switch.turn_on
# data:
# entity_id: switch.pc_s2
# - delay:
# # supports seconds, milliseconds, minutes, hours
# seconds: 1
# - alias: 关
# service: switch.turn_off
# data:
# entity_id: switch.pc_s2
#以下是HomeAssistant使用shell命令行实现关电脑,请根据运行环境自行选择
# shutdown:
# alias: 关闭电脑
# sequence:
# - service: shell_command.computer
#shell_command:
# computer: ssh net rpc shutdown -I 192.168.31.188 -U zhelishiyonghuming%zhelitiankaijimima
# 以下是Hassio/Hassos使用插件方式实现关电脑
# shutdown:
# alias: 关闭电脑
# sequence:
# - service: hassio.addon_stdin
# data:
# addon: core_rpc_shutdown
# input: mypc
homeassistant:
customize:
script.wake_on_lan:
friendly_name: 远程开机
icon: mdi:gesture-tap
hidden: true
script.shutdown:
friendly_name: 远程关机
icon: mdi:gesture-tap
hidden: true
binary_sensor.my_computer:
friendly_name: 我的电脑状态
switch.computer:
friendly_name: 电脑
icon: mdi:power
hagenie_zone: 客厅
hagenie_deviceName: 开关
hagenie_deviceType: switch
switch.computer:
friendly_name: 电脑
icon: mdi:power
hagenie_zone: 客厅
hagenie_deviceName: 开关
hagenie_deviceType: switch
注释掉的有时候也有用 大家可以参考下~ |