Siri shortcuts on 2.0

You’re a god! Thanks buddy.

I’m using these entites for my alarm clock.

    entities:
      - sensor.date_time
      - input_boolean.alarm_1_enable
      - input_number.alarm_1_hour
      - input_number.alarm_1_minutes
      - sensor.alarm_1_time

Can I use it with sensor.alarm_1_time?
I have tried with input_number.alarm_1_hour and minutes with no result.

Can you share your hassio alarm clock.

I don’t actually use an alarm clock and figured out what I posted because I was curious about how to do it.
Not sure how you have it set up to determine the input_number values or sensor.alarm_1_time. Do you change the input_number values manually, and the sensor is based off that?
In you case, assuming you want the input_number entities to change to be the same as your phone alarm, I think you’d basically need to do the entire process twice over, but format the Get text from Time differently. First format as HH, then do another with format MM.
Do two dictionaries, with entity_id and value instead of time.
Call service would need to be done once for each entity, with input_number.set_value.

Alternatively you could create an input_datetime.alarm_1 and have the shortcut update that, and an automation change the input_number values, or just get rid of the input_number values and have the sensor.alarm_1_time based on the input_datetime.

Thank you. I have changed the input method to datetime and everything work fine.
I think the only problem is if you change de order of the alarms. An option is use the shortcuts app, with a target alarm clock, the you can call an automation fom home assistant.

Thank you! this works well. Can i ask you why you have the COMMENT thing after DICTIONARY and HOME ASSISTANT?

Wow! This is awesome. Thanks a lot. I only discovered a bug in this approach. When changing the name of any of the alarms. The line that gets the text from the ‘Time’-application longer shows the time value of the alarm. But, instead, it shows the changed name of the alarm. Is there a solution for this? Or should I just deal with the facts that I should keep the names of any of my alarms left default?

Hello, after a few hours of tinkering with Siri Shortcuts. I got the ‘bug’ fixed. The solution was to set the format for the first item in my alarms as an alarm type with custom time formatting. Sounds vague, doesn’t it? Well, here are some screenshots of my way of setting the iOS alarm clock to a HA input datetime.


And here’s the url to the shortcut: https://www.icloud.com/shortcuts/88d9d1e2bdb94dd7a8f8867cdd3aa8f2

I’m working on another Siri Shortcut which utilizes this one to only automatically sync the alarm clock to HA when needed using the iOS 14 personal automations and some if / else logic. The ultimate goal with all of this is to automate my hue light to gently wake me up in the morning. But still keep it all simple and easy to operate with software my family members are familiar with.

2 Likes

Great. What if I wanted a 2nd entity.
I know that I could add another “service call”.
But could I instead put a second entity_id in service data?

One entity_id key in the dictionary, but you can have multiple entity_ids in the text. Use a comma to seperate them.

Nice work! Do you have finish the other automation for synch the alarm time in HA?

Okay so here is my Siri Shortcut that provides an all in one solution to get my iOS alarm synced to home assistant.
https://www.icloud.com/shortcuts/587916c45580406f976f69f02012ebd5

You’ll need to set two helpers in Home Assistant:

  • An input_boolean entity that keeps track of the on/off state of your alarm. Called ‘input_boolean.wekker_jannick_status’ in my case
  • An input_datetime entity that keeps track of the time of your alarm. Called ‘input_datetime. wekker_jannick’ in my case. See the docs only_time example

Then you’ll need to make sure that the names match with the ones in the Shortcut.

Lastly, I have configured some ‘Personal Automations’ in the iOS shortcut app. One that turns off the alarm status input_boolean when the alarm on the iOS device is stopped after it rang. And two personal automations that just run the ‘Alarm in HA’ shortcut whenever I close the alarm clock app or turn on don’t disturb mode (Usually when I’m going to sleep).

Here’s a demo video of the personal automations and the working of the shortcut.

If you have any questions, something is unclear or any suggestions, let me know.

1 Like

Hello,
I don’t have so many time the last day to test your Siri Shortcut. Today I have test And it work fine but I have like 5 or 6 alarms in my IPhone and the Siri shortcut take only the first alarm. I don’t know why.

Hello,
I don’t have so many time the last day to test your Siri Shortcut. Today I have test And it work fine but I have like 5 or 6 alarms in my IPhone and the Siri shortcut take only the first alarm. I don’t know why.

Nice that it’s working. The reason that it only syncs the time of the first alarm is because this shortcut gets the first out of all alarms. You can change this to ‘ask every time when running’ or take the last one in the list of your iOS alarms.

Btw, where do you use the to HomeAssistant synchronized time of the iOS alarm for? I use it to wake me up in the morning with an artificial sunrise on my hue light in the bedroom.

Here’s a video that shows where you can change in the shortcut from first item to ask every time. https://streamable.com/6zypq5

hello I have seen your siri shortcute for alarm clock in home assistant very nice but I have a question I am not getting to the input_boolean.wekker_jannick_status how to make it and then also the 'input_datetime. wekker_jannick how to make this would you be able to share it would be very nice? I found the input but how is the automation made can you share it smoothly? thanks in advance?

Input_boolean and input_datetime are helpers they can be created from the user interface. For more general information on input_booleans have a look at the docs. Same for input_datetime. If you would like to learn more about helpers in home assistant, take a look at this YouTube video.
The way that I use the helpers here in this situation is that the input boolean just keep track of the state (on / off) of my alarm clock and the input_datetime does that for the time.
What is it you would like to set up? Could you specify what you want me to explain or where I could help you with?

@DutchDeffy his is awesome but for some reason I get an error saying it’s not in the correct format, any clue on why that is?

Also can this be used with the “bedtime” alarm?

EDIT: It seems to stop at the “Call input_datetime.set_datetime with data” part.

EDIT2: So in HA logs I get

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/mobile_app/webhook.py", line 221, in webhook_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1434, in async_call
    processed_data = handler.schema(service_data)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/validators.py", line 218, in __call__
    return self._exec((Schema(val) for val in self.validators), v)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/validators.py", line 341, in _exec
    raise e if self.msg is None else AllInvalid(self.msg, path=path)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/validators.py", line 337, in _exec
    v = func(v)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py", line 817, in validate_callable
    return schema(data)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py", line 594, in validate_dict
    return base_validate(path, iteritems(data), out)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py", line 432, in validate_mapping
    raise er.MultipleInvalid(errors)
voluptuous.error.MultipleInvalid: Invalid time specified:  for dictionary value @ data['time']

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/webhook/__init__.py", line 96, in async_handle_webhook
    response = await webhook["handler"](hass, webhook_id, request)
  File "/usr/src/homeassistant/homeassistant/components/mobile_app/webhook.py", line 205, in handle_webhook
    return await asyncio.shield(
  File "/usr/src/homeassistant/homeassistant/components/mobile_app/webhook.py", line 140, in validate_and_run
    return await func(hass, config_entry, data)
  File "/usr/src/homeassistant/homeassistant/components/mobile_app/webhook.py", line 235, in webhook_call_service
    raise HTTPBadRequest() from ex
aiohttp.web_exceptions.HTTPBadRequest: Bad Request

Hello,
First thing that comes to mind is, did you set up the input_datetime as only_time in Home Assistant?
Did you copy the shortcut from the url I shared? I think there might be something wrong with the dictionary and it’s variables set in the shortcuts app before the input_datetime.set_datetime service is called.

Yeah I use the “helper” and put it as “Time”. Does it still work for you with the latest version of iOS? I had problem with another Shortcut that syncs time as well, might be something broken on the iOS part?