https://www.home-assistant.io/integrations/switch.template/
binary_sensor:
- platform: ping
host: 192.168.0.1
name: "ping_nas"
count: 2
scan_interval: 30
switch:
- platform: template
switches:
skylight:
value_template: "{{ is_state('binary_sensor.ping_nas', 'on') }}"
turn_on:
service: switch.turn_on
target:
entity_id: switch.nas_open
turn_off:
service: shell_command.turn_off_pc
shell_command:
turn_off_pc: bash /config/shell/turn_off_pc.sh
这样行不行呢? |