Scene_generator.py - Export YAML formatted state/attributes

Hi, looking forward to using this script to take a snapshot of my hue lights, but as a newbie to HA I am really struggling to get this working. Here’s my setup:

  1. Created a directory called python_scripts under the main config tree and copied the scene_generator.py file into it.

  2. added this line to the configuration.yaml file: python_script:

  3. created an automation which looks like this:

    alias: Hue snapshot
    description: ''
    trigger: []
    condition: []
    action:
      - service: python_script.scene_generator
    mode: single
    
  4. Note that I don’t know how to pass JSON in an automation, so I modified the script itself with my defaults like this:

    domains = 'light'
    attributes = ["brightness", "color_temp", "xy_color", "rgb_color"]
    save_file = 'true'
    
  5. Note that I tried true in quotes and without quotes. Either way I get this error:

    2021-12-05 08:01:44 ERROR (SyncWorker_3) [homeassistant.components.python_script.scene_generator.py] Error executing script: Unable to find service notify.scene_generator
    Traceback (most recent call last):
    File "/usr/src/homeassistant/homeassistant/components/python_script/__init__.py", line 222, in execute
     exec(compiled.code, restricted_globals)
      File "scene_generator.py", line 66, in <module>
      File "/usr/src/homeassistant/homeassistant/core.py", line 1401, in call
     return asyncio.run_coroutine_threadsafe(
      File "/usr/local/lib/python3.9/concurrent/futures/_base.py", line 445, in result
     return self.__get_result()
      File "/usr/local/lib/python3.9/concurrent/futures/_base.py", line 390, in __get_result
     raise self._exception
    File "/usr/src/homeassistant/homeassistant/core.py", line 1442, in async_call
     raise ServiceNotFound(domain, service) from None
    homeassistant.exceptions.ServiceNotFound: Unable to find service notify.scene_generator
    

Any advice on this would be greatly appreciated. I’d prefer to write to an output file but that doesn’t seem to work either. I am confused why it’s trying to call notify.scene_generator unless maybe that’s trying to write to a log file with the save_file = false ?

Thanks,

Dennis