Hi All!
Last week I found Home Assistant – and absolutely love it. There is so much possibility here, and already there are a few projects on the go.
For one of the first projects I’m trying to start simple and implement a better timer system for cooking. Alexa or Google Home require that you cancel timers, which is a pain when your putting out the fire on the BBQ, so I have setup two timers (pasta and BBQ steak) using HA. These will use TTS to either tell you the 3 minutes is up for pasta, or for the BBQ say to start cooking, tell you to flip the steak after 3 minutes, then tell you the time is up after another 3 minutes – with no need to cancel the timer.
This is also a good chance for me to practice some coding. The basics here are working. I can call the script from Google Home, and have HA use TTS tell me to start and stop cooking.
There are a few things I can’t figure out though, and would appreciate any help.
-
It seems there are some differences between HASS.IO and installing HA on a Rasberry Pi linux distro. In the tts_current_time script I would like to say the start time in 12 hour format. (“It’s now seven sixteen” rather than “It’s now nineteen sixteen”.)
Unfortunately now().hour only seems to give the hour in 24 hour format. A lot of posts refer to strftime and strptime, but I can’t seem to get these working with HASS.IO.
Is there a way to convert now().hour to 12 hour format in the script.tts_current_time message, or alternate way to get the time hour in 12 hour form? -
The other thing I was stuck on was how to use tts_current_time as a “procedure”. (Probably the wrong term, but I believe that UCSD Pascal will make a comeback ) I’m trying to figure out how to setup generic scripts that can be called by other scripts with the required paramaters as well as using a default if no parameter is supplied, as this will become important for some of the lighting projects.
Is there any way to pass a variable to tts_current_time for the tts.google_say entity_id? Everything I have tried complains about using a variable for entity_id.
Also, is there a way to declare a variable at the start of the two main scripts that sets the entity_id to make maintenance easier? -
This will probably be a face palm one. I did have the main scripts calling tts_current_time, even though it was giving me 24 hour form. In my efforts to get 12 hour and pass variables working neither script is currently calling tts_current_time. I can active the tts_current_time Script fom the web page and know it works – the other scripts are no long calling it.
I had changed the script name. Since then I have restarted the server a few time, but wonder if coming is cached??
TIA
tts_current_time:
alias: Say the current time
sequence:
- service: tts.google_say
entity_id: media_player.kitchen_speaker
data_template:
message: "Its now {{ now().hour }} {{ now().minute }}."
the_grill_timer:
alias: The Grill
sequence:
- service: script.tts_current_time
- service: tts.google_say
entity_id: media_player.kitchen_speaker
data:
message: Get ready to grill
- delay:
seconds: 5
- service: tts.google_say
entity_id: media_player.kitchen_speaker
data:
message: Start cooking now
- delay:
seconds: 180
- service: tts.google_say
entity_id: media_player.kitchen_speaker
data:
message: 3 minutes, Turn the steak!
- delay:
seconds: 180
- service: tts.google_say
entity_id: media_player.kitchen_speaker
data:
message: 6 minutes, Stop cooking!
the_pasta_timer:
alias: The Pasta
sequence:
- service: script.tts_current_time
- data:
message: Get ready.
entity_id: media_player.kitchen_speaker
service: tts.google_say
- delay:
seconds: 5
- data:
message: Start cooking now
entity_id: media_player.kitchen_speaker
service: tts.google_say
- delay: '[object Object]'
- data:
message: 3 minutes is up. Gino says stop cooking.
entity_id: media_player.kitchen_speaker
service: tts.google_say