From 9a886d65cd8543c8a8ebb900f13317ee0deda18a Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Fri, 27 Sep 2019 11:48:58 -0700 Subject: [PATCH] Add reproduce state page --- docs/reproduce_state_index.md | 26 ++++++++++++++++++++++++++ website/i18n/en.json | 3 +++ website/sidebars.json | 3 ++- 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 docs/reproduce_state_index.md diff --git a/docs/reproduce_state_index.md b/docs/reproduce_state_index.md new file mode 100644 index 00000000..0f63efd4 --- /dev/null +++ b/docs/reproduce_state_index.md @@ -0,0 +1,26 @@ +--- +title: "Reproduce State / Scene support" +--- + +Home Assistant has support for scenes. Scenes are a collection of (partial) entity states. When a scene is activated, Home Assistant will try to call the right services to get the specified scenes in their specified state. + +Integrations are responsible for adding support to Home Assistant to be able to call the right services to reproduce the states in a scene. + +## Adding support + +The quickest way to add reproduce state support to a new integration is by using our built-in scaffold template. From a Home Assistant dev environment, run `python3 -m script.scaffold reproduce_state` and follow the instructions. + +If you prefer to go the manual route, create a new file in your integration folder called `reproduce_state.py` and implement the following method: + +```python +import asyncio +from typing import Iterable, Optional +from homeassistant.core import Context, State +from homeassistant.helpers.typing import HomeAssistantType + +async def async_reproduce_states( + hass: HomeAssistantType, states: Iterable[State], context: Optional[Context] = None +) -> None: + """Reproduce component states.""" + # TODO reproduce states +``` diff --git a/website/i18n/en.json b/website/i18n/en.json index 854569ef..441cffb6 100644 --- a/website/i18n/en.json +++ b/website/i18n/en.json @@ -412,6 +412,9 @@ "releasing": { "title": "Releasing" }, + "reproduce_state_index": { + "title": "Reproduce State / Scene support" + }, "version-0.72/version-0.72-architecture_components": { "title": "Components Architecture", "sidebar_label": "Components" diff --git a/website/sidebars.json b/website/sidebars.json index c335a7ea..8a1edc28 100644 --- a/website/sidebars.json +++ b/website/sidebars.json @@ -71,7 +71,8 @@ "configuration_yaml_index", "dev_101_services", "creating_platform_index", - "creating_component_generic_discovery" + "creating_component_generic_discovery", + "reproduce_state_index" ], "Development Checklist": [ "development_checklist",