🤡 Joke Generator - Speak random jokes

Insult your neighbors mom when they come over for drinks?
Bore your kids to sleep with a dad joke when they turn off their bedroom light?
Scare burglars away with insults when your alarm is triggered?

It’s now possible with the Joke Generator Blueprint!


The automation selects a random joke from a list.
There are 3 types of jokes to choose from:

  • funny insults
  • yo momma jokes
  • dad jokes

It speaks 9 of the most common languages in Europe:

  • English
  • German
  • French
  • Italian
  • Spanish
  • Dutch
  • Portuguese
  • Turkish
  • Russian
See how it works
  1. Select a trigger:
    This can be anything and the trigger can be further automated in a separate automation in order for the generator to loop for instance.
  2. Select a joke type: Choose between funny insults, yo momma jokes or dad jokes.
  3. Select a language and Text-to-speech entity (these must match for best performance)
  4. Select the media player you want to say the joke on.

:clown_face: ↓ ** !!! GET IT NOW !!!** ↓ :clown_face:

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

:link: Source code (Github)
:gear: See code changes (Github)


:memo:Changelog:

05/01/2024 - Version 1.1

  • Added 50 more English dad jokes
  • Simplified the code, reducing it by 233 lines
Open to see older changes

05/01/2024 - Version 1.0 (original release)

  • This blueprint selects a random rude joke from a list.
  • There are 3 types of jokes to choose from: funny insults, yo momma jokes and dad jokes
  • It speaks The 9 most common languages in Europe: German, English, French, Italian, Spanish, Dutch, Portuguese, Turkish and Russian.
4 Likes

This is awesome…
Have you considered adding something like…

1 Like

That’s very interesting.
I’ll take a look but honestly, I’ve never worked with API’s before so it might be a while before I get the hang of it.

There are probably others to cover other joke styles, I didn’t look.

NEW RELEASE:

05/01/2024 - Version 1.1

  • Added 50 more English dad jokes
  • Simplified the code, reducing it by 233 lines

You can do it using a RESTful sensor. Add the following to your configuration.yaml:

rest:
  - resource: https://icanhazdadjoke.com/
    method: GET
    headers:
      User-Agent: Home Assistant
      Accept: application/json
    scan_interval: 3600
    sensor:
      name: "joke"
      unique_id: joke123
      value_template: "{{ value_json.joke }}"

This creates an entity sensor.joke, which you can now use in assist or on a lovelace dashboard in an entities card. I set the scan interval to one hour to avoid overloading the site.

2 Likes

No TTS is showing up for me for some reason. When I go to Developer Tools and Services everything is working. Any suggestions?

It worked for me. Did you restart HA to install rest for the first time. Reload rest didn’t seem to work because this was my first one.

Same here, let me know if you get it fixed!

Yes, I did restart HA, I thought it was to get the conversation working, I never seem to have luck loading components of configuration.yaml. But, I really do enjoy asking “Tell me a joke” on my phone, and having it respond (with text to speech as well as display). How do they direct the voice back to the companion app that originated the request? There is no way to set this up in an automation as far as I can tell.

conversation:
  intents:
    Tellmeajoke:
      - "Tell me a joke"

intent_script:
  Tellmeajoke:
    speech:
      text: "Hey Phil {{ states('sensor.joke') }}"
1 Like

If you are having problems with the assist integration,a good place to ask is
Voice Assistant - Home Assistant Community.

But the rest command appears to work just fine, as you have tested yourself in developer.

For the api grab, This works great, but I was wondering about an improvement. Is there a way to plug this into a template sensor and only grab a new joke when you have triggered the last one?
I have tied this to my front door presence, so It might get a trigger every 5 minutes while there’s stuff happening and then not another trigger the rest of the day. I’m thinking why burden the server by pulling ever 5 minutes when maybe I can push an HA button when I use a joke, that triggers going to the api and getting a new one?
Any thoughts?

I guess I could use this blueprint and not burden any server but my own, but…

Set the interval to a day or more and then separately create an automation that gets a new joke when the stored one is spoken?
This would limit the polling to once per day (or longer), or when it’s needed.

Thanks for the clue. figured it out with this:

      - service: homeassistant.update_entity
        target:
          entity_id: sensor.joke
        data: {}

I set the rest sensor to once per day, then after I use a joke, I send this.

1 Like