Janet (The Good Place)

Extra automation for system check

  - 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 %}

Extra automation home assistant status

  - 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 %}

@Sunonline thanks friend.

Your welcome.

can u tell me more about that sensor open_street_map? how its configure?

I use this for open street map

1 Like

Hi

I tried following the guide and when I send a message to telegram saying “turn on heater” it says “ok turning on heater” but nothing happens.

I get an error saying: WARNING (MainThread) [homeassistant.core] Unable to find service sensor/turn_on

I am on polling method and I have also tried it with webhooks.

Can you share your configuration for telegram chat?

Do I have to write specific intents? or?

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

use call_greeting instead of Call_greeting

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

thank you very much
I changed as you say still not
this is my configuration

input_select:
janet_notification_media_player:
name: Source
icon: mdi:speaker
options:
- “Google_Assistant”
- “HA”
- “Living Room TV 2”
initial: “Google_Assistant”

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: >-

If you can post your config then I can help.

homeassistant:
group:
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:
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:
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:
janet_notification_media_player:
name: Source
icon: mdi:speaker
options:
- “Google_Assistant”
- “HA”
- “Living Room TV 2”
initial: “Google_Assistant”

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 -%}
        
        {%- macro alarm_clock_check() -%}
          Alarm clock weekday status is {{ states('input_boolean.alarmclock_wd_enabled') }} at {{ states('sensor.alarmclock_wd_time_template') }} and alarm clock weekend status is {{ states('input_boolean.alarmclock_we_enabled') }} at {{ states('sensor.alarmclock_we_time_template') }}.
        {%- endmacro -%}
        
        {%- 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 -%}   

        {%- 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 -%}
         
        {%- macro Home_Assistant_check() -%} 
          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 -%}
        
        {# ********************************************* #}
        {#  ******** Start the Speech routines ********  #}
        {# ********************************************* #}

        {% if call_alarm_clock_check == 1 %}
          {{ alarm_clock_check() }}
        {% endif %}
        
        {% 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 %} 
        
        {% if call_security_check == 1 %}
          {{ security_check() }}
        {% endif %}
        
        {% if call_system_check == 1 %}
          {{ system_check() }}
        {% endif %}
        
        {% if call_homeassistant_check == 1 %}
          {{ homeassistant_check() }}
        {% endif %}
        
        {% 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 }}
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.people
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("  "," ") }}

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

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") }}

  - service: notify.ios_nhatphat_6s
    data_template:
      title: "Janet:"
      message: >- 
        {{ speech_message | replace("\n","") | replace("   ","") | replace("eight hundred and sixty one thousand","861.000") }}
      
  - service: tts.google_say
    data_template:
      title: "Janet:"
      message: >- 
        {{ speech_message | replace("\n","") | replace("   ","") | replace("eight hundred and sixty one thousand","861.000") }}

That is my entire configuration in the janet.yaml package

Show me your media player config as well. Also you already can use google tts right?

Which file are you in?

Do you use teamviewer software?

No. I’m at work

media_players:
entities:
- media_player.livingroomcc
- media_player.whole_house
- media_player.living_room_tv
- media_player.living_room_ultra
- media_player.upstairs_living_room
- media_player.alarm_clock
- media_player.bedroom_alarm_panel