Janet (The Good Place)

if you don’t hear anything. after service call. check the setting input select for your speaker.

no, i cant call the service, because i got Invalid JSON

show me how you post then I can see. Mine with the one I post valid.

{
“call_greeting”: 1,
“call_introduction”: 1
}

paste then click somewhere out side where you paste json then will show valid json, press call service

dont know what is wrong, i cant call the service

Check from second post of janet (the good place). There are example the service call available. try from what available there.
sometime it just because of double quote " in english language. if you call more than 1 call the last call don’t need ,
Check from the example and how to on second post

thank you, i managed to get it working, enter the text manually, im not in home, so i cant listen in the media players, but i get the notification, it should be a easy way to call the services, maybe in the frontend

You need two spaces on the begging of each line that starts with "

If you see that he has automation provide to make Janet speaks ramdomly. So you can use from his automation or create what you want.

sorry to keep bothering, i managed to call the service, i get the notification but i dont hear anything, try all the media_players

if you can show how your config for janet packages for input_select: and script for speech_engine.
These two files will match each other for the media_player selected.
Also how is your media_player connected to HA, or do you have tts in your configuration?

input_select:
janet_notification_media_player:
name: Source
icon: mdi:speaker
options:
- Master bedroom Home
- Soundtouch
- Group
- Fer’s Chromecast
- Fer’s Chromecast Audio
- Nexus Player
- WebOS
- Spotify
- Kodi
initial: Master bedroom Home

script:
######################################################################################################

within janet_speech_engine the string message is generated with the use of macro’s.

######################################################################################################

janet_speech_engine:
sequence:
- service: script.janet_notification_hub
data_template:
#TODO
media_player: >-
{%- for device in states.media_player -%}
{%- if device.name == states.input_select.janet_notification_media_player.state -%}
{{ device.entity_id }}
{%- 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 %}
  1. does all your media player support tts?
  2. click on the 3 dots from your media player you will see text to speech. if support then you can use that media player.
  3. check from script speech_processing / at the - service what tts do you put?

yes google home supports tts this is the script speech_processing

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, 'playing') }}"
    timeout: 00:00:30

  - service: media_player.volume_set
    data_template:
      entity_id: >
        {{ media_player }}
      volume_level: >-
        {{ states.input_number.janet_notification_volume.state }}

  - service: tts.google_say
    data_template:
      entity_id: >
        {{ media_player }}
      message: >-
          {{ speech_message | replace("\n","") | replace("   ","") | replace("  "," ") }}

which media player from your source support tts.google_say. click on the 3 dots from your media player you will see text to speech. if support then you can use that media player. check the name to of the media player in source to match the entity id. not every media_player you have support tts, so you have to check which one is support.

Mine I use his old speech_engine which i have to state the entity_id that match from input_select.

example:

input_select:
  notification_media_player:
    name: Source
    icon: mdi:speaker
    options:
      - HA
      - LG
    initial: HA

example from my script speech_engine

speech_engine:
  sequence:      
    - service: script.notification_hub
      data_template:
        media_player: >-
          {% if states.input_select.notification_media_player.state == 'LG' %}  <== this from input_select
             media_player.lg_tv_remote  <=== entity_id of my media_player
          {% else %}
             media_player.ha_speaker  <=== default is this entity_id to be used from input_select is HA
          {% endif %}
          
        speech_message: >-

If anyone is interested here is a simple automation to change the TTS output, change to suit your setup:

#TTS Output Change

  - alias: Janet Change Output Night
    trigger:
      - platform: state
        entity_id: switch.wemo_bedroom
        to: 'on'
    
    condition:
      condition: and
      conditions:
        - condition: time
          after: '21:00:00'
          before: '06:59:00'
          
    action:
      - service: input_select.select_option
        data:
          entity_id: input_select.janet_notification_media_player
          option: "Master Bedroom - Home"
      - service: input_number.set_value
        data:
          entity_id: input_number.janet_notification_volume
          value: '0.45'
          
  - alias: Janet Change Output Day
    trigger:
      - platform: time
        at: '07:01:00'
    
    condition:
      condition: and
      conditions:
        - condition: time
          after: '07:00:00'
          before: '20:59:00'
          
    action:
      - service: input_select.select_option
        data:
          entity_id: input_select.janet_notification_media_player
          option: "Kitchen - Home"
2 Likes

Hi i am new to hass.io. How do I install this?

Great piece of work @Lentron

I’m looking for a strategy to move all my notifications (text and TTS) over to Janet and am wondering whether it is best to move all templates I currently have in automations and scripts entirely to Janet as skills or rather use the CustomMessage.

I have larger templates e.g. for looping over all entities in a battery_group to let me know of any batteries that are running low. Would I create a new skill like this in the janet_speech_engine script:

{%- macro check_low_batteries() -%}
  {%- for ... -%}
    ...
  {%- endfor -%}
{%- endmacro -%}

And then invoke it like this in the automation:

action:
  - service: script.janet_speech_engine
    data:
      check_low_batteries: 1

Or rather using the CustomMessage like this:

action:
  - service: script.janet_speech_engine
    data_template:
      CustomMessage: >
        {%- macro check_low_batteries() -%}
          {%- for ... -%}
            ...
          {%- endfor -%}
        {%- endmacro -%}

@geoffrey , thankyou for your feedback. As to your question, I think it would be great for the community if you’re willing to add your automations to the Janet Skills. This way everyone can benefit from the automations you made. If you’d like I can add you to the Github, so you can add these skills yourself.

I haven’t added new skills in a while already, but there is still much room for improvement. Your help would be greatly appreciated.