im also trying this, my config check shows no errors, but I cant hear any sound or receive notifications.
i use mopidy for sounds right now.
Am I missing something?
Script.yaml
janet_speech_engine:
sequence:
- service: script.janet_notification_hub
data_template:
#TODO
media_player: >-
{%- for device in states.media_player -%}
{%- if media_player.fire_speaker == states.input_select.janet_notification_media_player.state -%}
{{ media_player.fire_speaker }}
{%- endif -%}
{%- endfor -%}
speech_message: >-
{%- macro greeting() -%}
{% set greeting = [
"Hello, ",
"Heya! ",
"Hey Guys! ",
"Hey there! ",
"Hi, ",
"Hi there, "
] %}
{{ greeting|random }}
{%- endmacro -%}
{%- macro inform() -%}
{% set inform = [
"I just want to inform you that ",
"I just want to let you know that ",
"You asked me to inform you when ",
"I thought you'd like to know that "
] %}
{{ inform|random }}
{%- endmacro -%}
{%- macro introduction() -%}
{% set introduction = [
"I'm an informational delivery system, I literraly know everything. ",
"I'm sort of the janitor around here. ",
"I'm like a walking database. You can ask me about the creation of the universe... or history. ",
"Every time a Janet is rebooted, she increases her social awareness and abilities. I might be the most advanced Janet in the universe. ",
"I can be your therapist if you want. ",
"I have now been fully activated. ",
"Welcome to your new Janet. Janets are brought to you by the makers of light, darkness, and everything. ",
"To activate your Janet, press nose for three seconds. ",
"I'm very high in potassium. Like a banana! ",
"Happy to meet you. I will help you make the perfect neighborhood. Would you like to get started? ",
"I build and operate the neighborhood. You can ask me anything. For example, if you'd like me to stop calling you silly billy, just say so. "
] %}
I'm Janet. {{ introduction | random }}
{%- endmacro -%}
{%- macro unknown() -%}
{% set unknown = [
"Hmm, I don't know ",
"I wish I knew ",
"My programming prohibits me from telling you "
] %}
{{ unknown | random }}
{%- endmacro -%}
{%- macro error() %}
{% set error = [
"Fun fact: Janet is me! ",
"I don't understand. Given the situation it's far safer to initiate the self-destruct. ",
"If I stand next to a powerful array of magnets, I do get pretty loopy. ",
"I don't know what just happened, but I'm happy you're happy. ",
"A new Janet will need to be procured in order to return the Neighborhood to functionality. ",
"That glitch appears to have been limited to this building. ",
"I don't seem to be getting better. ",
"Here's a cactus! ",
"I tried to eat frozen yogurt. It looked so good, but I'm not supposed to eat anything, so there was a little earthquake. ",
"Look at us. Couple old pals, trying to make our way in this crazy world... that I built... Two peas in a pod. One of whom needs to kill the other one immediately. Come on. Kill me! ",
"What I really want is to stay and serve the neighborhood, but due to my glitching I'm putting him and everyone else at risk. So it looks like it's... Adios, Janeto! ",
"I know what you have to do now. Kill me! Sorry. I say everything in a cheery manner but in this case it may be inappropriate, so I'll try again. You have to kill me. ",
"Hi guys! I'm broken! ",
"Please don't make a big deal about turning me into a marble forever, i'm broken. ",
"Does not compute. Does not compute. I'm just kidding. I mean, it doesn't compute, but I'm not gonna explode or anything. "
] %}
{{ error | random }}
{%- endmacro -%}
{%- macro update() -%}
{% set update = [
"There have been 25 generation of Janet. Each new update of Janet gains more wisdom and social abilities. Fun fact: the first Janet had a clicking wheel! ",
"I read all Google's eight hundred and sixty one thousand references on Home Assistant these last 3 milliseconds, and I found some new skills! ",
"I just leisurely reread all of human history, there was even some new content! ",
"So I found an update. That's the good news. The bad news is I seem to be losing my ability to sustain object permanence, so it's sort of a glass-half-full, glass-stops-existing-in-time-and-space kinda deal. "
] %}
{{ update | random }}
{%- endmacro -%}
{%- macro location_not_home() -%}
{% set not_home = [
" is going somewhere. ",
" is currently not in this neighbourhood. ",
"'s location is not in my database. "
] %}
{{ not_home | random }}
{%- endmacro -%}
{%- macro location_inquiry( person, not_home ) -%}
{%- for device in states.device_tracker -%}
{%- if device.name == person -%}
{%- set location = device.state -%}
{% if location == "not_home" %}
{{ person }} {{ not_home }}
{%- else -%}
{{ person }} is at {{ location }}.
{%- endif -%}
{%- endif -%}
{%- endfor -%}
{%- endmacro -%}
{%- macro bad_weather() -%}
{% set rain = [
" You might want to change your schedule. ",
" Maybe you should ask for a ride. ",
" It's no weather to be outside. ",
" All those poor people outside... "
] %}
{{ rain | random }}
{%- endmacro -%}
{%- macro rain_warning( bad_weather ) -%}
{% set rain = [
Event ~ " there will be " ~ WeatherRain ~ " rain. " ,
Event ~ " I predict " ~ WeatherRain ~ " rain. ",
" I think that " ~ Event ~ " there will be " ~ WeatherRain ~ " rain. "
] %}
{{ rain | random }}{{ bad_weather }}
{%- endmacro -%}
{%- macro okay()-%}
{% set okay = [
"Done! I love you guys. ",
"Extraordinarily bad idea. Oh well.. ",
"Funny, I was just about to do that. ",
"Here you go. ",
"I'll do that. ",
"Ofcourse! ",
"Ofcourse! Glad to help. ",
"Of course, silly billy. ",
"OK ",
"Okay ",
"Okay, can we not do this in front of my friends? ",
"Okie-dokie ",
"Sure ",
"Sure thing! ",
"There. Happy to help. ",
"There you go! ",
"Okay. I've hacked into the mainframe. ",
"Okay. I've hacked into the mainframe. Kidding. I can't hack into the mainframe. Technically, I am the mainframe. ",
"I will not. It is literally impossible for me to do that. Just kidding. ",
"I couldn't do this 800 reboots ago, but apparently now I can. "
"Yup. Bye! "
] %}
{{ okay|random }}
{%- endmacro -%}
{%- macro bye() -%}
{% set bye = [
"Adios! ",
"Bye Guys! ",
"See ya! " ,
"See you later. ",
"Untill next time!"
] %}
{{ bye | random }}
{%- endmacro -%}
{%- macro shut_down() -%}
{% set shut_down = [
"I'll be gone, you'll get a new Janet, and everything will go back to normal. Well, not for me, I'll be a lifeless marble floating through space, but you will be back to normal.",
"Self-destruct time... Don't worry, I won't feel any pain or anything. ",
"If it's okay with you, I'm gonna go to my void for a little while. I just need to spend some time alone and focus on myself. ",
"Shutting down. I'll be about as dead as I can be. Kind of like I'm in power-saver mode. ",
"I'm in danger of total collapse. Fun fact! Mathematically, I'm equally likely to either implode or explode. "
] %}
{{ shut_down | random }}
{%- endmacro -%}
{% set chance = states.input_number.janet_notification_witty.state | round %}
{%- macro witty( sentence, witty ) -%}
{% set number = (range(0, 100)|random) %}
{% if number <= chance %}
{{ sentence }}
{% endif %}
{%- endmacro -%}
{%- macro new_device( introduction ) -%}
{% set new_device = [
introduction~"I don't know your name yet, so for now i will call you "~person,
"We have a visitor! Nice to meet you "~person~". "~introduction,
"Welcome "~person~"! Or is that not your real name? "~introduction
] %}
{{ new_device | random }}
{%- endmacro -%}
{# ********************************************* #}
{# ******** Start the Speech routines ******** #}
{# ********************************************* #}
{% if call_greeting == 1 %}
{{ greeting() }}
{% endif %}
{% if call_introduction == 1 %}
{{ introduction() }}
{% endif %}
{% if call_update == 1 %}
{{ update() }}
{% endif%}
{% if call_okay == 1 %}
{{ okay () }}
{% endif %}
{% if call_inform == 1 %}
{{ inform() }}
{% endif %}
{% if call_location_inquiry == 1 %}
{% set location = location_inquiry( person, location_not_home() ) %}
{% set count = location | length %}
{% if count <= 10 %}
{{ unknown() }}where {{ person }} is. {{ witty( error(), chance ) }}
{% else %}
{{ location }}
{% endif %}
{% endif %}
{% if call_rain_warning == 1 %}
{{ rain_warning( witty ( bad_weather(), chance ) ) }}
{% endif %}
{{ CustomMessage }}
{% if call_bye == 1 %}
{{ bye() }}
{% endif %}
{% if call_shut_down == 1 %}
{{ witty( shut_down(), chance) }}
{% endif %}
{% if call_new_device == 1 %}
{{ new_device( witty( introduction(), chance) ) }}
{% endif %}
- service: input_boolean.turn_off
data:
entity_id:
- input_boolean.janet_alert_mode
######################################################################################################
## janet_notification_hub is the bridge between the speech_engine and the processing units. ##
######################################################################################################
janet_notification_hub:
sequence:
- service: script.janet_speech_processing
data_template:
media_player: >-
{{ media_player.fire_speaker }}
speech_message: >-
{{ speech_message }}
- service: script.janet_text_processing
data_template:
speech_message: >-
{{ speech_message }}
######################################################################################################
## Within janet_speech_processing the TTS-service is called. ##
######################################################################################################
janet_speech_processing:
sequence:
- condition: and
conditions:
- condition: or
conditions:
- condition: time
after: '07:00:00'
before: '23:00:00'
- condition: state
entity_id: input_boolean.janet_alert_mode
state: 'on'
- condition: state
entity_id: input_boolean.janet_speech_notifications
state: 'on'
- condition: or
conditions:
- condition: state
#TODO
entity_id: group.location
state: 'home'
- condition: state
entity_id: input_boolean.janet_guest_mode
state: 'on'
#TODO
- wait_template: "{{ not is_state( media_player.fire_speaker, 'playing') }}"
timeout: 00:00:30
- service: media_player.volume_set
data_template:
entity_id: >
{{ media_player.fire_speaker }}
volume_level: >-
{{ states.input_number.janet_notification_volume.state }}
- service: tts.google_say
data_template:
entity_id: >
{{ media_player.fire_speaker }}
message: >-
{{ speech_message | replace("\n","") | replace(" ","") | replace(" "," ") }}
######################################################################################################
## Within janet_text_processing the notify-service is called. ##
######################################################################################################
janet_text_processing:
sequence:
- condition: state
entity_id: input_boolean.janet_text_notifications
state: 'on'
- service: notify.Janet
data_template:
#TODO
title: "Janet:"
message: >-
{{ speech_message | replace("\n","") | replace(" ","") |
replace("eight hundred and sixty one thousand","861.000") }}
group.yaml
janet_settings:
name: Settings
view: yes
icon: mdi:tune
entities:
- group.janet_notification_modes
- group.janet_notification_notifications
- group.janet_notification_settings
- group.janet_notification_skills
janet_notification_modes:
name: Modes
entities:
- input_boolean.janet_guest_mode
- input_boolean.janet_alert_mode
janet_notification_notifications:
name: Notifications
entities:
- input_boolean.janet_speech_notifications
- input_boolean.janet_text_notifications
janet_notification_settings:
name: Settings
entities:
- input_select.janet_notification_media_player
- input_number.janet_notification_volume
- input_number.janet_notification_witty
janet_notification_skills:
name: Skills
entities:
- automation.janet_new_device_connected
- automation.janet_update_available
- automation.janet_start_up
- automation.janet_shut_down
input_boolean.yaml
janet_guest_mode:
name: Guest Mode
icon: mdi:account-multiple
initial: off
janet_alert_mode:
name: Alert Mode
icon: mdi:bell
initial: off
janet_speech_notifications:
name: Speech Notifications
icon: mdi:bell-outline
initial: on
janet_text_notifications:
name: Text Notifications
icon: mdi:message-text-outline
initial: on
input_number.yaml
janet_notification_volume:
name: Volume
icon: mdi:volume-high
min: 0.0
max: 1.0
step: 0.01
initial: 1.0
janet_notification_witty:
name: Witty
icon: mdi:auto-fix
min: 0
max: 100
step: 1
initial: 80
input_select.yaml
janet_notification_media_player:
name: Source
icon: mdi:speaker
options:
- media_player.fire_speaker
- MPD
initial: media_player.fire_speaker
configuration.yaml
homeassistant:
# Name of the location where Home Assistant is running
name: Home
# Location required to calculate the time the sun rises and sets
latitude: 41.0844
longitude: -80.7182
# Impacts weather/sunrise data (altitude above sea level in meters)
elevation: 0
# metric for Metric, imperial for Imperial
unit_system: imperial
# Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
time_zone: America/New_York
customize: !include customize.yaml
# Enables configuration UI
config:
xiaomi_aqara:
discovery_retry: 5
gateways:
- key: 1821C8E69C994AB9
# Cloud
cloud:
# Enables the frontend
frontend:
javascript_version: latest
extra_html_url:
- /local/lovelace.html
#wink:
http:
server_port: 8123
# Secrets are defined in the file secrets.yaml
# api_password: !secret http_password
# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# base_url: example.duckdns.org:8123
# Allows you to issue voice commands from the frontend in enabled browsers
conversation:
# Discover some devices automatically
discovery:
ignore:
- deconz
- philips_hue
nest:
client_id: !secret nest_client_id
client_secret: !secret nest_client_secret
usps:
username: !secret usps_username
password: !secret usps_password
ios:
proximity:
# Enables support for tracking state changes over time
history:
# View all events in a logbook
logbook:
# Enables a map showing the location of tracked devices
map:
remote:
- platform: harmony
name: Living Room
host: 192.168.1.120 #Add the IP address of your harmony remote
# go to the secrets.yaml file and add your passwords there
username: !secret harmony_username
password: !secret harmony_password
# Track the sun
sun:
# Text to speech
tts:
- platform: google
# Checks for available updates
updater:
# Optional, allows Home Assistant developers to focus on popular components.
# Note: This component will send some information about your system to
# the developers to assist with development of Home Assistant.
# For more information, please see:
# https://home-assistant.io/blog/2016/10/25/explaining-the-updater/
############################################################
# THESE SECTIONS ARE IN OTHER FILES #
# e.g. If you add a sensor, just put the platform in #
# the sensors.yaml file and not in this configuration #
############################################################
media_player: !include media_players.yaml
sensor: !include sensors.yaml
input_boolean: !include input_booleans.yaml
input_select: !include input_selects.yaml
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
input_number: !include input_number.yaml
camera: !include cameras.yaml
binary_sensor: !include binary_sensor.yaml
zone: !include zones.yaml
############################################################
is there a way to add this so it plays sound?