Automation calling a script not firing

Im having problems with what I thought was a pretty basic presence based automation.
Presence detection is handled by the sky hub component, and I use the following automation to set an input select to either Home or Away

- alias: Presence detection
  initial_state: 'on'
  hide_entity: False
  trigger:
    - platform: state
      entity_id: device_tracker.rich_phone_s8

  action:
    - service: input_select.select_option
      entity_id: input_select.home_mode
      data_template:
        option: >
          {% if is_state('device_tracker.rich_phone_s8', 'home') %}
          Home
          {% elif is_state('device_tracker.rich_phone_s8', 'not_home') %}
          Away
          {% endif %}

I then have an automations_home-modes.yaml file:

######################################################################
##  Away Mode
######################################################################

- alias: Home Mode Away
  initial_state: 'on'
  hide_entity: False
  trigger:
    - platform: state
      entity_id: input_select.home_mode
      to: 'Away'
      for: '00:05:00'

  action:
    - service: script.turn_on
      entity_id: script.home_mode_away


#####################################################################
##  Home Mode
######################################################################

- alias: Home Mode Home
  initial_state: 'on'
  hide_entity: False
  trigger:
    - platform: state
      entity_id: input_select.home_mode
      to: 'Home'
      
  action:
    - service: script.turn_on
      entity_id: script.home_mode_home

and the scripts for home and away mode:

home_mode_away:
  sequence:
    - service: automation.turn_on
      entity_id:
        - automation.intruder
        
    - service: automation.turn_off
      entity_id:
        - automation.motion_lights_bedroom_full
        - automation.bedroom_lights_off_after_10
        - automation.evening_lights_on
        - automation.motion_lights_lounge_full
        - automation.lounge_lamp_off_after_10
home_mode_home:
  sequence:
    - service: automation.turn_off
      entity_id:
        - automation.intruder
        
    - service: automation.turn_on
      entity_id:
        - automation.motion_lights_bedroom_full
        - automation.bedroom_lights_off_after_10
        - automation.evening_lights_on
        - automation.motion_lights_lounge_full
        - automation.lounge_lamp_off_after_10

I can see that the device tracker is changing to not_home when I leave, and the input select is being set to Away, but the script.home_mode_away
I know the presence detection is working, as I have other automations that fire OK when I leave home (e.g. turn our lights left on etc.)

If I manually trigger the script it fires, and the automations are toggled on/off as I expect.
Am I missing something here?

I think your automations are using the wrong service.

EDIT
Removed incorrect instructions.

Ah OK, I suspected this, but I could not find any documentation on calling scripts in automations?
Has this changed in recent version of HA?
These automations and scripts fired perfect in the past (before updating to v0.88.x)

OOPS! I’m wrong!

I don’t know what I was thinking! You can definitely execute a script using script.turn_on.

Im going to try it as you state above, as im fresh out of other ideas!

You’re welcome to try it, but I just performed a test, using the Services page, and was able to execute a script using script_turn_on.

_turn_on

well, ive just checked from the services dev tab, and I can fire the script by calling the script.turn_on service.
but can also fire it by calling the service script.home_mode_home
im stuck!

OK, so both of us have confirmed the action: section of the automation is valid. If the action: never happens then it means there may be something wrong with the trigger: section.

Please post the configuration for input_select.home_mode.

agreed.
the trigger is initially device_tracker.rich_phone_s8 changing state. Data template will change an input select according to whether im home or away
The home mode automation is triggered by this input_select.home_mode
I can see in my frontend that this input select is correctly showing Away
The trigger for the “away mode” automation is the input select being at Away for 5 minutes…which it is…yet it does not fire?

Does your input_select look something like this?

input_select:
  home_mode:
    name: Home Mode
    options:
      - 'Away'
      - 'Home'

Are the options delimited by single-quotes? (Or double-quotes or no quotes at all?)

my input select looks like:

home_mode:
  name: Security Mode
  options:
   - Home
   - Away
   - Night
   - Vacation
  icon: mdi:home-modern

Im not convinced this is the problem, as it is selecting the correct option based on my presence?

I don’t know that this will solve the problem, but at the very least you should change:

      data_template:
        option: >
          {% if is_state('device_tracker.rich_phone_s8', 'home') %}
          Home
          {% elif is_state('device_tracker.rich_phone_s8', 'not_home') %}
          Away
          {% endif %}

to:

      data_template:
        option: >
          {% if is_state('device_tracker.rich_phone_s8', 'home') %}
          Home
          {% else %}
          Away
          {% endif %}

You should never have a potential for a service_template or data_template to return nothing. E.g., if the state of device_tracker.rich_phone_s8 ever changed to something other than home or not_home, which it would if you ever entered a zone other than zone.home, this automation wouldn’t work. Ending with an else clause will cause it to always return something, which in this case, is what I think you would want.

But getting back to the automation not triggering. There are only two possibilities that I can think of. The first is the automation is somehow off when the five minute interval expires. I see you have initial_state set to on, which is a good thing, but are you sure something else isn’t turning it off?

The other possibility is that input_select.home_mode is not staying in the Away state for a full five minutes. Could it possibly be changing to something else before five minutes is up (and, I guess, staying in some other state than Away)?

If none of that helps, then make sure you have logger set to debug (for everything), then analyze home-assistant.log. The details of what is, and isn’t, happening should be in there.

Thanks for the tip, I will change it as it makes sense, but I have no other zones set up and have never seen the device tracker show as anything other than home or not_home

Positive, if I check the state of the automation it shows as on

Again, positive this is not the case. As mentioned in the OP the input select is showing as being set to Away
logger is set to debut already, and having a look through, I don’t see anything obvious.
Ill take a closer look later…im actually away on business now, so this will have to be put on hold unfortunately.

I doubt this would be the case, but it is possible for it to change to something other than Away (e.g., unknown) so shortly you don’t see it, but even a microsecond would be enough to cause the 5 minute “for” period to restart. That’s why you really need to check the log. But, like I said, doubt that’s what’s happening. Good luck!