immersive-home/docs/reference/lib--globals--home_api.md

145 lines
11 KiB
Markdown
Raw Normal View History

2024-03-16 19:45:43 +02:00
# HomeApi
**Inherits:** [Node](https://docs.godotengine.org/de/4.x/classes/class_node.html)
2024-03-16 19:45:43 +02:00
2024-03-17 01:14:31 +02:00
## Description
2024-03-16 19:45:43 +02:00
2024-03-17 01:14:31 +02:00
Manages the connection to the home automation system and provides a unified interface to the different home automation systems.
2024-03-16 19:45:43 +02:00
## Properties
2024-04-26 18:41:52 +03:00
| Name | Type | Default |
| ---------------------- | ------------------------------------------------------------------------- | ------- |
| [api](#prop-api) | [Node](https://docs.godotengine.org/de/4.x/classes/class_node.html) | |
| [groups](#prop-groups) | [Variant](https://docs.godotengine.org/de/4.x/classes/class_variant.html) | |
2024-03-16 19:45:43 +02:00
## Methods
| Returns | Name |
| ------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| void | [_on_connect](#-on-connect) ( ) |
| void | [_on_disconnect](#-on-disconnect) ( ) |
| void | [_ready](#-ready) ( ) |
| [Variant](https://docs.godotengine.org/de/4.x/classes/class_variant.html) | [get_device](#get-device) ( id: [String](https://docs.godotengine.org/de/4.x/classes/class_string.html) ) |
| [Variant](https://docs.godotengine.org/de/4.x/classes/class_variant.html) | [get_devices](#get-devices) ( ) |
2024-04-26 18:41:52 +03:00
| [Variant](https://docs.godotengine.org/de/4.x/classes/class_variant.html) | [get_history](#get-history) ( entity_id: [Variant](https://docs.godotengine.org/de/4.x/classes/class_variant.html), start: [Variant](https://docs.godotengine.org/de/4.x/classes/class_variant.html), end: [Variant](https://docs.godotengine.org/de/4.x/classes/class_variant.html) ) |
2024-03-16 19:45:43 +02:00
| [Variant](https://docs.godotengine.org/de/4.x/classes/class_variant.html) | [get_state](#get-state) ( entity: [String](https://docs.godotengine.org/de/4.x/classes/class_string.html) ) |
2024-03-18 14:30:37 +02:00
| [VoiceHandler](/reference/lib--home_apis--voice_handler.html) | [get_voice_assistant](#get-voice-assistant) ( ) |
2024-03-16 19:45:43 +02:00
| [Variant](https://docs.godotengine.org/de/4.x/classes/class_variant.html) | [has_connected](#has-connected) ( ) |
2024-03-18 14:30:37 +02:00
| [bool](https://docs.godotengine.org/de/4.x/classes/class_bool.html) | [has_integration](#has-integration) ( ) |
2024-03-16 19:45:43 +02:00
| [Variant](https://docs.godotengine.org/de/4.x/classes/class_variant.html) | [set_state](#set-state) ( entity: [String](https://docs.godotengine.org/de/4.x/classes/class_string.html), state: [Variant](https://docs.godotengine.org/de/4.x/classes/class_variant.html), attributes: [Dictionary](https://docs.godotengine.org/de/4.x/classes/class_dictionary.html) ) |
| void | [start_adapter](#start-adapter) ( type: [String](https://docs.godotengine.org/de/4.x/classes/class_string.html), url: [String](https://docs.godotengine.org/de/4.x/classes/class_string.html), token: [String](https://docs.godotengine.org/de/4.x/classes/class_string.html) ) |
2024-03-18 14:30:37 +02:00
| void | [update_room](#update-room) ( room: [String](https://docs.godotengine.org/de/4.x/classes/class_string.html) ) |
2024-03-16 19:45:43 +02:00
| [Variant](https://docs.godotengine.org/de/4.x/classes/class_variant.html) | [watch_state](#watch-state) ( entity: [String](https://docs.godotengine.org/de/4.x/classes/class_string.html), callback: [Callable](https://docs.godotengine.org/de/4.x/classes/class_callable.html) ) |
## Signals
### on_connect ( ) {#on-connect}
2024-03-17 01:14:31 +02:00
Emitted when the connection to the home automation system is established
### on_disconnect ( ) {#on-disconnect}
2024-03-17 01:14:31 +02:00
Emitted when the connection to the home automation system is lost
2024-03-17 01:14:31 +02:00
## Constants
### Hass = `<Object>` {#const-Hass}
No description provided yet.
2024-04-26 18:41:52 +03:00
### EntityGroups = `<Object>` {#const-EntityGroups}
No description provided yet.
### HassWebSocket = `<Object>` {#const-HassWebSocket}
No description provided yet.
2024-03-18 14:30:37 +02:00
### VoiceAssistant = `<Object>` {#const-VoiceAssistant}
No description provided yet.
### apis = `{"hass": <Object>, "hass_ws": <Object>}` {#const-apis}
No description provided yet.
2024-03-17 01:14:31 +02:00
### methods = `[
"get_devices",
"get_device",
"get_state",
"set_state",
"watch_state"
]` {#const-methods}
No description provided yet.
2024-03-16 19:45:43 +02:00
## Property Descriptions
2024-03-17 01:14:31 +02:00
### api: [Node](https://docs.godotengine.org/de/4.x/classes/class_node.html) {#prop-api}
2024-03-16 19:45:43 +02:00
2024-03-17 01:14:31 +02:00
The current home automation system adapter
2024-03-16 19:45:43 +02:00
2024-04-26 18:41:52 +03:00
### groups: [Variant](https://docs.godotengine.org/de/4.x/classes/class_variant.html) {#prop-groups}
No description provided yet.
2024-03-16 19:45:43 +02:00
## Method Descriptions
2024-03-17 01:14:31 +02:00
### _on_connect ( ) -> void {#-on-connect}
2024-03-16 19:45:43 +02:00
No description provided yet.
2024-03-17 01:14:31 +02:00
### _on_disconnect ( ) -> void {#-on-disconnect}
2024-03-16 19:45:43 +02:00
No description provided yet.
2024-03-17 01:14:31 +02:00
### _ready ( ) -> void {#-ready}
2024-03-16 19:45:43 +02:00
No description provided yet.
2024-03-17 01:14:31 +02:00
### get_device (id: [String](https://docs.godotengine.org/de/4.x/classes/class_string.html) ) -> [Variant](https://docs.godotengine.org/de/4.x/classes/class_variant.html) {#get-device}
2024-03-16 19:45:43 +02:00
Get a single device by id
2024-03-17 01:14:31 +02:00
### get_devices ( ) -> [Variant](https://docs.godotengine.org/de/4.x/classes/class_variant.html) {#get-devices}
2024-03-16 19:45:43 +02:00
Get a list of all devices
2024-04-26 18:41:52 +03:00
### get_history (entity_id: [Variant](https://docs.godotengine.org/de/4.x/classes/class_variant.html) , start: [Variant](https://docs.godotengine.org/de/4.x/classes/class_variant.html) , end: [Variant](https://docs.godotengine.org/de/4.x/classes/class_variant.html) ) -> [Variant](https://docs.godotengine.org/de/4.x/classes/class_variant.html) {#get-history}
No description provided yet.
2024-03-17 01:14:31 +02:00
### get_state (entity: [String](https://docs.godotengine.org/de/4.x/classes/class_string.html) ) -> [Variant](https://docs.godotengine.org/de/4.x/classes/class_variant.html) {#get-state}
2024-03-16 19:45:43 +02:00
Returns the current state of an entity
2024-03-18 14:30:37 +02:00
### get_voice_assistant ( ) -> [VoiceHandler](/reference/lib--home_apis--voice_handler.html) {#get-voice-assistant}
Returns the VoiceHandler if the adapter has a voice assistant
2024-03-17 01:14:31 +02:00
### has_connected ( ) -> [Variant](https://docs.godotengine.org/de/4.x/classes/class_variant.html) {#has-connected}
2024-03-16 19:45:43 +02:00
2024-03-17 01:14:31 +02:00
Returns true if the adapter is connected to the home automation system
2024-03-16 19:45:43 +02:00
2024-03-18 14:30:37 +02:00
### has_integration ( ) -> [bool](https://docs.godotengine.org/de/4.x/classes/class_bool.html) {#has-integration}
Returns true if the adapter has an integration in the home automation system allowing to send the room position of the headset.
2024-03-17 01:14:31 +02:00
### set_state (entity: [String](https://docs.godotengine.org/de/4.x/classes/class_string.html) , state: [Variant](https://docs.godotengine.org/de/4.x/classes/class_variant.html) , attributes: [Dictionary](https://docs.godotengine.org/de/4.x/classes/class_dictionary.html) ) -> [Variant](https://docs.godotengine.org/de/4.x/classes/class_variant.html) {#set-state}
2024-03-16 19:45:43 +02:00
Updates the state of the entity and returns the resulting state
2024-03-17 01:14:31 +02:00
### start_adapter (type: [String](https://docs.godotengine.org/de/4.x/classes/class_string.html) , url: [String](https://docs.godotengine.org/de/4.x/classes/class_string.html) , token: [String](https://docs.godotengine.org/de/4.x/classes/class_string.html) ) -> void {#start-adapter}
2024-03-16 19:45:43 +02:00
2024-03-17 01:14:31 +02:00
Starts the adapter for the given type and url
2024-03-16 19:45:43 +02:00
2024-03-18 14:30:37 +02:00
### update_room (room: [String](https://docs.godotengine.org/de/4.x/classes/class_string.html) ) -> void {#update-room}
Updates the room position of the headset in the home automation system
2024-03-17 01:14:31 +02:00
### watch_state (entity: [String](https://docs.godotengine.org/de/4.x/classes/class_string.html) , callback: [Callable](https://docs.godotengine.org/de/4.x/classes/class_callable.html) ) -> [Variant](https://docs.godotengine.org/de/4.x/classes/class_variant.html) {#watch-state}
2024-03-16 19:45:43 +02:00
Watches the state and each time it changes, calls the callback with the changed state, returns a function to stop watching the state