Thanks,
I now have this working in a rule with the below logic. One question remains illusive, is there some logic to limit this action to only run once per day ?
This could be simplified to not even creating or assigning the variable. Just use %value% as the message.
Private boolean. Just an example: set it to True. In the actions, if true, do the actions, once the message is spoken, set the boolean to false. Then another rule to set the boolean to true at 3 am or something.
@KurtSanders, one more observation. Please consider having abbreviations completely written out, or an option to use abbreviations or not. Fine for text message (oooh, an idiom of the day Pushover message to start the day), but doesn't work well with TTS. I tried on Alexa and Siri, and neither of them could pronounce "Rur." or "Euph." in any manner that could be understood.
Wonderful,
Thanks for your help!
I now have working with the below rules and logic (if it might help anyone else)
Wow
, went to bed last night after posting this 1st version to HPM, and woke up so see that this app has so many comments and useful suggestions!
Here are responses to some of the previous comments and suggestions above. Keep them coming, I will make updates as time permits, but all suggestions and issues are welcomed.
- @neerav.modi Our granddaughters, after a few weeks, have started using some of these idioms in their everyday communications. It is nice to see them picking up more than what my wife and randomly use, ie "Don't look a gift horse in the mouth".
- @ThunderboltsRock I have a HE rule when our Theater Projector turns off that sets the idiom device's 'idiom' attribute to a local variable named quote that can be used in HE rule's TTS message as %value%. I also have it play an idiom when we eat our morning breakfast...so many options.
- RM Example (quote is a local variable)
- Set quote to Idioms
- Notify Echo - Theater: '%quote%.
- I usually end the RM rule with a device command 'refresh' or toggle the switch to 'on' to pre-load the next idiom in the idiom device's attributes so that the next RM rule can fire off faster and eliminate the delay in activating the idiom's device's logic.
- RM Example (quote is a local variable)
- @neerav.modi I will check the Idiom data files to see if my Python parsing routine that generates these files into bite-size chunks might have a synchronization loop issue with phrase and definition.
- @neerav.modi Great RM tip using private boolean, so many ways to create rules for specific use.
- @neerav.modi Great suggestion on abbreviations, 'Rur', 'Euph' and TTS struggles. I will see if I can expand some of the frequent abbreviations used in these idiom phrases and definitions. I will either re-generate these idiom data files with my python parsing program or add some regex replace logic to the groovy idiom device driver in an updated version.
version 0.1.0, the examples are missing. Known, or a bug?
And an open, semi-related question: does anyone know how to slow Siri down? She's "speaking a hundred miles an hour", as my mom would say! Alexa is a bit slower, but still a bit too fast to really digest.
The new idioms database are shortened and have the meaning, which is a shorter example which plays better in Alexa and Google Play. The legacy idioms database was a mess as indicated in the version change log..
As far as speed of Siri TTS, here is a youtube video on the settings...
I was so hopeful. I found something similar for the HomePod minis, but it's called Voice Over, and turning it on unfortunately does not affect regular TTS. Voice Over is for reading the buttons or options out loud.
Notice: Early 'Hubitat-Fun' Adopters
Please note that I am now sunsetting the original 'pre-release' Idioms device driver in favor of the more robust Fun Api Responses application, soon to be released in a few days.
Please read my 1st post above that gives more details.
The 'Fun Api Responses' app is now available in HPM.
You will need to turn off 'Fast Search' and then search for 'Fun' as shown below.
FAQs
- You will need a free Api key (50 responses/day) from ApiLeague.com for all response categories (e.g. Jokes, Trivia, Poems, Quotes & Riddles).
- You will NOT need an api key for Idiom Responses.
- You can designate a TTS device for voice output in the Fun Api Responses App. If you decide to designate a TTS device, all device Refresh and Push events will generate a voice immediately.
- If you choose to capture the device 'response' attribute to a local string variable using Rules, that string variable can be used in subsequent actions, for example, sending a Pushover message, etc. Remember to either Refresh or Push the device to get a new response. I generally do this action after I obtain the string response, so that the next time, it is ready for capture, avoiding the delay of the Internet.
- The Fun Api Responses App is Only used to:
- Enter an Api Key for all categories except for Idioms
- Select a response site for testing your api key.
- Seeing how many api response tokens you have left.
- Adding 'difficulty' level to the 'Riddles' category
- Adding Include/Exclude filters to Jokes.
- Note: Be cautious on adding too many restriction and inclusion tags, you may encounter a "groovyx.net.http.HttpResponseException: status code: 400, reason phrase: Bad Request" which means the server could not find any responses that met your conditions.
Once the 'Fun Api Response' app is configured with your api, you can use the respective six (6) child devices to generate new responses.
Been anxiously looking forward to this since you teased us a few days ago. "Is it up yet? Now?"
I'm getting "groovyx.net.http.HttpResponseException: status code: 400, reason phrase: Bad Request". Edit: I removed all of the exclude tags and the jokes worked.
My daughter is going to max out the requests everyday once she learns this has been implemented!
Glad it's working for you. The Api*League has 'paid' plans if you or your daughter need more than 50 responses/day (Ha)... We have been using the idioms and riddles (medium difficulty) categories for education and laughs...
- A HTTP 400 Bad Request error means the server couldn't understand the client's request, likely due to a client-side issue like an incorrect URL, malformed data, or an invalid request format.
I, too, loaded up too many include/exclude filters for jokes and encountered the dreaded 400 response status in development. I finally figured it out, like you, and settled on these for the 'jokes' category:
Include:
- clean
Exclude:
- chuck norris
- nsfw
I am looking at the next version of the app to:
- Include a device on/auto-off 'switch' attribute for activating the refresh using Alexa routine. Apparently, Alexa does not recognize 'Push' attribute in a device.
- Add an app preference setting to indicate which response categories to send the response to the designated TTS device. Current is all categories.
If you have any other app suggestions, free free to let me know.
When I mean working, I mean I press the button in the device, and I get a new one. I've chosen a TTS device, but I'm not getting anything there.
It would be great when there is a switch exposed. Then have alexa/siri/google flip the switch to fetch a new entry. And when the TTY works, it will be awesome to not need any rules.
When the riddle runs it need a longer pause before it gives you the answer if possible? (perhaps 2 seconds)
@ThunderboltsRock I agree. Unfortunately, the diverse number of TTS output devices (eg. Amazon, Google, Sonos, etc) do not define or consistently allow how to insert a 'pause/break' in the provided text. Some TTS devices understand SSML (Speech Synthesis Markup Language), like Amazon devices, others do not.
I think the answer will be to:
- If a TTS device is selected, the 'Fun Api Response' app will separate the 'riddle' category sending separate question and answer speak commands separated by a user defined wait (secs) period.
- Define new sub-part attributes of the site specific 'response'. One could use a Hubitat Rule to set string variables to the separate device attributes and pause a TTS output with a 'wait' action between separate speak actions.
Category | Device Attributes (v 0.1.0) |
---|---|
Riddle | * response * question * answer |
Poem | * response * title * author * poem |
Joke | * response * joke |
Trivia | * response * trivia |
Quote | * response * author * quote |
Idiom | * response * phrase * definition |
@neerav.modi I will check why this is not playing on the TTS device. I will also add a 'switch' capability to all devices in this version 0.1.0 for Amazon Alexa integration and voice control.
I will begin working on version 0.1.0 over the next few days. I will need to test pause/break SAML tags with Amazon Echo devices.
Fun-Api-Responses App
Version 0.1.0 is now available in HPM (5/29/2025)
"Release Notes": "Version 0.1.0 Release Highlights
- This application generates fun and educational random responses from the internet that are formatted for TTS output on capability 'SpeechSynthesis' compatible devices (ie. Amazon, Google, Sonos, Ikea, etc).
- A free account on APILeague.com is required to obtain a free api string for some response categories shown in the table below with a
. You may wish to purchase their paid plans, which allow more responses (tokens) per day.
- The 'Idiom' category does not require an api account or api string. The Idioms category is powered by my own JSON file (over 700 entries), and I will add more on an as-needed basis.
- Several new 'no api required' response categories have been added: Dad-Jokes, Cat-facts, Zen-Facts, Advice and Useless-Facts.
- Site responses can be directed to an existing Global Hub Variable, eliminating creating a temporary variable in RM or WebCore.
- Riddle responses now have a designated pause duration (set in the App preferences ) between the Question and the Answer.
- Amazon Echo devices have an option to direct TTS to one device to play synchronously all hubitat integrated devices.
- One can select only the sites they wish and respective child devices.
- Child devices now have additional custom attributes for those responses that have separate responses, like Poems (eg. title, author, poem). The response field will have the sites response in a TTS format.
- A switch capability has been added to all child devices that allow one to use to initiate a new response. The switch will reset/auto-off. The momentary push capability and command Refresh are also available to generate a new site random response.
Category | Free API Required | Api Website | Responses |
---|---|---|---|
Jokes | ![]() |
ApiLeague.com | Joke |
Trivia | ![]() |
ApiLeague.com | Trivia |
Poems | ![]() |
ApiLeague.com | Title, Author, Poem |
Quotes | ![]() |
ApiLeague.com | Author, Quote |
Riddles | ![]() |
ApiLeague.com | Question, Answer |
Idioms | ![]() |
My GitHub Repo | Phrase, Definition |
![]() |
![]() |
icanhazdadjoke.com | Jokes |
![]() |
![]() |
http://uselessfacts.jsph.pl | text |
![]() |
![]() |
http://catfact.ninja | fact |
![]() |
![]() |
zenquotes.io | Author, Quote |
![]() |
![]() |
api.adviceslip.com | Slip |
For anyone who had the non-HPM, older version installed, make sure you manually remove the app and driver and devices before you install from HPM. If you don't, really strange things happen such as the new app using the old driver to create child devices.
@KurtSanders, TTS is now working with the Test for non-API categories. Nothing appear to work with API categories.
I did make some major updates to the driver to include more response attributes, but it should upgrade w/o issue. However, if it is weird, then a fresh install is worth it.
I am assuming that you have an API key from Api*League? This is different than the api key from the older version (V0.0.1).