Unable to find how to get HA to tell me what time it is

I can ask Alexa “Alexa, what time is it?” and I get a reply. I am trying to do this disconnected from the internet. Does anybody have an idea? I am new to Home Assistant but I can voice control my lights.

Are you using Alexa to voice control your lights? If so do you have a Home Assistant Cloud subscription, or are you using a custom integration?

I am moving over to HA from Alexa. I am in a high risk zone for hurricanes and go without internet for too long. I am using HA for what Alexa once did for me.

I am older, handicapped and live alone. I am trying to automate everything I can as soon as I can, Thank you for any help. Once I get a few tasks under my belt I should be able to modify more for other uses.

I have setup date/time as a helper but so many instructions over the web involve hardware I dont have. My server has date/time I thought it would be easy to send a “now” time to TTS to get current time but I dont know how to do that.

I use Piper text to speech and it works very well over my RaspiAudio Muse Luxe. Not sure where or if this would work “The time is {{ now().strftime(‘%H %M’) }}”

I use an HA automation that says “X minutes after Y pm” or “X minutes until Y am.”

alias: Assist Tell Time
description: Voice Assistant Tell the Time
trigger:
  - platform: conversation
    command:
      - What is the time
      - Tell me the time
      - What time is it
      - Give me the time
      - Time please
condition: []
action:
  - set_conversation_response: |-
      {% set hour = now().hour %}  
      {% set minute = now().minute %}  
      {% set ampm = "AM" %}  
      {% if hour > 12 %}
        {% set hour = hour - 12 %}
        {% set ampm = "PM" %}
      {% endif %}  
      {% if minute < 30 %}
          The time is now {{minute}} minutes after {{hour}} {{ampm}}
      {% elif minute == 30 %}
          The time is now {{hour}} {{minute}} {{ampm}}
      {% elif minute > 30 %}
        {% set minute = 60 - now().minute %}
        {% set hour = hour + 1 %}
        {% if hour > 12 %}
          {% set hour = hour - 12 %}
        {% endif %}
      The time is now {{minute}} minutes before {{hour}} {{ampm}}
      {% endif %}
mode: single
1 Like

Than you so much, this looks great! I have never done an automation or script before so I will have to figure out how and where to insert this, I will work on this best I can.

This is far more complicated than I ever expected, I never wanted to become a programmer. I was looking for something to help me out not a new career. I have to abandon my thought that Home Assistant was a replacement for Alexa. When I loose the internet II may be able to work my lights, still better than where I am today.

Thank you for your help! I stepped away for a few days, came back and had your automation running in 20 minutes. Sorry for being terse, some days are better than others

1 Like

I’ve been playing around with this as well. This automation works, except that it doesn’t switch from AM to PM. I guess I can figure it out by where the sun is in the sky :rofl:

But in all seriousness… It would be nice to have it just simply announce the time in 24-hour format. Any idea how to do that? Nothing I’ve tried works and I’m also not a programmer…

I tried different things with these lines to at least get the AM/PM thing to work, but whatever I try I get a syntax error:

The YAML was written for my US/English/American system, generating 1-to-12 AM/PM responses.
If you prefer a simple 24-hour format, that isn’t terribly difficult:

action:
  - set_conversation_response: |-
      {% set hour = now().hour %}  
      {% set minute = now().minute %}  
      {% if minute < 30 %}
          The time is now {{minute}} minutes after {{hour}}
      {% elif minute == 30 %}
          The time is now {{hour}} {{minute}}
      {% elif minute > 30 %}
        {% set minute = 60 - now().minute %}
        {% set hour = hour + 1 %}
      The time is now {{minute}} minutes before {{hour}}
      {% endif %}

OK, now I get it… Actually was able to make it say the time just in hours and minutes, either AM/PM format or 24-hour format!
Thank you

1 Like