Janet (The Good Place)

background / motivation: We’re a Google family and basically our whole life is connected to Google. Though i have been using HA for a while now, my wife refuses to and set me an ultimatum: She will only use it if it’s more fun than Google. Challenge accepted.

What is Janet: Janet is a TTS and notifications machine that answers your questions and informs you about anything you can think of. She is based on the Janet character from the tv-series The Good Place.

This speech-engine provides the platform to create “Skills” that will allow you to basically build notification messages for any automation. In her current state she has over 90 references/phrases/quotes at her disposal that are randomised to build complete sentences. With her current phrase library she can generate 100’s of different variations of replies, her answer will not quickly bore you.

Setup:

  • Janet can send TTS and Notification messages. The kind of reply can be toggled with a hard switch
  • incase you’re not home but there are visitors in your house the “guest mode” will make sure she’s still operational.
  • Some notifications are too important to neglect, hence the “alert mode”
  • Janet has several settings:
    - Source: the output for TTS
    - The volume of her output TTS
    - Her wittyness: Basically the %-chance she will throw in witty comments in adition to the factual answer of your question.
  • Janet’s abilities are expanded with skills: These skills are built up out of automations and the macro’s needed to form a reply.

Credits for inspiration, mechanics and collaboration:
@CCOSTAN @happyleaves @tschmidty

As Skills are added, Janet’s functionality will keep increasing!
With enough interest in this project, the users of Janet can add Skills both for their own use, and that of the community.

39 Likes

Planned expansion abilities / skills:

technical:

  • Configure media_player input_select to dynamically update available media_players.
  • Ability to specify the notification output type (TTS or Notify) with a parameter.
  • Automations which entity_id contain “skill_” are automatically added to the group ‘Skills’ in the front end.
  • Ability to provide image / URL infomation in addition to her text message, both to media_player and embedded in her notification
  • Ability to determine to which device to send a specific message or notification.

practical:

  • Notify Location Changes / Location travel times
  • Battery inquiries / Notify low battery
  • Weather inquiries / Notify pollen

fun skills:

  • Welcoming devices (guests) after they’ve been last seen for over an x period.
  • Talking back to you when you check configuration / reload components and addons

Participation:
Please feel free to post idea’s or to expand the Github directory and build in planned expansions. I’ll keep the ‘planned expansions’ heading up-to-date.

1 Like

Mechanics:
Automations send ‘calls’ to the speech_engine, along with parameter values such as “person”, “CustomMessage” etc… These calls are then randomized to form a response.

Configuration:
At the moment you need to configure a couple of things to use it:

  1. media_player input_select has to contain the friendly names of your media_players.
  2. Script speech_processing has to refer to your personal TTS component.
  3. Script text_processing has to refer to your personal Notification component (I’m using PushBullet).

Examples:

Currently available calls/parameters:
Call values have to be value: 1 to trigger them:

"call_greeting": 1,
"call_introduction": 1,
"call_update": 1,
"call_okay": 1,
"call_inform": 1,
"call_bye": 1,
"call_shut_down": 1,
"call_new_device": 1,
"call_location_inquiry": 1
"call_rain_warning": 1

Parameter values are string values or sensor states:

“person”: “Michael”
“CustomMessage”: “This is an extra string.”
“Event”: “some string”
“WeatherRain”: {{ sensor.example.state + unit_of_measurement }}

3 Likes

This is amazing project :slight_smile: However there is a similar one I saw it yesterday (Voice controlled "house bot" project called Ira) by @wadetb, I think it would be beneficial for you and the community to merge the efforts :slight_smile:

1 Like

I think it looks really cool and fully plan to steal some ideas. I am a little confused as you said something about responding to queries but I don’t see where there is an input state but is this just something where you are initiating actions via google and having it respond via this?

@tschmidty
First of all: why steal idea’s if you can add to it? The more people participate in this project, the better it will become. =)

second: messages can be triggered by:

  • any normal trigger… IFTTT, states, times, events etc…
  • this speech_engine can work for everyone despite having different setups and sensors, for example: for my weather i’d use buienradar components, while you might use something else. It doesn’t matter because the speech_engine will accept the parameters “WeatherDescription”, “WeatherTemperature” and so on. The only thing you’d have to configure is linking the required sensor to the Parameter in the automation:

data_template:
WeatherCondition: >-
{{ states.sensor.example.state }}

2 Likes

Meant to add that it looks like some of the yaml indentation looks off towards the end.

Stealing because I am pretty far along with my own Jarvis implementation which is an implementation using appdaemon and Snips to do some similar things. I’d be happy to contribute any ideas but it’s pretty different since it is all python code for the most part.

Fantastic looking project and will be following it as it continues to be added to.
@Lentron If you are looking to potentially have people add to it do you have it hosted on github?

@CBRHerms Thanks for your suggestion and comment. I’ve never used Github before, but i will look into it. I’d like to see this project getting taken up by the community.

1 Like

Definitely look at github. If you set this code as a package you can literally have everything in one file. If you use distinct names for all the pieces (prefix janet_ or something) people could just drop it in and make some use if you set up a basic api type thing. I’d be happy to help take a whack at it if you do so.

