Run script from automation

I have some python scripts in the python_scripts directory. I need no input into the script, only to run it from automation. Does somebody have an example for it? If i run them from commandline they work, so i only need an automation config.
Thnx for the support!

Here is one of mine, hope that helps:

- id: refresh vncsnapshot
  trigger:  
  - platform: homeassistant
    event: start
  action:
  - service: python_script.refresh_vncsnapshot
1 Like

Thanks for the reply! when i paste your code it works. My code is the following:

- alias: 'Last payouts'
  hide_entity: true
  trigger:
    platform: event
    event_type: telegram_command
    event_data:
      command: '/status'
  action:
    - service: python_script.bittrex-minerpayment

I have this already working for reply messages for other commands from telegram. But now when i check the config i get the following:

Invalid config for [automation]: Service python_script.bittrex-minerpayment does not match format <domain>.<name> for dictionary value @ data['action'][0]['service']. Got None. (See /config/configuration.yaml, line 197). Please check the docs at https://home-assistant.io/components/automation/

Try changing the dash to an underscore in the name of your python script and see if that works.

1 Like

Thanks for fast reply! this was the trick to accept the configuration.

The script is in the folder: config/python_scripts

I get the error below, is this the correct location? Also changed the automation line to python_scripts but same error

2019-04-17 20:53:17 ERROR (MainThread) [homeassistant.components.automation] Error while executing automation automation.automation_4. Service not found for call_service at pos 1: (ServiceNotFound(...), 'Service python_script.bittrex_minerpayments not found')

Did you try restarting HA after the change in script file name?

1 Like

Yes i restartes ha

Try calling this from dev-service: python_script.reload. You can also call it directly from the dev-service page, rather than modifying, reloading, and triggering the automation.

1 Like