Desta vez trago-vos um tutorial em que podem controlar o pc por voz e pelo HA e saber o estado do mesmo (acender e apagar o pc).
Então comecei por flashar um sonoff sv, (podem encontrar tutoriais aqui no forum).
Depois usei o tuttorial do nosso amigo @RodolfoVieira para ligar o gpio 14 para contacto seco. 📑 Como abrir a garagem com o comando Original a partir do Home Assistant.
Depois flashei um wemos d1 mini com tasmota versao 6.4.1. e configurei com generic
Também foi preciso soldar 2 fios no botão de power do pc…
Após isto tudo feito vamos configurar o HA com o seguinte yaml…
homeassistant:
###############################################################################
# #
# L I G H T #
# #
###############################################################################
light:
- platform: mqtt
name: "Leds Armário sala"
state_topic: "stat/leds_pc/POWER1"
command_topic: "cmnd/leds_pc/power1"
availability_topic: "tele/leds_pc/LWT"
payload_available: "Online"
payload_not_available: "Offline"
qos: 1
payload_on: "ON"
payload_off: "OFF"
retain: false
###############################################################################
# #
# S W I T C H #
# #
###############################################################################
switch:
- platform: mqtt
name: "ON OFF PC"
state_topic: "stat/leds_pc/POWER2"
command_topic: "cmnd/leds_pc/power2"
availability_topic: "tele/leds_pc/LWT"
payload_available: "Online"
payload_not_available: "Offline"
qos: 1
payload_on: "ON"
payload_off: "OFF"
retain: false
#estado do pc wemos d1 mini
- platform: mqtt
name: "Estado do PC"
state_topic: "stat/state_pc_on_off/POWER1"
command_topic: "cmnd/state_pc_on_off/power1"
availability_topic: "tele/state_pc_on_off/LWT"
payload_available: "Online"
payload_not_available: "Offline"
qos: 1
payload_on: "ON"
payload_off: "OFF"
###############################################################################
# #
# S E N S O R #
# #
###############################################################################
sensor:
- platform: template
sensors:
pc_on_off:
friendly_name: "PC Estado"
value_template: >-
{% if is_state('switch.estado_do_pc', 'off') %}
Ligado
{% else %}
Desligado
{% endif %}
icon_template: >-
{% if is_state('switch.estado_do_pc', 'off') %}
mdi:television
{% else %}
mdi:television-off
{% endif %}
###############################################################################
# #
# A U T O M A T I O N #
# #
###############################################################################
automation:
- alias: Ligar pc
initial_state: true
trigger:
platform: time
at: 02:45:00
action:
- service: switch.turn_on
entity_id: switch.on_off_pc
- alias: Desligar pc
initial_state: true
trigger:
platform: time
at: 09:15:00
action:
- service: switch.turn_on
entity_id: switch.on_off_pc
# leds armario sala
E como bonus ainda vou ligar uns leds de 12v a saida do sonoff para poder controlar esses mesmos.
Agora só falta uma pequena configuração no windows que segue uma imagem de exemplo.
Depois de todo configurado e reinicio do HA vamos configurar rotinas no GHM
Acho que não me esqueci de nada. Espero que vos seja util.