2 Likes

Most definitely.
A lot easier to keep track of community contributions that way and always have the latest code.

@CBRHerms @tschmidty

Here it is.
I don’t have much time this weekend so i split my configuration files and dropped them in the Guthub through their GUI website from my tablet. I couldn’t find out how to add/create folders this way so the folders are missing. Obviously it’s supposed to be like:

/www/Janet.png
/automation/skills
/scripts/scripts

etc.

1 Like

How to communicate with Janet. I try add all and run fine but how to communicate with it. Please advice and show example.

@Sunonline

  • If you look at the skills already available, you can click on them and press “trigger”.
  • when you go to “services” (atleast, in Hassio), you can use the example from the picture in my earlier ‘tutorial post’.

Be aware that the current version of this code uses my personal media_player and notification component ( I will fix this when i have time ) :

  1. the input_select uses my personal media_players atm.
  2. the script speech_processing refers to my personal TTS component, and uses the media_players from the input_select
  3. the script text_processing refers to my personal Notification component.

The above 3 things you have to change to your personal components / media_players. Since this project started as my personal project it doesn’t work dynamically yet, but i intend to change this

1 Like

I try using script.speech_engine and put
{
“message”: " Hello how are you"
}

the json is correct but no sound.

I have tried to put all file together as much as possible as janet.yaml in package.
The janet.yaml exclude scripts and group from default view. HA checks config OK.

## Janet (Packages)  https://community.home-assistant.io/t/janet-the-good-place/38904
## Github: https://github.com/Lentron/Janet---Home-Assistant

## Excluded scripts and tabview
## Ex-notification_hub
## Ex-speech_engine
## Ex-speech_processing
## Ex-text_processing
## Ex-View Tab from group

##################################################
## input - Janet
################################################## 

input_boolean:
  guest_mode:
    name: Guest Mode
    icon: mdi:account-multiple
    initial: off

  alert_mode:
    name: Alert Mode
    icon: mdi:bell
    initial: off

  speech_notifications:
    name: Speech Notifications
    icon: mdi:bell-outline
    initial: on

  text_notifications:
    name: Text Notifications
    icon: mdi:message-text-outline
    initial: on
    
input_number:
  notification_volume:
    name: Volume
    icon: mdi:volume-high
    min: 0.0
    max: 1.0
    step: 0.01
    initial: 1.0

  notification_witty:
    name: Witty
    icon: mdi:auto-fix
    min: 0
    max: 100
    step: 1
    initial: 80
    
input_select:
  notification_media_player:
    name: Source
    icon: mdi:speaker
    options:
      - RPI
      - LG
    initial: RPI
    
##################################################
## group
##################################################    

group:
  notification_modes:
    name: Modes
    entities:
      - input_boolean.guest_mode
      - input_boolean.alert_mode
 
  notification_notifications:
    name: Notifications
    entities:
      - input_boolean.speech_notifications
      - input_boolean.text_notifications
    
  notification_settings:
    name: Settings
    entities:
      - input_select.notification_media_player
      - input_number.notification_volume
      - input_number.notification_witty
  notification_skills:
    name: Skills
    entities:
      - automation.new_device_connected
      - automation.update_available
      - automation.start_up
      - automation.shut_down

##################################################
## automation
################################################## 

automation:
  - alias: "New device connected"
    trigger:
      - platform: event
        event_type: device_tracker_new_device
    action:
      - service: input_boolean.turn_on
        data:
         entity_id: input_boolean.alert_mode 
      - service: script.speech_engine
        data:
          call_greeting: 1
          call_new_device: 1
        data_template: 
          person: >-
            {{ trigger.event.data.name }}
            
  - alias: Shut Down
    trigger:
      - event: shutdown
        platform: homeassistant
      - event_type: homeassistant.restart
        platform: event
    action:
      - service: script.speech_engine
        data:
          call_bye: 1
          call_shut_down: 1
          
  - alias: Start Up
    trigger:
      - event: start
        platform: homeassistant    
    action:
      - service: automation.reload
      - service: script.speech_engine
        data:
          call_greeting: 1
          call_introduction: 1
          
  - alias: Update Available
    trigger:
      - platform: state
        entity_id: sensor.up_to_date
        from: 'true'
        to: 'false'     
    action:
      - service: script.speech_engine
        data:
          call_greeting: 1
          call_update: 1
1 Like

The scripts file. What I have change is the media_player to what I have use. Is there anything else need to be change?

part of media player from speech_engine
media_player: >-
{% if states.input_select.notification_media_player.state == ‘LG’ %} <== change according input_select
media_player.lg_tv_remote <== change according input_select
{% else %}
media_player.ha_speaker <== change according input_select
{% endif %}

Please advice regarding text_processing as you mention personal notification component. I didn’t change anything is this file. Do I have to change to ?

@Sunonline

your personal components:

notify:
  - platform: pushbullet
    name: Janet
    api_key: xxxxxx
tts:
  - platform: google

I don’t have pushbullet nor letencrypt.

Can I use ios.notify ?

@Sunonline You need to have a component to refer to, it can be any component of your choice as long as it accepts the data parameters that are used in the ‘processing’ scripts