iOS Shortcut to Trigger HA automation

I have just spent hours trying to do this with some Googling but I just can’t make it happen, please help.

I want to use iOS Shortcut app to trigger my bedtime routine automation immediately after my phone is plugged in at night time.

So I have a working automation in HA.

How do I use iOS shortcut app to trigger it once my phone is on charge??


Check how reliable the reporting of this sensor is first sensor.your_phone_name_battery_state. I find that it takes ages to update the charging state sensor for my phone, if it gets updated at all.

If you see a consistent and reliably punctual update of the sensor then it is just a matter of triggering an automation on this sensor state.

  - platform: state
    entity_id: sensor.your_phone_name_battery_state
    from: 'Not Charging'
    to: 'Charging'

You may want to include a time condition so it only triggers, say, after 9pm. Otherwise it will trigger if you charge your phone during the day.

  - condition: time
    after: '21:00:00'
1 Like

I’ve done something similar.

I’m using the “When turning Do Not Disturb on” automation from Shortcuts and triggering an Home Assistant Call Service a Dictionary shortcut property that contains entity_id: automation.name_of_automation and then passing this dictionary to Call automation.trigger with data.

I guess you can do the same with the “Charger → Is Connected” automation from Shortcuts.

I can send you some screenshots if you want.


I want the iOS shortcut app to be the trigger

Thanks yes could you post your screenshot to help me!?

Sure! In the Do field add a Dictionary and Call Service from HA and choose automation.trigger:

Then, in the Dictionary add new items like in the previous and this screenshot.

If you need anything else, let me know!

That’s great! That triggers the automation - sort of.

But curiously it is only triggering the ACTIONS of the automation and not respecting the conditions.

I only want it to run between 22:00 and 01:00, is my automation wrong? does that need to be on the iOS side?

This is my HA automation

alias: Bedroom Lights Off When On Charger
  description: ''
  trigger: []
  - condition: time
    after: '22:00'
    before: 01:00
  - type: turn_off
    device_id: 06bd47e93f1abe26b0368784fa68479a
    entity_id: light.michaels_lamp_2
    domain: light
  - type: turn_off
    device_id: 0445fcd7ec38524fe8793b22e197da85
    entity_id: light.shabs_lamp_2
    domain: light
  - type: turn_off
    device_id: d28a65b7497aa30d0d8ab5b278a22b5d
    entity_id: light.bedroom_lamp_2
    domain: light
  - service: sonos.set_sleep_timer
      entity_id: media_player.bedroom_sonos
      sleep_time: 1800
  mode: single

It should work both ways probably. I’d add a time condition in Shortctus app just to be safe and sane :stuck_out_tongue:

sorry to sounds useless

but i cant figure out how to do a time condition in iOS shortcuts

could you show me? please

No worries!

You’ll have to create an If Else statement that will check the time and then run the Call Service.

You’ll have to set all the above inside an If Else statement, and do something like this.

Here I’m getting the Current Date, and formating it to display the hour only. (That’s why I’m formating in HH).

Inside the first IF statement, you’ll have to create the Dictionary etc.

You’ll probably want to use is between instead of is greater than or equal to to check for time range.

Hope that helps!

wow! that is complicated for something so simple. but thanks… I’ll have a go.

it is really frustrating HA isn’t respecting the condition from the automation when triggered by iOS.

if anyone can come up with a fix for that in the future… greatly appreciated.

Is it possible to use IOS Shortcuts to trigger a node-red node within HA?

By default skip_condition is true

you need to add another key of type Boolean, with key name skip_condition and value False for the conditions to be respected in the automation.

I believe it is to do with your inconsistency.

  • condition: time
    after: ‘22:00’
    before: 01:00
    I believe either ‘01:00’ or 22:00 is needed to make it work. My guess without testing is ‘01:00’.

Having the condition dependcy in the automation means no duplication of functionality and if triggered by another means within HA it will still perform as expected.