Some I put as custom message and some I put as call. I this it is depend, but both works.
The automation can make janet to inform you without asking in certain condition like event after work auotmation that Mr. Lentron has provided.
I have recently, use conversation to ask janet also, I feel like both way communication and I love it so much.
Then I just register telegram bot polly and since I have conversation added already. I can text via telegram bot to inform me the status of the house that I put in conversation.
I use this guide to communicate between telegram bot to home assistant to turn on-off light, switch whatever I want. This guide is so useful.
Extra automation skill to greet people that are back home.
- alias: Sun Greeting
trigger:
- platform: state
entity_id: device_tracker.suniphone
from: 'not_home'
to: 'home'
for: '00:01:00'
action:
- wait_template: >-
{{ not is_state('media_player.ha_speaker', 'playing') }}
- service: script.speech_engine
data_template:
personarriving: >
{% set person = "Sun" %} # original setting is to read from device_tracker. but mine device_tracker name is long and sound strange # {% set person = trigger.entity_id.split('.')[1]|replace('_', ' ')%}
{%- macro greeting_sentence(person) -%}
{{ [
"Welcome back home " ~ person,
"Guess who is home " ~ person + " is!",
person + " is now in the house.",
"Welcome Home " ~ person + ". We have missed you. Or at least I did.",
"Our home is now complete, Rest your head and relax your feet Welcome Back " ~ person,
"Life is like a song, you’re back where you belong, Welcome home " ~ person,
"Hey there " ~ person + " Welcome Home!",
"Knock Knock. Who is There " ~ person + " is!",
person ~ " You are home!",
"I know a secret " ~ person + " is home!"
] | random }}
{%- endmacro -%}
{{greeting_sentence(person)}}
call_no_announcement: 1
- alias: My Family Location
trigger:
- platform: state
entity_id: input_boolean.whoishome_status
from: 'off'
to: 'on'
action:
- wait_template: >-
{{ not is_state('media_player.ha_speaker', 'playing') }}
- service: script.speech_engine
data_template:
whoishome: >
{%- if is_state('device_tracker.suniphone', 'home') and is_state('device_tracker.dianaiphone', 'home') -%}
You are both home.
{%- else -%}
Diana is at {{ states("sensor.diana_open_street_map") }} and Sun is at {{ states("sensor.sun_open_street_map") }} .
{% endif %}
call_no_announcement: 1
call_bye: 1
- delay: 00:00:15
- service: input_boolean.turn_off
entity_id: input_boolean.whoishome_status
{%- macro security_check() -%}
S1C alarm status is {{ states('sensor.key_fob') }}. SSH alarm status is {{ states('alarm_control_panel.ssh') }}. Office camera motion status is {{ states('switch.office_camera_motion') }} and office camera record status is {{ states('switch.office_camera_alarm') }}.
{%- endmacro -%}
{% if call_security_check == 1 %}
{{ security_check() }}
{% endif %}
- alias: System Status
trigger:
- platform: state
entity_id: input_boolean.system_status
from: 'off'
to: 'on'
action:
- wait_template: >-
{{ not is_state('media_player.ha_speaker', 'playing') }}
- service: script.speech_engine
data:
call_greeting: 1
call_inform: 1
call_system_check: 1
call_no_announcement: 1
call_bye: 1
- delay: 00:00:15
- service: input_boolean.turn_off
entity_id: input_boolean.system_status
speech_engine
{%- macro system_check() -%}
CPU temperature is {{ states('sensor.cpu_temp') }} °C. Processor is running at {{ states('sensor.processor_use') }} %. Memory used is {{ states('sensor.memory_use_percent') }} %. Disk used is {{ states('sensor.disk_use_percent_') }} % and your last reboot is {{ states('sensor.ha_last_reboot') }}.
{%- endmacro -%}
{% if call_system_check == 1 %}
{{ system_check() }}
{% endif %}
- alias: Home Assistant Status
trigger:
- platform: state
entity_id: input_boolean.homeassistant_status
from: 'off'
to: 'on'
action:
- wait_template: >-
{{ not is_state('media_player.ha_speaker', 'playing') }}
- service: script.speech_engine
data:
call_greeting: 1
call_inform: 1
call_homeassistant_check: 1
call_no_announcement: 1
call_bye: 1
- delay: 00:00:15
- service: input_boolean.turn_off
entity_id: input_boolean.homeassistant_status
speech_engine
Home Assistant installed version is {{ states('sensor.installed_ha_version') }}. Database size is {{ states('sensor.ha_db_size') }} Megabytes. Uptime running is {{ states('sensor.ha_uptime') }}. SSL certificate is expiring in {{ states('sensor.ssl_cert_expiry') }} days and currently {{ states('sensor.connected_clients') }} clients are connected to Home Assistant.
{%- endmacro -%}
{% if call_homeassistant_check == 1 %}
{{ homeassistant_check() }}
{% endif %}
For telegram I use this guide. Once you know you can create your own text (not command) to home assistant, also conversation (shopping list).
For turn on and turn off you can you from the share project below.
For other than turn on/ turn off. I can give you example below.
########################################################
## Telegram Bot Polly ‘Bye’ to Janet ##
########################################################
##################################################
## Automation - Bye
##################################################
automation:
- alias: "Telegram Bot Bye"
trigger:
platform: event
event_type: telegram_text
event_data:
text: 'Bye'
action:
- service: conversation.process
data_template:
text: '{{ trigger.event.data.text }}'
##################################################
## conversation.yaml
##################################################
conversation:
intents:
ByeIntent:
- Bye
- Thank you
- Done
- Finish
- No thank you
##################################################
## intent_script.yaml
##################################################
intent_script:
ByeIntent:
speech:
type: plain
text: Good friends never say goodbye, they simply say see you soon!
action:
service: script.speech_engine
data:
call_bye: 1
############################################################
## script.speech_engine (Janet) For Bye Macro and call_bye
############################################################
{%- macro bye() -%}
{% set bye = [
"How lucky I am to have something that makes saying Goodbye so hard. ",
"Good friends never say goodbye, they simply say: see you soon! "
] %}
{{ bye | random }}
{%- endmacro -%}
{% if call_bye == 1 %}
{{ bye() }}
{% endif %}
Turn on and turn off from telegram is call from the group you create to turn on and off. So check the devices in the group you want to turn on and off.
Hi
This is a great project
I am a newcomer
I tried to do and followed the steps above
But when I call the translation, the file sjon error
someone help me please