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.
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:
- Set individual lights, fans, switches, covers, etc. to your desired state for the scene.
- Call the
scene_generator
service with your custom service data, or leave it blank for default settings. - If you set
save_file
to false, go to the Home Assistant logs to copy the generated YAML for the scene. - If you set
save_file
to true, go to your configuration folder and opengenerated_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.
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.
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.