Skip to content

sunnythaper/python_scripts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 

Repository files navigation

python_scripts

This repository contains Python scripts that can be used with the Home Assistant automation platform. Each script provides a unique functionality to extend the capabilities of your Home Assistant setup.

scene_generator.py

DEMO

scene generator walkthrough

OVERVIEW

The scene_generator.py script allows you to export your current entity states and attributes into the YAML format for Home Assistant Scenes. This is a powerful tool for creating scenes based on your current device configurations.

Here's how it works:

  1. Set individual lights, fans, switches, covers, etc. to your desired state for the scene.
  2. Call the scene_generator service with your custom service data, or leave it blank for default settings.
  3. If you set save_file to false, go to the Home Assistant logs to copy the generated YAML for the scene.
  4. If you set save_file to true, go to your configuration folder and open generated_scene.yaml.

This script allows you to specify either domains or entities directly. If both domains and entities are defined, the script will prioritize entities over domains.

EXAMPLE SERVICE DATA

example service call

domains:
  - light
  - switch
  - fan
entities:
  - light.living_room
  - switch.kitchen
attributes:
  - brightness
  - color_temp
  - xy_color
  - rgb_color
save_file: true

In this example, we're generating a scene for all light, switch, and fan entities defined in the domains, as well as specifically for light.living_room and switch.kitchen entities. It includes brightness, color temperature, and color attributes. If both domains and entities are defined, the script will process only the entities and ignore the domains.

FILE SAVING

If you would like scene_generator.py to save the generated scene directly to a file in the Home Assistant configuration directory, you'll need to set up a file notification in your Home Assistant configuration. Here's an example of how to do that:

notify:
  - name: scene_generator
    platform: file
    filename: generated_scene.yaml
    timestamp: false

In this configuration, the generated scene will be saved to a file named generated_scene.yaml in your Home Assistant configuration directory. The timestamp option is set to false, meaning that timestamps will not be included in the generated file.

About

Sunny's collection of Home Assistant python scripts

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages