Fire a python script from an automation

test the script service, I have the hello_world.py example

name = data.get('name', 'world')
logger.info("Hello {}".format(name))
hass.bus.fire(name, { "wow": "from a Python script!" })

I call it from the developer tools with { “name”:“you”} and it works.
So now I was trying to create a call to the service from an automation and I don’t have the syntax right. (hassctl config chokes)
what should my action look like?
Here is what I have now …

  - alias: test script
    trigger:
      - platform: template
        value_template: "{% if not is_state('input_select.thermostat_mode', 'off') %}true{% endif %}"
    action:
      - service: python_script.hello_world
        name: Paul

close

  - alias: test script
    trigger:
      - platform: template
        value_template: "{% if not is_state('input_select.thermostat_mode', 'off') %}true{% endif %}"
    action:
      service: python_script.hello_world
      data:
        name: Paul

I think that will work.

Getting close. I switched my literal for variable or at least I thought. It did not evaluate, but passed as a literal.
Here is where I am at right now …

  - alias: test script
    trigger:
      - platform: template
        value_template: "{% if not is_state('input_select.thermostat_mode', 'off') %}true{% endif %}"
    action:
      - service: python_script.hello_world
        data_template: 
          { "name": trigger.to_state.state }

trigger.to_state.state, I would have expected to be Cool, Heat, or Auto depending on the input_select.

Ok, got it to evaluate the trigger.to_state.state by using …’

        data_template: 
         name: "{{ trigger.to_state.state }}"

Here is my entire package. I was using a package that I was testing how to control climate.

input_select:
  thermostat_mode:
    name: Thermostat Mode
    options:
      - "Auto"
      - "Off"
      - "Cool"
      - "Heat"
    icon: mdi:target

group:
  thermostat_views:
    view: yes
    name: Thermostat
    entities:
    - group.thermostat_mode
  thermostat_mode:
    name: Thermostat Modes
    entities:
    - climate.2gig_technologies_ct101_thermostat_iris_cooling_1
    - sensor.thermostat_battery


sensor:
- platform: template
  sensors:
    thermostat_battery:
      friendly_name: "Thermostat Battery"
      unit_of_measurement: "%"
      value_template: >-
        {%- if states.zwave['2gig_technologies_ct101_thermostat_iris'].attributes.battery_level %}
            {{ states.zwave['2gig_technologies_ct101_thermostat_iris'].attributes.battery_level }}
        {% else %}
            Unknown
        {%- endif %}


automation:
  - alias: Set Thermostat Mode Off
    trigger:
      - platform: template
        value_template: "{% if is_state('input_select.thermostat_mode', 'off') %}true{% endif %}"
    action:
      - service: switch.turn_Off
        entity_id: switch.remotec_zfm80_switch
  - alias: Set Thermostat Mode On
    trigger:
      - platform: template
        value_template: "{% if not is_state('input_select.thermostat_mode', 'off') %}true{% endif %}"
    action:
      - service: switch.turn_on
        entity_id: switch.remotec_zfm80_switch
  - alias: Set Thermostat Mode
    trigger:
      - platform: state
        entity_id: input_select.thermostat_mode
    action:
      - service: climate.set_operation_mode
        entity_id: climate.2gig_technologies_ct101_thermostat_iris_cooling_1
        data_template:
          operation_mode: "{{ trigger.to_state.state }}"
  - alias: test script
    trigger:
      - platform: template
        value_template: "{% if not is_state('input_select.thermostat_mode', 'off') %}true{% endif %}"
    action:
      - service: python_script.hello_world
        data_template: 
          name: "{{ trigger.to_state.state }}"
#{{ "name":"paul" }}
#{{ states.climate['2gig_technologies_ct101_thermostat_iris_cooling_1'].state }}
#{"entity_id": "climate.2gig_technologies_ct101_thermostat_iris_cooling_1", "operation_mode": "Off"}

So I have 3 automations and all three fire the first time, but then only one fires after that
Here is the log, you can see it at the end.

2017-07-12 15:13:05 INFO (Dummy-12) [homeassistant.components.zwave] Z-Wave network is complete. All nodes on the network have been queried
2017-07-12 15:13:05 INFO (Thread-1) [homeassistant.components.zwave] Z-Wave ready after 5 seconds
2017-07-12 15:13:05 INFO (Thread-1) [homeassistant.components.zwave] Z-Wave polling interval set to 60000 ms
2017-07-12 15:14:05 INFO (MainThread) [homeassistant.components.automation] Executing Set Thermostat Mode On
2017-07-12 15:14:05 INFO (MainThread) [homeassistant.components.automation] Executing Set Thermostat Mode
2017-07-12 15:14:05 INFO (MainThread) [homeassistant.components.automation] Executing test script
2017-07-12 15:14:05 INFO (Thread-9) [homeassistant.components.python_script] Executing hello_world.py: {'name': 'Heat'}
2017-07-12 15:14:05 INFO (Thread-9) [homeassistant.components.python_script.hello_world.py] Hello World Started
2017-07-12 15:14:05 INFO (Thread-9) [homeassistant.components.python_script.hello_world.py] Hello Heat
2017-07-12 15:14:18 INFO (MainThread) [homeassistant.components.automation] Executing Set Thermostat Mode
2017-07-12 15:14:30 INFO (MainThread) [homeassistant.components.automation] Executing Set Thermostat Mode
2017-07-12 15:14:43 INFO (MainThread) [homeassistant.components.automation] Executing Set Thermostat Mode