Tema
Homie_Bot - HA Lite Version | Telegram
Resumo
Enquanto pensava num tópico para o projecto deparei com vários objectivos para a realização do mesmo:
- Participar;
- Aprender algo novo;
- Tentar resolver algum problema aos utilizadores;
Assim sendo e como nunca tinhe feito nada com o Telegram Bot dentro do HA, decidi investigar. Reparei que a maioria das pessoas usa para notificações e decidi então fazer uma versão para visualizar/controlar em tempo real o nosso Home Assistant, sem ter que aceder à aplicação. Isto permite também que a nossa instância não tenha que ser publicada e permite por vezes efectuar tarefas mais rápidas sem abrir a aplicação.
Descrição
Assim sendo, e como isto foi feito tudo em yaml, passo a descrever a utilização e configuração para poderem controlar a vossa casa através do HA.
Eu tenho alguns exemplos e entidades que escolhi para utilização deste serviço.
Pré-requisito e não contemplado:
Configuração do Bot Telegram, configuração por packages, integração do speedtest.
Todo o projecto é à base de software, pelo que ficam imagens das várias fases e menus:
Menu Inicial:
Menu Visualização Geral:
Menu Visualização Temperaturas e Humidade:
Menu Visualização Baterias:
Menu Visualização Alarme e Sensores:
Menu Visualização Meteorologia:
Menu Visualização Consumos:
Menu Visualização Speedtest:
Menu Visualização VMs e Containers Proxmox:
Menu Controlo Pedido Password
Menu Controlo Geral
Menu Controlo Luzes
Menu Controlo Tomadas
Fica também um link com um pequeno vídeo de demonstração para ter o real feeling do bot:
Vídeo Demonstração | Homie Bot
Código (Automations e Scripts)
Importante: Ter o nome dos scripts iguais ao nome dos botões pois o segredo está aqui:
service: script.{{ trigger.event.data.data.split(’/’)[1] }}
automations_telegram_bot.yaml
automation:
################################################
## Automation Password Validation HA Telegram ##
################################################
#####Alterar user_id#####
#####Alterar chat_id#####
#####Criar auxiliar input_text.telegram_password#####
#####Num card ou onde quiserem escrever a vossa password de validação para controlo de entidades#####
- id: '1613005098936'
alias: Telegram Bot Password Validation
description: ''
trigger:
- platform: event
event_type: telegram_command
event_data:
command: /validation
user_id: YOUR_USER_ID
- platform: event
event_type: telegram_text
condition: []
action:
- service: telegram_bot.delete_message
data:
message_id: last
chat_id: YOUR_CHAT_ID
- choose:
- conditions:
- condition: template
value_template: '{{ trigger.event.data.text == states.input_text.telegram_password.state
}}'
sequence:
- service: script.password_validation_telegram
data: {}
- service: telegram_bot.edit_message
data:
message_id: last
chat_id: YOUR_CHAT_ID
message: '[{{"\U00002705"}}Password Correcta!{{"\U00002705"}}]'
- delay:
hours: 0
minutes: 0
seconds: 3
milliseconds: 0
- service: script.control_telegram
data: {}
default:
- service: script.password_validation_telegram
data: {}
- service: telegram_bot.edit_message
data:
message_id: last
chat_id: YOUR_CHAT_ID
message: '[❌Password Errada!❌]'
- delay:
hours: 0
minutes: 0
seconds: 3
milliseconds: 0
- service: script.insert_password_telegram
data: {}
mode: single
###############################################
## Automation Daily Consumptions HA Telegram ##
###############################################
- id: '1613328947876'
alias: Daily Consumptions
description: ''
trigger:
- platform: time
at: '23:59'
condition: []
action:
- service: script.information_consumptions_ha_telegram
data: {}
mode: single
#############################################
## Automation Command Control HA Telegram ##
#############################################
#####Alterar chat_id#####
- id: '1613972768703'
alias: Telegram Script Template
description: ''
trigger:
- platform: event
event_type: telegram_callback
- platform: event
event_type: telegram_command
event_data:
command: /ha
user_id: YOUR_CHAT_ID
condition: []
action:
- choose:
- conditions:
- condition: template
value_template: '{{ trigger.event.data.data == ''/back'' }}'
sequence:
- service: telegram_bot.delete_message
data:
message_id: last
chat_id: YOUR_CHAT_ID
- service: script.start_ha_telegram
data: {}
- conditions:
- condition: template
value_template: '{{ trigger.event.data.data == ''/exit'' }}'
sequence:
- service: telegram_bot.delete_message
data:
message_id: last
chat_id: YOUR_CHAT_ID
- service: telegram_bot.delete_message
data:
message_id: last
chat_id: YOUR_CHAT_ID
- conditions:
- condition: template
value_template: '{{ trigger.event.data.command == ''/ha'' }}'
sequence:
- service: telegram_bot.delete_message
data:
message_id: last
chat_id: YOUR_CHAT_ID
- service: script.start_ha_telegram
data: {}
default:
- service: script.{{ trigger.event.data.data.split('/')[1] }}
data: {}
mode: single
telegram_bot_start.yaml
script:
#####Alterar chat_id#####
#####Alterar cada entidade light.XXXX ou switch.XXXX para uma entidade vossa dentro de cada {if -> endif}#####
#####Alterar no texto de cada if o nome da entidade a ser apresentada (ex:Candeeiro Hall R/C)#####
#####Acrescentar consumos instantaneos nas tomadas que tenham essas leituras (ex:switch.termoacumulador)#####
##############################
## Menu Inicial HA Telegram ##
##############################
start_ha_telegram:
alias: Start HA Telegram
sequence:
- service: telegram_bot.send_message
data_template:
message: |
Olá Maurício! Sou o Homie{{"[\U0001F916]"}}.
Em que posso ajudar?
{{"\U0001F4A1"}}Iluminação{{"\U0001F4A1"}}
{% if is_state('light.candeeiro_hall_r_c', 'on') %}{{"\U0001F7E1"}}Candeeiro Hall R/C - {{states.light.candeeiro_hall_r_c.state}} | Ligado às {{as_timestamp(states.light.candeeiro_hall_r_c.last_updated)| timestamp_custom('%H:%M',True)}}{% else %}{{"\U00002B55"}}Candeeiro Hall R/C - {{states.light.candeeiro_hall_r_c.state}}{% endif %}
{% if is_state('light.candeeiro_margarida', 'on') %}{{"\U0001F7E1"}}Candeeiro Margarida - {{states.light.candeeiro_margarida.state}} | Ligado às {{as_timestamp(states.light.candeeiro_margarida.last_updated)| timestamp_custom('%H:%M',True)}}{% else %}{{"\U00002B55"}}Candeeiro Margarida - {{states.light.candeeiro_margarida.state}}{% endif %}
{% if is_state('light.candeeiro_mauricio', 'on') %}{{"\U0001F7E1"}}Candeeiro Maurício - {{states.light.candeeiro_mauricio.state}} | Ligado às {{as_timestamp(states.light.candeeiro_mauricio.last_updated)| timestamp_custom('%H:%M',True)}}{% else %}{{"\U00002B55"}}Candeeiro Maurício - {{states.light.candeeiro_mauricio.state}}{% endif %}
{% if is_state('switch.focos_suite', 'on') %}{{"\U0001F7E1"}}Focos Suíte - {{states.switch.focos_suite.state}} | Ligado às {{as_timestamp(states.switch.focos_suite.last_updated)| timestamp_custom('%H:%M',True)}}{% else %}{{"\U00002B55"}}Focos Suíte - {{states.switch.focos_suite.state}}{% endif %}
{% if is_state('light.bedside_lamp', 'on') %}{{"\U0001F7E1"}}Bedside Lamp - {{states.light.bedside_lamp.state}} | Ligado às {{as_timestamp(states.light.bedside_lamp.last_updated)| timestamp_custom('%H:%M',True)}}{% else %}{{"\U00002B55"}}Bedside Lamp - {{states.light.bedside_lamp.state}}{% endif %}
{% if is_state('light.candeeiro_maria', 'on') %}{{"\U0001F7E1"}}Candeeiro Maria - {{states.light.candeeiro_maria.state}} | Ligado às {{as_timestamp(states.light.candeeiro_maria.last_updated)| timestamp_custom('%H:%M',True)}}{% else %}{{"\U00002B55"}}Candeeiro Maria - {{states.light.candeeiro_maria.state}}{% endif %}
{% if is_state('light.aqara_hub', 'on') %}{{"\U0001F7E1"}}Aqara Hub - {{states.light.aqara_hub.state}} | Ligado às {{as_timestamp(states.light.aqara_hub.last_updated)| timestamp_custom('%H:%M',True)}}{% else %}{{"\U00002B55"}}Aqara Hub - {{states.light.aqara_hub.state}}{% endif %}
{{"\U0001F50C"}}Tomadas{{"\U0001F50C"}}
{% if is_state('switch.tomada_suite', 'on') %}{{"\U000026A1"}}Suíte - {{states.switch.tomada_suite.state}} | Instantâneo - {{states.sensor.tomada_suite.state}} W{% else %}{{"\U0000274C"}}Tomada Suíte - {{states.switch.tomada_suite.state}}{% endif %}
{% if is_state('switch.tv_suite', 'on') %}{{"\U000026A1"}}TV Suíte - {{states.switch.tv_suite.state}} | Sem leituras{% else %}{{"\U0000274C"}}TV Suíte - {{states.switch.tv_suite.state}}{% endif %}
{% if is_state('switch.mibox_suite', 'on') %}{{"\U000026A1"}}MiBox Suíte - {{states.switch.mibox_suite.state}} | Sem leituras{% else %}{{"\U0000274C"}}MiBox Suíte - {{states.switch.mibox_suite.state}}{% endif %}
{% if is_state('switch.extra_suite', 'on') %}{{"\U000026A1"}}Extra Suíte - {{states.switch.extra_suite.state}} | Sem leituras{% else %}{{"\U0000274C"}}Extra Suíte - {{states.switch.extra_suite.state}}{% endif %}
{% if is_state('switch.tomada_francisco', 'on') %}{{"\U000026A1"}}Francisco - {{states.switch.tomada_francisco.state}} | Instantâneo - {{states.sensor.tomada_francisco.state}} W{% else %}{{"\U0000274C"}}Francisco - {{states.switch.tomada_francisco.state}}{% endif %}
{% if is_state('switch.sala', 'on') %}{{"\U000026A1"}}Sala - {{states.switch.sala.state}} | Sem leituras{% else %}{{"\U0000274C"}}Sala - {{states.switch.sala.state}}{% endif %}
{% if is_state('switch.arca', 'on') %}{{"\U000026A1"}}Arca - {{states.switch.arca.state}} | Sem leituras{% else %}{{"\U0000274C"}}Arca - {{states.switch.arca.state}}{% endif %}
{% if is_state('switch.maquina_secar', 'on') %}{{"\U000026A1"}}Máquina Secar - {{states.switch.maquina_secar.state}} | Sem leituras{% else %}{{"\U0000274C"}}Máquina Secar - {{states.switch.maquina_secar.state}}{% endif %}
{% if is_state('switch.termoacumulador', 'on') %}{{"\U000026A1"}}Termoacumulador - {{states.switch.termoacumulador.state}} | Instantâneo - {{states.sensor.tomada_termoacumulador_instantaneo.state}} W{% else %}{{"\U0000274C"}}Termoacumulador - {{states.switch.termoacumulador.state}}{% endif %}
{% if is_state('switch.maquina_roupa', 'on') %}{{"\U000026A1"}}Máquina Roupa - {{states.switch.maquina_roupa.state}} | Instantâneo - {{states.sensor.maquina_da_roupa.state}} W{% else %}{{"\U0000274C"}}Máquina Roupa - {{states.switch.maquina_roupa.state}}{% endif %}
inline_keyboard:
- "\U0001F4BB Controlo:/insert_password_telegram"
- "\U0001F4CA Visualização:/visualization_telegram"
- "\U0001F3C3 Sair:/exit"
teelgram_bot_visualization.yaml
script:
###################################
## Menu Visualização HA Telegram ##
###################################
#####Alterar chat_id#####
visualization_telegram:
alias: Visualization HA Telegram
sequence:
- service: telegram_bot.edit_message
data_template:
message_id: last
chat_id: YOUR_CHAT_ID
message: "\U0001F4CA O que pretende visualizar?"
inline_keyboard:
- "\U0001F321 Temp. & Hum. \U0001F4A7:/Visualization_temp_hum_telegram, \U0001F324 Meteorologia:/visualization_weather_telegram"
- "\U000026A1 Consumos:/visualization_consumptions_telegram, \U0001F50B Baterias:/visualization_batteries_telegram"
- "\U0001F5A5 Máquinas Virtuais:/visualization_vms_telegram, \U0001F310 SpeedTest:/visualization_speedtest_telegram"
- "\U0001F6E1 Alarme & Sensores:/visualization_alarm_others_telegram"
- "\U0001F3C3 Voltar:/back, \U0001F3C3 Sair:/exit"
###########################################################
## Menu Visualização Temperaturas & Humidade HA Telegram ##
###########################################################
#####Alterar chat_id#####
#####Alterar entidades temp & hum (neste exemplo cada divisão é um sensor aqara de temp&hum)#####
visualization_temp_hum_telegram:
alias: Visualization Temp & Hum HA Telegram
sequence:
- service: telegram_bot.edit_message
data_template:
message_id: last
chat_id: YOUR_CHAT_ID
message: |
{{"\U0001F321"}}Temperatura & Humidade{{"\U0001F4A7"}}
Sala
{{"\U0001F321"}}{{states('sensor.conbee_temperatura_sala')}}
{{- state_attr('sensor.conbee_temperatura_sala', 'unit_of_measurement')}} |
{{- "\U0001F4A7"}}{{states('sensor.humidade_sala')}}
{{- state_attr('sensor.humidade_sala', 'unit_of_measurement')}}
Suíte
{{"\U0001F321"}}{{states('sensor.conbee_temperatura_suite')}}
{{- state_attr('sensor.conbee_temperatura_suite', 'unit_of_measurement')}} |
{{- "\U0001F4A7"}}{{states('sensor.humidade_suite')}}
{{- state_attr('sensor.humidade_suite', 'unit_of_measurement')}}
Q. Francisco
{{"\U0001F321"}}{{states('sensor.conbee_temperatura_francisco')}}
{{- state_attr('sensor.conbee_temperatura_francisco', 'unit_of_measurement')}} |
{{- "\U0001F4A7"}}{{states('sensor.humidade_quarto_francisco')}}
{{- state_attr('sensor.humidade_quarto_francisco', 'unit_of_measurement')}}
Q. Maria
{{"\U0001F321"}}{{states('sensor.conbee_temperatura_maria')}}
{{- state_attr('sensor.conbee_temperatura_maria', 'unit_of_measurement')}} |
{{- "\U0001F4A7"}}{{states('sensor.humidade_quarto_maria')}}
{{- state_attr('sensor.humidade_quarto_maria', 'unit_of_measurement')}}
Escritório
{{"\U0001F321"}}{{states('sensor.conbee_temperatura_escritorio')}}
{{- state_attr('sensor.conbee_temperatura_escritorio', 'unit_of_measurement')}} |
{{- "\U0001F4A7"}}{{states('sensor.humidade_escritorio')}}
{{- state_attr('sensor.humidade_escritorio', 'unit_of_measurement')}}
Cozinha
{{"\U0001F321"}}{{states('sensor.conbee_temperatura_cozinha')}}
{{- state_attr('sensor.conbee_temperatura_cozinha', 'unit_of_measurement')}} |
{{- "\U0001F4A7"}}{{states('sensor.humidade_cozinha')}}
{{- state_attr('sensor.humidade_cozinha', 'unit_of_measurement')}}
inline_keyboard:
- "\U0001F3C3 Voltar:/visualization_telegram, \U0001F3C3 Sair:/exit"
############################################
## Menu Visualização Baterias HA Telegram ##
############################################
#####Alterar chat_id#####
#####Alterar entidades bateria#####
visualization_batteries_telegram:
alias: Visualization Batteries HA Telegram
sequence:
- service: telegram_bot.edit_message
data_template:
message_id: last
chat_id: YOUR_CHAT_ID
message: |
{{"\U0001F50B"}}Baterias{{"\U0001F50B"}}
{{"\U0001F3C3"}}S. Movimento
{% if states('sensor.sensor_movimento_bateria') | float > 69 -%}
{{"\U0001F7E2"}}
{%- elif states('sensor.sensor_movimento_bateria') | float < 70 and states('sensor.sensor_movimento_bateria') | float > 29 -%}
{{"\U0001F7E1"}}
{%- else -%}
{{"\U0001F534"}}
{%- endif -%}
Aqara -
{{- states('sensor.sensor_movimento_bateria')}}
{{- state_attr('sensor.sensor_movimento_bateria','unit_of_measurement')}}
{% if states('sensor.sensor_escadas_battery_level') | float > 69 -%}
{{"\U0001F7E2"}}
{%- elif states('sensor.sensor_escadas_battery_level') | float < 70 and states('sensor.sensor_escadas_battery_level') | float > 29 -%}
{{"\U0001F7E1"}}
{%- else -%}
{{"\U0001F534"}}
{%- endif -%}
Escadas -
{{- states('sensor.sensor_escadas_battery_level')}}
{{- state_attr('sensor.sensor_escadas_battery_level','unit_of_measurement')}}
{{"\U0001F321"}}{{"\U0001F4A7"}}S. Temp & Hum
{% if states('sensor.bateria_sensor_temp_sala') | float > 69 %}{{"\U0001F7E2"}}
{%- elif states('sensor.bateria_sensor_temp_sala') | float < 70 and states('sensor.bateria_sensor_temp_sala') | float > 29 %}{{"\U0001F7E1"}}
{%- else %}{{"\U0001F534"}}{% endif -%}
Sala - {{states('sensor.bateria_sensor_temp_sala')}}{{state_attr('sensor.bateria_sensor_temp_sala','unit_of_measurement')}}
{% if states('sensor.bateria_sensor_temp_suite') | float > 69 %}{{"\U0001F7E2"}}
{%- elif states('sensor.bateria_sensor_temp_suite') | float < 70 and states('sensor.bateria_sensor_temp_suite') | float > 29 %}{{"\U0001F7E1"}}
{%- else %}{{"\U0001F534"}}{% endif %}Suíte - {{states('sensor.bateria_sensor_temp_suite')}}{{state_attr('sensor.bateria_sensor_temp_suite','unit_of_measurement')}}
{% if states('sensor.bateria_sensor_temp_quarto_francisco') | float > 69 %}{{"\U0001F7E2"}}{% elif states('sensor.bateria_sensor_temp_quarto_francisco') | float < 70 and states('sensor.bateria_sensor_temp_quarto_francisco') | float > 29 %}{{"\U0001F7E1"}}{% else %}{{"\U0001F534"}}{% endif %}Q. Francisco - {{states('sensor.bateria_sensor_temp_quarto_francisco')}}{{state_attr('sensor.bateria_sensor_temp_quarto_francisco','unit_of_measurement')}}
{% if states('sensor.bateria_sensor_temp_maria') | float > 69 %}{{"\U0001F7E2"}}{% elif states('sensor.bateria_sensor_temp_maria') | float < 70 and states('sensor.bateria_sensor_temp_maria') | float > 29 %}{{"\U0001F7E1"}}{% else %}{{"\U0001F534"}}{% endif %}Q. Maria - {{states('sensor.bateria_sensor_temp_maria')}}{{state_attr('sensor.bateria_sensor_temp_maria','unit_of_measurement')}}
{% if states('sensor.bateria_sensor_temp_escritorio') | float > 69 %}{{"\U0001F7E2"}}{% elif states('sensor.bateria_sensor_temp_escritorio') | float < 70 and states('sensor.bateria_sensor_temp_escritorio') | float > 29 %}{{"\U0001F7E1"}}{% else %}{{"\U0001F534"}}{% endif %}Escritório - {{states('sensor.bateria_sensor_temp_escritorio')}}{{state_attr('sensor.bateria_sensor_temp_escritorio','unit_of_measurement')}}
{% if states('sensor.sensor_cozinha_battery_level') | float > 69 %}{{"\U0001F7E2"}}{% elif states('sensor.sensor_cozinha_battery_level') | float < 70 and states('sensor.sensor_cozinha_battery_level') | float > 29 %}{{"\U0001F7E1"}}{% else %}{{"\U0001F534"}}{% endif %}Cozinha - {{states('sensor.sensor_cozinha_battery_level')}}{{state_attr('sensor.sensor_cozinha_battery_level','unit_of_measurement')}}
{{"\U0001F6AA"}}S. Porta
{% if states('sensor.bateria_sensor_porta_cozinha') | float > 69 %}{{"\U0001F7E2"}}{% elif states('sensor.bateria_sensor_porta_cozinha') | float < 70 and states('sensor.bateria_sensor_porta_cozinha') | float > 29 %}{{"\U0001F7E1"}}{% else %}{{"\U0001F534"}}{% endif %}Cozinha - {{states('sensor.bateria_sensor_porta_cozinha')}}{{state_attr('sensor.bateria_sensor_porta_cozinha','unit_of_measurement')}}
{% if states('sensor.bateria_sensor_porta_escritorio') | float > 69 %}{{"\U0001F7E2"}}{% elif states('sensor.bateria_sensor_porta_escritorio') | float < 70 and states('sensor.bateria_sensor_porta_escritorio') | float > 29 %}{{"\U0001F7E1"}}{% else %}{{"\U0001F534"}}{% endif %}Hall R/C - {{states('sensor.bateria_sensor_porta_escritorio')}}{{state_attr('sensor.bateria_sensor_porta_escritorio','unit_of_measurement')}}
{{"\U0001F4F1"}}Outros
{% if states('sensor.bateria_cubo') | float > 69 %}{{"\U0001F7E2"}}{% elif states('sensor.bateria_cubo') | float < 70 and states('sensor.bateria_cubo') | float > 29 %}{{"\U0001F7E1"}}{% else %}{{"\U0001F534"}}{% endif %}Aqara Cube - {{states('sensor.bateria_cubo')}}{{state_attr('sensor.bateria_cubo','unit_of_measurement')}}
{% if states('sensor.oneplus_a5010_battery_level') | float > 69 %}{{"\U0001F7E2"}}{% elif states('sensor.oneplus_a5010_battery_level') | float < 70 and states('sensor.oneplus_a5010_battery_level') | float > 29 %}{{"\U0001F7E1"}}{% else %}{{"\U0001F534"}}{% endif %}Tlm Maurício - {{states('sensor.oneplus_a5010_battery_level')}}{{state_attr('sensor.oneplus_a5010_battery_level','unit_of_measurement')}}
{% if states('sensor.redmi_note_5_nivel_da_bateria') | float > 69 %}{{"\U0001F7E2"}}{% elif states('sensor.redmi_note_5_nivel_da_bateria') | float < 70 and states('sensor.redmi_note_5_nivel_da_bateria') | float > 29 %}{{"\U0001F7E1"}}{% else %}{{"\U0001F534"}}{% endif %}Tlm Margarida - {{states('sensor.redmi_note_5_nivel_da_bateria')}}{{state_attr('sensor.redmi_note_5_nivel_da_bateria','unit_of_measurement')}}
{% if states('sensor.tablet_battery_level') | float > 69 %}{{"\U0001F7E2"}}{% elif states('sensor.tablet_battery_level') | float < 70 and states('sensor.tablet_battery_level') | float > 29 %}{{"\U0001F7E1"}}{% else %}{{"\U0001F534"}}{% endif %}Tablet - {{states('sensor.tablet_battery_level')}}{{state_attr('sensor.tablet_battery_level','unit_of_measurement')}}
inline_keyboard:
- "\U0001F3C3 Voltar:/visualization_telegram, \U0001F3C3 Sair:/exit"
#####################################################
## Menu Visualização Alarme & Sensores HA Telegram ##
#####################################################
#####Alterar chat_id#####
#####Alterar entidades alarme, sensores de porta e movimento#####
visualization_alarm_others_telegram:
alias: Visualization Alarm Others HA Telegram
sequence:
- service: telegram_bot.edit_message
data_template:
message_id: last
chat_id: YOUR_CHAT_ID
message: |
{{"\U0001F6E1"}}Alarme{{"\U0001F6E1"}}
{% if is_state('alarm_control_panel.aqara_hub', 'disarmed') %}{{"\U000026A0"}}Desarmado{% else %}{{"\U0001F46E"}}Armado{% endif %}
{{"\U0001F3C3"}}S. Movimento{{"\U0001F3C3"}}
{% if is_state('binary_sensor.sensor_movimento_aqara', 'on') %}{{"\U0001F6B6"}}Aqara Piso 0 - Movimento detectado{% else %}{{"\U0001F9CD"}}Aqara Piso 0 - Limpo{% endif %}
{% if is_state('binary_sensor.motion_sensor_escadas', 'on') %}{{"\U0001F6B6"}}Escadas Piso 1 - Movimento detectado{% else %}{{"\U0001F9CD"}}Escadas Piso 1 - Limpo{% endif %}
{{"\U0001F6AA"}}S. Porta{{"\U0001F6AA"}}
{% if is_state('binary_sensor.conbee_porta_escritorio', 'on') %}{{"\U00002B1C"}}Hall R/C - Aberta{% else %}{{"\U00002B1B"}}Hall R/C - Fechada{% endif %}
{% if is_state('binary_sensor.conbee_porta_cozinha', 'on') %}{{"\U00002B1C"}}Cozinha - Aberta{% else %}{{"\U00002B1B"}}Cozinha - Fechada{% endif %}
inline_keyboard:
- "\U0001F3C3 Voltar:/visualization_telegram, \U0001F3C3 Sair:/exit"
############################################
## Menu Visualização Consumos HA Telegram ##
############################################
#####Alterar chat_id#####
#####Alterar entidades consumos diários, semanai e mensais. São utilizadas utility_meter#####
visualization_consumptions_telegram:
alias: Visualization Consumptiom HA Telegram
sequence:
- service: telegram_bot.edit_message
data_template:
message_id: last
chat_id: YOUR_CHAT_ID
message: |
{{"\U000026A1"}}Consumos{{"\U000026A1"}}
{{"\U0001F6CF"}}Suíte{{"\U0001F6CF"}}
Dia: {{states('sensor.consumo_diario_suite')}} ({{(states.sensor.consumo_diario_suite.state | float - states.sensor.consumo_diario_suite.attributes.last_period | float) | round(2)}}) kWh
Semana: {{states('sensor.consumo_semanal_suite')}} ({{(states('sensor.consumo_semanal_suite') | float - states.sensor.consumo_semanal_suite.attributes.last_period | float) | round(2)}}) kWh
Mês: {{states('sensor.consumo_mensal_suite')}} ({{(states('sensor.consumo_mensal_suite') | float - states.sensor.consumo_mensal_suite.attributes.last_period | float) | round(2)}}) kWh
Total: {{states('sensor.consumo_suite')}} kWh
{{"\U0001F645"}}Q. Francisco{{"\U0001F645"}}
Dia: {{states('sensor.consumo_diario_aquecedor_francisco')}} ({{(states('sensor.consumo_diario_aquecedor_francisco') | float - states.sensor.consumo_diario_aquecedor_francisco.attributes.last_period | float) | round(2)}}) kWh
Semana: {{states('sensor.consumo_semanal_aquecedor_francisco')}} ({{(states('sensor.consumo_semanal_aquecedor_francisco') | float - states.sensor.consumo_semanal_aquecedor_francisco.attributes.last_period | float) | round(2)}}) kWh
Mês: {{states('sensor.consumo_mensal_aquecedor_francisco')}} ({{(states('sensor.consumo_mensal_aquecedor_francisco') | float - states.sensor.consumo_mensal_aquecedor_francisco.attributes.last_period | float) | round(2)}}) kWh
Total: {{states('sensor.consumo_francisco.state')}} kWh
{{"\U00002668"}}Termoacumulador{{"\U00002668"}}
Dia: {{states('sensor.consumo_diario_termoacumulador')}} ({{(states('sensor.consumo_diario_termoacumulador') | float - states.sensor.consumo_diario_termoacumulador.attributes.last_period | float) | round(2)}}) kWh
Semana: {{states('sensor.consumo_semanal_termoacumulador')}} ({{(states('sensor.consumo_semanal_termoacumulador') | float - states.sensor.consumo_semanal_termoacumulador.attributes.last_period | float) | round(2)}}) kWh
Mês: {{states('sensor.consumo_mensal_termoacumulador')}} ({{(states('sensor.consumo_mensal_termoacumulador') | float - states.sensor.consumo_mensal_termoacumulador.attributes.last_period | float) | round(2)}}) kWh
Total: {{states('sensor.consumo_termoacumulador')}} kWh
{{"\U0001F455"}}Máquina Roupa{{"\U0001F455"}}
Dia: {{states.sensor.consumo_diario_maquina_roupa.state}} ({{(states.sensor.consumo_diario_maquina_roupa.state | float - states.sensor.consumo_diario_maquina_roupa.attributes.last_period | float) | round(2)}}) kWh
Semana: {{states.sensor.consumo_semanal_maquina_roupa.state}} ({{(states.sensor.consumo_semanal_maquina_roupa.state | float - states.sensor.consumo_semanal_maquina_roupa.attributes.last_period | float) | round(2)}}) kWh
Mês: {{states.sensor.consumo_mensal_maquina_roupa.state}} ({{(states.sensor.consumo_mensal_maquina_roupa.state | float - states.sensor.consumo_mensal_maquina_roupa.attributes.last_period | float) | round(2)}}) kWh
Total: {{states.sensor.consumption_31.state}} kWh
inline_keyboard:
- "\U0001F3C3 Voltar:/visualization_telegram, \U0001F3C3 Sair:/exit"
#############################################
## Menu Visualização SpeedTest HA Telegram ##
#############################################
#####Alterar chat_id#####
#####Alterar entidades integração speedtest#####
visualization_speedtest_telegram:
alias: Visualization SpeedTest HA Telegram
sequence:
- service: telegram_bot.edit_message
data_template:
message_id: last
chat_id: YOUR_CHAT_ID
message: |
{{"\U0001F310"}}SpeedTest{{"\U0001F310"}}
Nome Servidor: Lisboa
País Servidor: Portugal
{{"\U0001F4E5"}}Download{{"\U0001F4E5"}}
{{states('sensor.speedtest_download')}} Mbit/s
{{"\U0001F4E4"}}Upload{{"\U0001F4E4"}}
{{states('sensor.speedtest_upload')}} Mbit/s
{{"\U000023F3"}}Ping{{"\U000023F3"}}
{{states('sensor.speedtest_ping')}} ms
inline_keyboard:
- "\U0001F3C3 Novo Teste:/new_speedtest_telegram"
- "\U0001F3C3 Voltar:/visualization_telegram, \U0001F3C3 Sair:/exit"
#############################################
## Menu Visualização Weather HA Telegram ####
#############################################
#####Alterar chat_id#####
#####Alterar entidades integração weather (exemplo: weather.roquexavier -> weather.vossaentidadecasa#####
visualization_weather_telegram:
alias: Visualization Weather HA Telegram
sequence:
- service: telegram_bot.edit_message
data_template:
message_id: last
chat_id: YOUR_CHAT_ID
message: |
{% set condition0 = state_attr('weather.roquexavier','forecast')[0].condition %}
{% set condition1 = state_attr('weather.roquexavier','forecast')[1].condition %}
{% set condition2 = state_attr('weather.roquexavier','forecast')[2].condition %}
{% set condition3 = state_attr('weather.roquexavier','forecast')[3].condition %}
{% set condition4 = state_attr('weather.roquexavier','forecast')[4].condition %}
{{"\U0001F324"}}Meteorologia{{"\U0001F324"}}
{%if is_state('weather.roquexavier','sunny')%}{{"\U00002600"}}Ensolarado{%elif
is_state('weather.roquexavier','partlycloudy')%}{{"\U000026C5"}}Parcialmente Nublado{%elif
is_state('weather.roquexavier','cloudy')%}{{"\U00002601"}}Nublado{%elif
is_state('weather.roquexavier','fog')%}{{"\U0001F32B"}}Nevoeiro{%elif
is_state('weather.roquexavier','rainy')%}Chuvoso{{"\U0001F327"}}{%elif
is_state('weather.roquexavier','snowy')%}Neve{{"\U0001F328"}}{%elif is_state('weather.roquexavier','snowy-rainy')%}Neve e
Chuva{{"\U0001F32B"}}{% elif is_state('weather.roquexavier','lightning')%}{{"\U0001F329"}}Trovoada{%elif
is_state('weather.roquexavier','lightning-rainy')%}Trovoada e Chuva{{"\U000026C8"}}{%elif
is_state('weather.roquexavier','clear-night')%}Noite Limpa{{"\U0001F31D"}}{% elif
is_state('weather.roquexavier','windy')%}{{"\U0001F32C"}}Ventoso{% elif is_state('weather.roquexavier','windy-variant')%}Ventoso
Variante{{"\U0001F32C"}}{%elif is_state('weather.roquexavier','hail')%}{{"\U0001F9CA"}}Granizo{%elif is_state('weather.roquexavier','pouring')%}Chuva Forte{{"\U0001F4A7"}}{%else%}{{"\U0001F30C"}}Excepcional{%endif%}
Temperatura - {{(state_attr('weather.roquexavier', 'temperature'))}}ºC
Humidade - {{(state_attr('weather.roquexavier', 'humidity'))}}%
Pressão Atmosférica - {{(state_attr('weather.roquexavier', 'pressure'))}}
Vento - {{(state_attr('weather.roquexavier', 'wind_speed'))}}km/h
{% if condition0 == "sunny" -%}
{{"\U00002600"}}
{%- elif condition0 == "partlycloudy" -%}
{{"\U000026C5"}}
{%- elif condition0 == "cloudy" -%}
{{"\U00002601"}}
{%- elif condition0 == "partlycloudy" -%}
{{"\U000026C5"}}
{%- elif condition0 == "fog" -%}
{{"\U0001F32B"}}
{%- elif condition0 == "rainy" -%}
{{"\U0001F327"}}
{%- elif condition0 == "snowy-rainy" -%}
{{"\U0001F32B"}}
{%- elif condition0 == "lightning" -%}
{{"\U0001F329"}}
{%- elif condition0 == "lightning-rainy" -%}
{{"\U000026C8"}}
{%- elif condition0 == "clear-night" -%}
{{"\U0001F31D"}}
{%- elif condition0 == "windy" -%}
{{"\U0001F32C"}}
{%- elif condition0 == "windy-variant" -%}
{{"\U0001F32C"}}
{%- elif condition0 == "hail" -%}
{{"\U0001F9CA"}}
{%- elif condition0 == "pouring" -%}
{{"\U0001F4A7"}}
{%- else -%}
{{"\U0001F30C"}}
{%- endif -%}
{{as_timestamp(state_attr('weather.roquexavier','forecast')[0].datetime)|timestamp_custom('%A, %d %b')}} {{(state_attr('weather.roquexavier','forecast')[0].templow)}}ºC - {{(state_attr('weather.roquexavier','forecast')[0].temperature)}}ºC
{% if condition1 == "sunny" -%}
{{"\U00002600"}}
{%- elif condition1 == "partlycloudy" -%}
{{"\U000026C5"}}
{%- elif condition1 == "cloudy" -%}
{{"\U00002601"}}
{%- elif condition1 == "partlycloudy" -%}
{{"\U000026C5"}}
{%- elif condition1 == "fog" -%}
{{"\U0001F32B"}}
{%- elif condition1 == "rainy" -%}
{{"\U0001F327"}}
{%- elif condition1 == "snowy-rainy" -%}
{{"\U0001F32B"}}
{%- elif condition1 == "lightning" -%}
{{"\U0001F329"}}
{%- elif condition1 == "lightning-rainy" -%}
{{"\U000026C8"}}
{%- elif condition1 == "clear-night" -%}
{{"\U0001F31D"}}
{%- elif condition1 == "windy" -%}
{{"\U0001F32C"}}
{%- elif condition1 == "windy-variant" -%}
{{"\U0001F32C"}}
{%- elif condition1 == "hail" -%}
{{"\U0001F9CA"}}
{%- elif condition1 == "pouring" -%}
{{"\U0001F4A7"}}
{%- else -%}
{{"\U0001F30C"}}
{%- endif -%}
{{as_timestamp(state_attr('weather.roquexavier','forecast')[1].datetime)|timestamp_custom('%A, %d %b')}} {{(state_attr('weather.roquexavier','forecast')[1].templow)}}ºC - {{(state_attr('weather.roquexavier','forecast')[1].temperature)}}ºC
{% if condition2 == "sunny" -%}
{{"\U00002600"}}
{%- elif condition2 == "partlycloudy" -%}
{{"\U000026C5"}}
{%- elif condition2 == "cloudy" -%}
{{"\U00002601"}}
{%- elif condition2 == "partlycloudy" -%}
{{"\U000026C5"}}
{%- elif condition2 == "fog" -%}
{{"\U0001F32B"}}
{%- elif condition2 == "rainy" -%}
{{"\U0001F327"}}
{%- elif condition2 == "snowy-rainy" -%}
{{"\U0001F32B"}}
{%- elif condition2 == "lightning" -%}
{{"\U0001F329"}}
{%- elif condition2 == "lightning-rainy" -%}
{{"\U000026C8"}}
{%- elif condition2 == "clear-night" -%}
{{"\U0001F31D"}}
{%- elif condition2 == "windy" -%}
{{"\U0001F32C"}}
{%- elif condition2 == "windy-variant" -%}
{{"\U0001F32C"}}
{%- elif condition2 == "hail" -%}
{{"\U0001F9CA"}}
{%- elif condition2 == "pouring" -%}
{{"\U0001F4A7"}}
{%- else -%}
{{"\U0001F30C"}}
{%- endif -%}
{{as_timestamp(state_attr('weather.roquexavier','forecast')[2].datetime)|timestamp_custom('%A, %d %b')}} {{(state_attr('weather.roquexavier','forecast')[2].templow)}}ºC - {{(state_attr('weather.roquexavier','forecast')[2].temperature)}}ºC
{% if condition3 == "sunny" -%}
{{"\U00002600"}}
{%- elif condition3 == "partlycloudy" -%}
{{"\U000026C5"}}
{%- elif condition3 == "cloudy" -%}
{{"\U00002601"}}
{%- elif condition3 == "partlycloudy" -%}
{{"\U000026C5"}}
{%- elif condition3 == "fog" -%}
{{"\U0001F32B"}}
{%- elif condition3 == "rainy" -%}
{{"\U0001F327"}}
{%- elif condition3 == "snowy-rainy" -%}
{{"\U0001F32B"}}
{%- elif condition3 == "lightning" -%}
{{"\U0001F329"}}
{%- elif condition3 == "lightning-rainy" -%}
{{"\U000026C8"}}
{%- elif condition3 == "clear-night" -%}
{{"\U0001F31D"}}
{%- elif condition3 == "windy" -%}
{{"\U0001F32C"}}
{%- elif condition3 == "windy-variant" -%}
{{"\U0001F32C"}}
{%- elif condition3 == "hail" -%}
{{"\U0001F9CA"}}
{%- elif condition3 == "pouring" -%}
{{"\U0001F4A7"}}
{%- else -%}
{{"\U0001F30C"}}
{%- endif -%}
{{as_timestamp(state_attr('weather.roquexavier','forecast')[3].datetime)|timestamp_custom('%A, %d %b')}} {{(state_attr('weather.roquexavier','forecast')[3].templow)}}ºC - {{(state_attr('weather.roquexavier','forecast')[3].temperature)}}ºC
{% if condition4 == "sunny" -%}
{{"\U00002600"}}
{%- elif condition4 == "partlycloudy" -%}
{{"\U000026C5"}}
{%- elif condition4 == "cloudy" -%}
{{"\U00002601"}}
{%- elif condition4 == "partlycloudy" -%}
{{"\U000026C5"}}
{%- elif condition4 == "fog" -%}
{{"\U0001F32B"}}
{%- elif condition4 == "rainy" -%}
{{"\U0001F327"}}
{%- elif condition4 == "snowy-rainy" -%}
{{"\U0001F32B"}}
{%- elif condition4 == "lightning" -%}
{{"\U0001F329"}}
{%- elif condition4 == "lightning-rainy" -%}
{{"\U000026C8"}}
{%- elif condition4 == "clear-night" -%}
{{"\U0001F31D"}}
{%- elif condition4 == "windy" -%}
{{"\U0001F32C"}}
{%- elif condition4 == "windy-variant" -%}
{{"\U0001F32C"}}
{%- elif condition4 == "hail" -%}
{{"\U0001F9CA"}}
{%- elif condition4 == "pouring" -%}
{{"\U0001F4A7"}}
{%- else -%}
{{"\U0001F30C"}}
{%- endif -%}
{{as_timestamp(state_attr('weather.roquexavier','forecast')[4].datetime)|timestamp_custom('%A, %d %b')}} {{(state_attr('weather.roquexavier','forecast')[4].templow)}}ºC - {{(state_attr('weather.roquexavier','forecast')[4].temperature)}}ºC
inline_keyboard:
- "\U0001F3C3 Voltar:/visualization_telegram, \U0001F3C3 Sair:/exit"
###########################################################
## Menu Visualização Temperaturas & Humidade HA Telegram ##
###########################################################
#####Alterar chat_id#####
#####Alterar entidades das vossas VMs e Containers do Proxmox#####
visualization_vms_telegram:
alias: Visualization VM's HA Telegram
sequence:
- service: telegram_bot.edit_message
data_template:
message_id: last
chat_id: YOUR_CHAT_ID
message: |
{{"\U0001F5A5"}}Máquinas Virtuais{{"\U0001F5A5"}}
{% if is_state('binary_sensor.xavier_hassosova_4_13_running', 'on') -%}
{{"\U0001F7E2"}}HassOS - ON
{%- else -%}
{{"\U00002B55"}}HassOS - OFF{% endif %}
{% if is_state('binary_sensor.xavier_plexserver_running', 'on') -%}
{{"\U0001F7E2"}}Plex Server - ON
{%- else -%}
{{"\U00002B55"}}Plex Server - OFF{% endif %}
{% if is_state('binary_sensor.xavier_tuya_convert_running', 'on') -%}
{{"\U0001F7E2"}}Tuya Convert - ON
{%- else -%}
{{"\U00002B55"}}Tuya Convert - OFF{% endif %}
inline_keyboard:
- "\U0001F3C3 Voltar:/visualization_telegram, \U0001F3C3 Sair:/exit"
telegram_bot_password.yaml
script:
#######################################
## Script Menu para Inserir Password ##
#######################################
#####Alterar chat_id#####
insert_password_telegram:
alias: Insert Password HA Telegram
sequence:
- service: telegram_bot.edit_message
data_template:
message_id: last
chat_id: YOUR_CHAT_ID
message: "\U0001F510 Introduza a sua password?"
inline_keyboard:
- "\U0001F3C3 Voltar:/back, \U0001F3C3 Sair:/exit"
######################################
## Telegram_Bot_Password Validation ##
######################################
#####Alterar chat_id#####
password_validation_telegram:
alias: Password Validation HA Telegram
sequence:
- service: telegram_bot.delete_message
data:
message_id: last
chat_id: YOUR_CHAT_ID
- service: telegram_bot.send_message
data_template:
message: |
{{"\U0001F511"}}Validando Password.
- delay: 0.5
- service: telegram_bot.edit_message
data_template:
message_id: last
chat_id: YOUR_CHAT_ID
message: |
{{"\U0001F511"}}Validando Password .
- delay: 0.5
- service: telegram_bot.edit_message
data_template:
message_id: last
chat_id: YOUR_CHAT_ID
message: |
{{"\U0001F511"}}Validando Password .
- delay: 0.5
- service: telegram_bot.edit_message
data_template:
message_id: last
chat_id: YOUR_CHAT_ID
message: |
{{"\U0001F511"}}Validando Password.
- delay: 0.5
- service: telegram_bot.edit_message
data_template:
message_id: last
chat_id: YOUR_CHAT_ID
message: |
{{"\U0001F511"}}Validando Password .
- delay: 0.5
- service: telegram_bot.edit_message
data_template:
message_id: last
chat_id: YOUR_CHAT_ID
message: |
{{"\U0001F511"}}Validando Password .
- delay: 0.5
- service: telegram_bot.edit_message
data_template:
message_id: last
chat_id: YOUR_CHAT_ID
message: |
{{"\U0001F511"}}Validando Password.
telegram_bot_control
script:
##############################
## Menu Control HA Telegram ##
##############################
#####Alterar chat_id#####
#####Acrescentem ou retirem os menus do inline_keyboard que quiserem#####
control_telegram:
alias: Control HA Telegram
sequence:
- service: telegram_bot.edit_message
data_template:
message_id: last
chat_id: YOUR_CHAT_ID
message: "\U0001F4BB O que pretende controlar?"
inline_keyboard:
- "\U0001F4A1 Iluminação:/control_light_telegram"
- "\U0001F50C Tomadas:/control_socket_telegram"
- "\U0001F6E1 Alarme & Sensores:/control_alarm_telegram"
- "\U0001F3C3 Voltar:/back, \U0001F3C3 Sair:/exit"
#####################################
## Menu Controlo Luzes HA Telegram ##
#####################################
#####Alterar chat_id#####
#####Alterar cada entidade light.XXXX para uma entidade vossa dentro de cada {if -> endif}#####
#####Alterar no texto de cada if o nome da entidade a ser apresentada (ex:Candeeiro Hall R/C)#####
#####IMPORTANTE:No inline_keyboard, o nome do comando a ser enviado deve ser o mesmo nome do script#####
control_light_telegram:
alias: Control Light HA Telegram
sequence:
- service: telegram_bot.edit_message
data_template:
message_id: last
chat_id: YOUR_CHAT_ID
message: |
{{"\U0001F4A1"}}Iluminação{{"\U0001F4A1"}}
{% if is_state('light.candeeiro_hall_r_c', 'on') %}{{"\U0001F7E1"}}Candeeiro Hall R/C - {{states.light.candeeiro_hall_r_c.state}} | Ligado às {{as_timestamp(states.light.candeeiro_hall_r_c.last_updated)| timestamp_custom('%H:%M',True)}}{% else %}{{"\U00002B55"}}Candeeiro Hall R/C - {{states.light.candeeiro_hall_r_c.state}}{% endif %}
{% if is_state('light.candeeiro_margarida', 'on') %}{{"\U0001F7E1"}}Candeeiro Margarida - {{states.light.candeeiro_margarida.state}} | Ligado às {{as_timestamp(states.light.candeeiro_margarida.last_updated)| timestamp_custom('%H:%M',True)}}{% else %}{{"\U00002B55"}}Candeeiro Margarida - {{states.light.candeeiro_margarida.state}}{% endif %}
{% if is_state('light.candeeiro_mauricio', 'on') %}{{"\U0001F7E1"}}Candeeiro Maurício - {{states.light.candeeiro_mauricio.state}} | Ligado às {{as_timestamp(states.light.candeeiro_mauricio.last_updated)| timestamp_custom('%H:%M',True)}}{% else %}{{"\U00002B55"}}Candeeiro Maurício - {{states.light.candeeiro_mauricio.state}}{% endif %}
{% if is_state('switch.focos_suite', 'on') %}{{"\U0001F7E1"}}Focos Suíte - {{states.switch.focos_suite.state}} | Ligado às {{as_timestamp(states.switch.focos_suite.last_updated)| timestamp_custom('%H:%M',True)}}{% else %}{{"\U00002B55"}}Focos Suíte - {{states.switch.focos_suite.state}}{% endif %}
{% if is_state('light.bedside_lamp', 'on') %}{{"\U0001F7E1"}}Bedside Lamp - {{states.light.bedside_lamp.state}} | Ligado às {{as_timestamp(states.light.bedside_lamp.last_updated)| timestamp_custom('%H:%M',True)}}{% else %}{{"\U00002B55"}}Bedside Lamp - {{states.light.bedside_lamp.state}}{% endif %}
{% if is_state('light.candeeiro_maria', 'on') %}{{"\U0001F7E1"}}Candeeiro Maria - {{states.light.candeeiro_maria.state}} | Ligado às {{as_timestamp(states.light.candeeiro_maria.last_updated)| timestamp_custom('%H:%M',True)}}{% else %}{{"\U00002B55"}}Candeeiro Maria - {{states.light.candeeiro_maria.state}}{% endif %}
{% if is_state('light.aqara_hub', 'on') %}{{"\U0001F7E1"}}Aqara Hub - {{states.light.aqara_hub.state}} | Ligado às {{as_timestamp(states.light.aqara_hub.last_updated)| timestamp_custom('%H:%M',True)}}{% else %}{{"\U00002B55"}}Aqara Hub - {{states.light.aqara_hub.state}}{% endif %}
inline_keyboard:
- "\U0001F4A1Candeeiro Maurício:/candeeiro_mauricio_telegram, \U0001F4A1Candeeiro Margarida:/candeeiro_margarida_telegram"
- "\U0001F4A1Candeeiro Hall R/C:/candeeiro_hall_r_c_telegram, \U0001F4A1Candeeiro Maria:/candeeiro_maria"
- "\U0001F4A1Bedside Lamp:/bedside_lamp_telegram, \U0001F4A1Focos Suíte:/focos_suite_telegram, \U0001F4A1Aqara Hub:/aqara_hub_telegram"
- "\U0001F519 Voltar:/control_telegram,\U0001F504 Actualizar:/control_light_telegram, \U0001F3C3 Sair:/exit"
#######################################
## Menu Controlo Tomadas HA Telegram ##
#######################################
#####Alterar chat_id#####
#####Alterar cada entidade switch.XXXX para uma entidade vossa dentro de cada {if -> endif}#####
#####Alterar no texto de cada if o nome da entidade a ser apresentada (ex:Suíte)#####
#####IMPORTANTE:No inline_keyboard, o nome do comando a ser enviado deve ser o mesmo nome do script#####
control_socket_telegram:
alias: Control Socket HA Telegram
sequence:
- service: telegram_bot.edit_message
data_template:
message_id: last
chat_id: YOUR_CHAT_ID
message: |
{{"\U0001F50C"}}Tomadas{{"\U0001F50C"}}
{% if is_state('switch.tomada_suite', 'on') %}{{"\U000026A1"}}Suíte - {{states.switch.tomada_suite.state}} | Instantâneo - {{states.sensor.tomada_suite.state}} W{% else %}{{"\U0000274C"}}Suíte - {{states.switch.tomada_suite.state}}{% endif %}
{% if is_state('switch.tv_suite', 'on') %}{{"\U000026A1"}}TV Suíte - {{states.switch.tv_suite.state}} | Sem leituras{% else %}{{"\U0000274C"}}TV Suíte - {{states.switch.tv_suite.state}}{% endif %}
{% if is_state('switch.mibox_suite', 'on') %}{{"\U000026A1"}}MiBox Suíte - {{states.switch.mibox_suite.state}} | Sem leituras{% else %}{{"\U0000274C"}}MiBox Suíte - {{states.switch.mibox_suite.state}}{% endif %}
{% if is_state('switch.extra_suite', 'on') %}{{"\U000026A1"}}Extra Suíte - {{states.switch.extra_suite.state}} | Sem leituras{% else %}{{"\U0000274C"}}Extra Suíte - {{states.switch.extra_suite.state}}{% endif %}
{% if is_state('switch.tomada_francisco', 'on') %}{{"\U000026A1"}}Francisco - {{states.switch.tomada_francisco.state}} | Instantâneo - {{states.sensor.tomada_francisco.state}} W{% else %}{{"\U0000274C"}}Francisco - {{states.switch.tomada_francisco.state}}{% endif %}
{% if is_state('switch.sala', 'on') %}{{"\U000026A1"}}Sala - {{states.switch.sala.state}} | Sem leituras{% else %}{{"\U0000274C"}}Sala - {{states.switch.sala.state}}{% endif %}
{% if is_state('switch.arca', 'on') %}{{"\U000026A1"}}Arca - {{states.switch.arca.state}} | Sem leituras{% else %}{{"\U0000274C"}}Arca - {{states.switch.arca.state}}{% endif %}
{% if is_state('switch.maquina_secar', 'on') %}{{"\U000026A1"}}Máquina Secar - {{states.switch.maquina_secar.state}} | Sem leituras{% else %}{{"\U0000274C"}}Máquina Secar - {{states.switch.maquina_secar.state}}{% endif %}
{% if is_state('switch.termoacumulador', 'on') %}{{"\U000026A1"}}Termoacumulador - {{states.switch.termoacumulador.state}} | Instantâneo - {{states.sensor.tomada_termoacumulador_instantaneo.state}} W{% else %}{{"\U0000274C"}}Termoacumulador - {{states.switch.termoacumulador.state}}{% endif %}
{% if is_state('switch.maquina_roupa', 'on') %}{{"\U000026A1"}}Máquina Roupa - {{states.switch.maquina_roupa.state}} | Instantâneo - {{states.sensor.maquina_da_roupa.state}} W{% else %}{{"\U0000274C"}}Máquina Roupa - {{states.switch.maquina_roupa.state}}{% endif %}
inline_keyboard:
- "\U0001F50CSuíte:/tomada_suite_telegram, \U0001F50CTV Suíte:/tomada_tv_suite_telegram, \U0001F50CMiBox:/tomada_mibox_telegram, \U0001F50CExtra:/tomada_extra_suite_telegram"
- "\U0001F50CSala:/tomada_sala_telegram, \U0001F50CFrancisco:/tomada_francisco_telegram, \U0001F50CTermoacumulador:/tomada_termoacumulador_telegram"
- "\U0001F50CArca:/tomada_arca_telegram, \U0001F50CMáq. Roupa:/tomada_maquina_roupa_telegram, \U0001F50C Máq. Secar:/tomada_maquina_secar_telegram"
- "\U0001F519 Voltar:/control_telegram,\U0001F504 Actualizar:/control_socket_telegram, \U0001F3C3 Sair:/exit"
#######################################
## Menu Controlo Alarme HA Telegram ##
#######################################
control_alarm_telegram:
alias: Control Alarm HA Telegram
sequence:
- service: telegram_bot.edit_message
data_template:
message_id: last
chat_id: YOUR_CHAT_ID
message: |
{{"\U0001F6E1"}}Alarme{{"\U0001F6E1"}}
{% if is_state('alarm_control_panel.aqara_hub', 'disarmed') %}{{"\U0001F6A8"}}Alarme - {{states.alarm_control_panel.aqara_hub.state}}{% else %}{{"\U0000146E"}}Alarme - {{states.alarm_control_panel.aqara_hub.state}}{% endif %}
inline_keyboard:
- "\U0001F50CArmar:/arm_alarm, \U0001F50CDesarmar:/disarm_alarm"
- "\U0001F519 Voltar:/control_telegram,\U0001F504 Actualizar:/control_alarm_telegram, \U0001F3C3 Sair:/exit"
telegram_bot_control_lights.yaml
script:
#####Criar um script por cada entidade a controlar#####
#####IMPORTANTE:Nome do script deve ser igual ao inline_keyboard do menu control#####
#####Adicionem as lâmpadas que quiserem e respectivos botões no script control_light_telegram#####
#####Alterar entidades para as vossas lights#####
###########################################
## Toggle Candeeiro Maurício HA Telegram ##
###########################################
candeeiro_mauricio_telegram:
alias: Control Candeeiro Maurício HA Telegram
sequence:
- service: light.toggle
target:
entity_id: light.candeeiro_mauricio
- service: script.control_light_telegram
############################################
## Toggle Candeeiro Margarida HA Telegram ##
############################################
candeeiro_margarida_telegram:
alias: Control Candeeiro Margarida HA Telegram
sequence:
- service: light.toggle
target:
entity_id: light.candeeiro_margarida
- service: script.control_light_telegram
#####################################
## Toggle Bedside Lamp HA Telegram ##
#####################################
bedside_lamp_telegram:
alias: Control Bedside Lamp HA Telegram
sequence:
- service: light.toggle
target:
entity_id: light.bedside_lamp
- service: script.control_light_telegram
################################################
## Toggle Candeeiro Hall R/C Lamp HA Telegram ##
################################################
candeeiro_hall_r_c_telegram:
alias: Control Candeeiro Hall R/C HA Telegram
sequence:
- service: light.toggle
target:
entity_id: light.candeeiro_hall_r_c
- service: script.control_light_telegram
####################################
## Toggle Focos Suíte HA Telegram ##
####################################
focos_suite_telegram:
alias: Control Focos Suíte HA Telegram
sequence:
- service: switch.toggle
target:
entity_id: switch.focos_suite
- service: script.control_light_telegram
##################################
## Toggle Aqara Hub HA Telegram ##
##################################
aqara_hub_telegram:
alias: Control Aqara Hub Telegram
sequence:
- service: light.toggle
target:
entity_id: light.aqara_hub
- service: script.control_light_telegram
telegram_control_sockets.yaml
script:
#####Criar um script por cada entidade a controlar#####
#####IMPORTANTE:Nome do script deve ser igual ao inline_keyboard do menu control#####
#####Adicionem as tomadas que quiserem e respectivos botões no script control_socket_telegram#####
#####Alterar entidades para os vossos switchs#####
#####################################
## Toggle Tomada Suíte HA Telegram ##
#####################################
tomada_suite_telegram:
alias: Control Tomada Suíte HA Telegram
sequence:
- service: switch.toggle
target:
entity_id: switch.tomada_suite
- service: script.control_socket_telegram
########################################
## Toggle Tomada TV Suíte HA Telegram ##
########################################
tomada_tv_suite_telegram:
alias: Control Tomada TV Suíte HA Telegram
sequence:
- service: switch.toggle
target:
entity_id: switch.tv_suite
- service: script.control_socket_telegram
#####################################
## Toggle Tomada Mibox HA Telegram ##
#####################################
tomada_mibox_telegram:
alias: Control Tomada Mibox HA Telegram
sequence:
- service: switch.toggle
target:
entity_id: switch.mibox_suite
- service: script.control_socket_telegram
###########################################
## Toggle Tomada Extra Suite HA Telegram ##
###########################################
tomada_extra_suite_telegram:
alias: Control Tomada Extra Suíte HA Telegram
sequence:
- service: switch.toggle
target:
entity_id: switch.extra_suite
- service: script.control_socket_telegram
####################################
## Toggle Tomada Sala HA Telegram ##
####################################
tomada_sala_telegram:
alias: Control Tomada Sala HA Telegram
sequence:
- service: switch.toggle
target:
entity_id: switch.sala
- service: script.control_socket_telegram
####################################
## Toggle Tomada Arca HA Telegram ##
####################################
tomada_arca_telegram:
alias: Control Tomada Arca Telegram
sequence:
- service: switch.toggle
target:
entity_id: switch.arca
- service: script.control_socket_telegram
#############################################
## Toggle Tomada Máquina Secar HA Telegram ##
#############################################
tomada_maquina_secar_telegram:
alias: Control Tomada Máquina Secar Hub Telegram
sequence:
- service: switch.toggle
target:
entity_id: switch.maquina_secar
- service: script.control_socket_telegram
#############################################
## Toggle Tomada Máquina Roupa HA Telegram ##
#############################################
tomada_maquina_roupa_telegram:
alias: Control Máquina Roupa Telegram
sequence:
- service: switch.toggle
target:
entity_id: switch.maquina_roupa
- service: script.control_socket_telegram
#########################################
## Toggle Tomada Francisco HA Telegram ##
#########################################
tomada_francisco_telegram:
alias: Control Tomada Francisco Telegram
sequence:
- service: switch.toggle
target:
entity_id: switch.tomada_francisco
- service: script.control_socket_telegram
###############################################
## Toggle Tomada termoacumulador HA Telegram ##
###############################################
tomada_termoacumulador_telegram:
alias: Control Tomada Termoacumulador Telegram
sequence:
- service: switch.toggle
target:
entity_id: switch.termoacumulador
- service: script.control_socket_telegram
telegram_bot_new_speedtest.yaml
script:
####################
## Novo SpeedTest ##
####################
#####Ter integração speed test no HA#####
#####Alterar chat_id#####
#####Alterar as vossas 3 entidades da integração speedtest (download, upload, ping#####
new_speedtest_telegram:
alias: New SpeedTest Validation HA Telegram
sequence:
- service: homeassistant.update_entity
entity_id:
- sensor.speedtest_download
- sensor.speedtest_upload
- sensor.speedtest_ping
- service: telegram_bot.edit_message
data_template:
message_id: last
chat_id: YOUR_CHAT_ID
message: |
{{"\U0001F310"}}A efectuar ligação ao servidor{{"\U0001F310"}}
{{"\U0001F4BB"}}{{"\U0000231B"}}
- delay: 2
- service: telegram_bot.edit_message
data_template:
message_id: last
chat_id: YOUR_CHAT_ID
message: |
{{"\U0001F310"}}Novo teste em curso{{"\U0001F310"}}
{{"\U0001F4BB"}}{{"\U00002709"}}
- delay: 0.5
- service: telegram_bot.edit_message
data_template:
message_id: last
chat_id: YOUR_CHAT_ID
message: |
{{"\U0001F310"}}Novo teste em curso{{"\U0001F310"}}
{{"\U0001F4BB"}} {{"\U00002709"}}
- delay: 0.5
- service: telegram_bot.edit_message
data_template:
message_id: last
chat_id: YOUR_CHAT_ID
message: |
{{"\U0001F310"}}Novo teste em curso{{"\U0001F310"}}
{{"\U0001F4BB"}} {{"\U00002709"}}
- delay: 0.5
- service: telegram_bot.edit_message
data_template:
message_id: last
chat_id: YOUR_CHAT_ID
message: |
{{"\U0001F310"}}Novo teste em curso{{"\U0001F310"}}
{{"\U0001F4BB"}} {{"\U00002709"}}
- delay: 0.5
- service: telegram_bot.edit_message
data_template:
message_id: last
chat_id: YOUR_CHAT_ID
message: |
{{"\U0001F310"}}Novo teste em curso{{"\U0001F310"}}
{{"\U0001F4BB"}}{{"\U00002709"}}
- delay: 0.5
- service: telegram_bot.edit_message
data_template:
message_id: last
chat_id: YOUR_CHAT_ID
message: |
{{"\U0001F310"}}Novo teste em curso{{"\U0001F310"}}
{{"\U0001F4BB"}} {{"\U00002709"}}
- delay: 0.5
- service: telegram_bot.edit_message
data_template:
message_id: last
chat_id: YOUR_CHAT_ID
message: |
{{"\U0001F310"}}Novo teste em curso{{"\U0001F310"}}
{{"\U0001F4BB"}} {{"\U00002709"}}
- delay: 0.5
- service: telegram_bot.edit_message
data_template:
message_id: last
chat_id: YOUR_CHAT_ID
message: |
{{"\U0001F310"}}Novo teste em curso{{"\U0001F310"}}
{{"\U0001F4BB"}} {{"\U00002709"}}
- delay: 0.5
- service: telegram_bot.edit_message
data_template:
message_id: last
chat_id: YOUR_CHAT_ID
message: |
{{"\U0001F310"}}Novo teste em curso{{"\U0001F310"}}
{{"\U0001F4BB"}}{{"\U00002709"}}
- delay: 0.5
- service: telegram_bot.edit_message
data_template:
message_id: last
chat_id: YOUR_CHAT_ID
message: |
{{"\U0001F310"}}Novo teste em curso{{"\U0001F310"}}
{{"\U0001F4BB"}} {{"\U00002709"}}
- delay: 0.5
- service: telegram_bot.edit_message
data_template:
message_id: last
chat_id: YOUR_CHAT_ID
message: |
{{"\U0001F310"}}Novo teste em curso{{"\U0001F310"}}
{{"\U0001F4BB"}} {{"\U00002709"}}
- delay: 0.5
- service: telegram_bot.edit_message
data_template:
message_id: last
chat_id: YOUR_CHAT_ID
message: |
{{"\U0001F310"}}Novo teste em curso{{"\U0001F310"}}
{{"\U0001F4BB"}} {{"\U00002709"}}
- delay: 0.5
- service: telegram_bot.edit_message
data_template:
message_id: last
chat_id: YOUR_CHAT_ID
message: |
{{"\U0001F310"}}Teste Concluído{{"\U0001F310"}}
{{"\U0001F4BB"}}{{"\U00002705"}}
- delay: 2
- service: script.visualization_speedtest_telegram
telegram_bot_notify.yaml
script:
####################################
## Telegram_Bot_Consumos diários ##
####################################
#####Fora do contexto do Homie Bot. Envia apenas um relatório diário dos consumos diário, semanal e mensal e diferenças para os períodos anteriores#####
#####Alterar entidades a enviar o relatório diário#####
information_consumptions_ha_telegram:
alias: Information Consumption Telegram
sequence:
- service: telegram_bot.send_message
data_template:
message: |
{{"\U000026A1"}}Consumos - Informação diária{{"\U000026A1"}}
{{"\U0001F6CF"}}Suíte{{"\U0001F6CF"}}
Dia: {{states.sensor.consumo_diario_suite.state}} ({{(states.sensor.consumo_diario_suite.state | float - states.sensor.consumo_diario_suite.attributes.last_period | float) | round(2)}}) kWh
Semana: {{states.sensor.consumo_semanal_suite.state}} ({{(states.sensor.consumo_semanal_suite.state | float - states.sensor.consumo_semanal_suite.attributes.last_period | float) | round(2)}}) kWh
Mês: {{states.sensor.consumo_mensal_suite.state}} ({{(states.sensor.consumo_mensal_suite.state | float - states.sensor.consumo_mensal_suite.attributes.last_period | float) | round(2)}}) kWh
Total: {{states.sensor.consumo_suite.state}} kWh
{{"\U0001F645"}}Q. Francisco{{"\U0001F645"}}
Dia: {{states.sensor.consumo_diario_aquecedor_francisco.state}} ({{(states.sensor.consumo_diario_aquecedor_francisco.state | float - states.sensor.consumo_diario_aquecedor_francisco.attributes.last_period | float) | round(2)}}) kWh
Semana: {{states.sensor.consumo_semanal_aquecedor_francisco.state}} ({{(states.sensor.consumo_semanal_aquecedor_francisco.state | float - states.sensor.consumo_semanal_aquecedor_francisco.attributes.last_period | float) | round(2)}}) kWh
Mês: {{states.sensor.consumo_mensal_aquecedor_francisco.state}} ({{(states.sensor.consumo_mensal_aquecedor_francisco.state | float - states.sensor.consumo_mensal_aquecedor_francisco.attributes.last_period | float) | round(2)}}) kWh
Total: {{states.sensor.consumo_francisco.state}} kWh
{{"\U00002668"}}Termoacumulador{{"\U00002668"}}
Dia: {{states.sensor.consumo_diario_termoacumulador.state}} ({{(states.sensor.consumo_diario_termoacumulador.state | float - states.sensor.consumo_diario_termoacumulador.attributes.last_period | float) | round(2)}}) kWh
Semana: {{states.sensor.consumo_semanal_termoacumulador.state}} ({{(states.sensor.consumo_semanal_termoacumulador.state | float - states.sensor.consumo_semanal_termoacumulador.attributes.last_period | float) | round(2)}}) kWh
Mês: {{states.sensor.consumo_mensal_termoacumulador.state}} ({{(states.sensor.consumo_mensal_termoacumulador.state | float - states.sensor.consumo_mensal_termoacumulador.attributes.last_period | float) | round(2)}}) kWh
Total: {{states.sensor.consumo_termoacumulador.state}} kWh
{{"\U0001F455"}}Máquina Roupa{{"\U0001F455"}}
Dia: {{states.sensor.consumo_diario_maquina_roupa.state}} ({{(states.sensor.consumo_diario_maquina_roupa.state | float - states.sensor.consumo_diario_maquina_roupa.attributes.last_period | float) | round(2)}}) kWh
Semana: {{states.sensor.consumo_semanal_maquina_roupa.state}} ({{(states.sensor.consumo_semanal_maquina_roupa.state | float - states.sensor.consumo_semanal_maquina_roupa.attributes.last_period | float) | round(2)}}) kWh
Mês: {{states.sensor.consumo_mensal_maquina_roupa.state}} ({{(states.sensor.consumo_mensal_maquina_roupa.state | float - states.sensor.consumo_mensal_maquina_roupa.attributes.last_period | float) | round(2)}}) kWh
Total: {{states.sensor.consumption_31.state}} kWh
Espero que gostem e que também vos seja útil.
A mim deu imenso prazer fazer isto. Aprendi algo novo (não trabalhava sequer com telegram e como podem ver aproveitei e coloquei as notificações personalizadas) e confesso que com o tempo até tenho usado bastante o bot para coisas rápidas.
A password foi só para tornar engraçado, se quiserem podem tirar.
Obrigado pela vossa atenção e se gostarem deixem um voto no meu projecto!