Janet (The Good Place)

It uses the Friendly name set for the sensor in the front end. if there’s no friendly name given then It will read the sensor name instead.

I did make a separate guest automation that uses the device_tracker so i can use guests that I set up bluetooth trackers on to greet them when they come over. It works very well!

- id: guest_greeting
  alias: Guest Greeting
  trigger:
    platform: state
    entity_id:
      - device_tracker.boos_iphone
      - device_tracker.jasmines_iphone

    from: 'not_home'
    to: 'home'
    for: '00:01:30'
  action:
    - wait_template: "{{ is_state('script.janet_speech_engine', 'off') }}"
    - service: script.janet_speech_engine
      data_template:
        person: >
          {{ trigger.to_state.name }}
          {%- for s in states.device_tracker
                |rejectattr('entity_id','eq',trigger.entity_id)
                |selectattr('state','eq','on')
                if '_home' in s.entity_id and
                   (now() - s.last_changed).total_seconds() < 60 -%}
            {{ (' and ' if loop.last else ', ') ~ s.name }}
          {%- endfor %}
        message: >
          {{ ["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!",
              "PERSON, When your here, your never alone, Welcome back",
              "Well hello PERSON, it's nice to see you again!",
              "Sweet, PERSON is here, I love me some PERSON"
             ] | random }}
      {{ trigger.to_state.name }}
      {%- for s in states.binary_sensor
            |rejectattr('entity_id','eq',trigger.entity_id)
            |selectattr('state','eq','on')
            if '_home' in s.entity_id and
               (now() - s.last_changed).total_seconds() < 60 -%}
        {{ (' and ' if loop.last else ', ') ~ s.name }}
      {%- endfor %}

In your family_greeting automation you use binary_sensor. The data_template part have to change

      {{ trigger.to_state.name }}
      {%- for s in states.binary_sensor
            |rejectattr('entity_id','eq',trigger.entity_id)
            |selectattr('state','eq','on')
            if 'on' in s.entity_id and   ### I change from '_home' to 'on' as binary_sensor never have state home and not_home
               (now() - s.last_changed).total_seconds() < 60 -%}
        {{ (' and ' if loop.last else ', ') ~ s.name }}

looks good… following, gotta get other stuff figured out first…

Question - do you really have your systems talking this much? I find it really annoying and intrusive and much prefer messages to my iPhone so I choose when and what to do with them.

I just don’t get it…

Looks cool. Will test it out.
Anybody dares to convert this to a NodeRed Flow?

I will give it a shot, once I find the time to first implement this as Yaml, because at the loooks of it, it does not seem simple…

I’ve had Janet working for some time. I get text and voice just like expected. However, the problem that I’m running into is that when I use multiple “calls” in one statement, they are always out of order. For example, using the json from the 3rd post,
{
“call_greeting”:1,
“call_new_device”:1,
“person”: “Michael”
}

Instead of getting a greeting, the new device appended with the name Michael, I get Michael, the new device, then the greeting. Changing the order of the calls doesn’t seem to make a difference. Anyone have any thoughts? Do I need to put the macros in alphabetical order? Any help would be appreciated!

Hey Ethan, the script builds the message in a specific order, so that will always be the same. If you want to change the order you’d have to add a new variable to the main script and use that, like person_start

Anyone managed to get grouped TTS devices to work?

Hi,

don’t know if this project is still active…but, just in case, can someone help me to create different welcome macro based on person’s gender (me vs my wife).

Thank you in advance

You can duplicate your welcome macro and set for each only one (different) trigger (device_tracker) and in the action use male/female related words…

1 Like

Well, that was so simple!

Thank you! :slight_smile:

Hi Lentron,

I guess I missed the memo about Janet, and just discovered it last night. I must say, it looks quite impressive and will be eager to give it a test drive in the near future. I just read through most of this whole thread but might have missed a few details that maybe you can answer for me, hopefully.

1.) Is it easily possible to change Janet’s name for our own personal implementation? My wife choose the name of our HA implementation a couple of years ago & would very much like to keep that name.

2.) My install of HA is a bit different than most. For high availability and fail-over justifications, we run distributed HA setup of 5 x HA installs. The primary HA runs on a VM and 4 more instances of HA run on RaspberryPi 3’s that are also functioning as remote media_player outputs & GPIO inputs (the VM of HA is the only HA instance with neither GPIO or media_player outputs, but it has lots of CPU & RAM). Everything is communicated between the HA instances using MQTT, including TTS strings that get sent from the primary VM based HA to the RPIs for TTS conversion and audio output via the Speaker Jack on each RPI.

Additionally, if the primary HA instance running on the VM were to ever crash (only happened once in 12 months) or go down for upgrades, a remaining HA RPI-based instance can also take over critical operations (like aquarium heating control, etc) until the primary VM based HA instance is back online. The remaining HA RPI’s also can raise TTS & push notification alerts that an unexpected failure with the VM occurred.

Further disclosure - this High Availability is required, as I use HA to manage everything regarding a dozen Coral Reef aquariums. In this regards, HA has blown the doors off any commercial aquarium controller. :slight_smile:

My question to you about this, is do you think Janet could be adapted easily for this type of setup? My initial impression so far is “why not?” but perhaps you also have some ideas about this too.

3.) Not a technical question - but are you also in the Netherlands? I saw you mention Buienradar, which is why I’m asking. I’m located in The Hague. If so, perhaps we could meet up and talk HA shop sometime. :slight_smile:

Thanks in advance & the impressive looking project of Janet. I look forward to learning more.

Cheers

1 Like