Skip to content

HomeApi ​

Inherits: Node

Description ​

Manages the connection to the home automation system and provides a unified interface to the different home automation systems.

Properties ​

NameTypeDefault
_synced_floor_planString""
apiNode
api_typeString""
floor_plan_timerTimer
groupsVariant
reconnect_timerTimer

Methods ​

ReturnsName
Variant_build_demo_house ( )
Variant_on_connect ( )
Variant_on_disconnect ( )
Variant_on_integration_ready ( )
void_ready ( )
Variant_use_house_of ( type: String )
Variantget_device ( id: String )
Variantget_devices ( )
Arrayget_entity_ids ( domains: Array )
Variantget_history ( entity_id: Variant, start: Variant, interval: Variant, end: Variant = null )
Stringget_http_url ( )
Variantget_state ( entity: String )
Dictionaryget_state_history ( entity_ids: Array, start: String, end: Variant = null )
Arrayget_todo_items ( entity_id: String )
VoiceHandlerget_voice_assistant ( )
Varianthas_connected ( )
boolhas_integration ( )
boolis_demo ( )
Variantset_state ( entity: String, state: Variant, attributes: Dictionary = {} )
Variantstart ( )
Variantstart_adapter ( type: String, url: String, token: String )
Variantstart_demo ( )
Variantstop_demo ( )
voidsync_floor_plan ( )
Variantunwatch_owner ( target: Object )
voidupdate_room ( room: String )
Variantwatch_state ( entity: String, callback: Callable )

Signals ​

on_connect ( ) ​

Emitted when the connection to the home automation system is established

on_disconnect ( ) ​

Emitted when the connection to the home automation system is lost

Constants ​

Demo = <Object> ​

No description provided yet.

DemoHouse = <Object> ​

No description provided yet.

EntityGroups = <Object> ​

No description provided yet.

FLOOR_PLAN_SYNC_DELAY = 2.0 ​

Seconds to wait after the house changed before syncing the floor plan, moving things around saves the house many times in a row.

FloorPlan = <Object> ​

No description provided yet.

HassWebSocket = <Object> ​

No description provided yet.

HouseStore = <Object> ​

No description provided yet.

VoiceAssistant = <Object> ​

No description provided yet.

apis = {"demo": <Object>, "hass_ws": <Object>} ​

No description provided yet.

Property Descriptions ​

_synced_floor_plan: String ​

JSON of the floor plan Home Assistant last stored, to skip unchanged syncs

api: Node ​

The current home automation system adapter

api_type: String ​

Type of the current adapter, a key of apis

floor_plan_timer: Timer ​

No description provided yet.

groups: Variant ​

No description provided yet.

reconnect_timer: Timer ​

No description provided yet.

Method Descriptions ​

_build_demo_house ( ) -> Variant ​

Saves the demo apartment, built around where the user is standing.

_on_connect ( ) -> Variant ​

No description provided yet.

_on_disconnect ( ) -> Variant ​

No description provided yet.

_on_integration_ready ( ) -> Variant ​

A fresh connection: push the floor plan even if it didn't change, Home Assistant may have lost it or another headset may have replaced it in the meantime.

_ready ( ) -> void ​

No description provided yet.

_use_house_of (type: String ) -> Variant ​

The demo mode keeps its own house, so it never changes the real one.

get_device (id: String ) -> Variant ​

Get a single device by id

get_devices ( ) -> Variant ​

Get a list of all devices

get_entity_ids (domains: Array ) -> Array ​

Ids of all entities in domains, e.g. ["person", "device_tracker"].

get_history (entity_id: Variant , start: Variant , interval: Variant , end: Variant = null ) -> Variant ​

No description provided yet.

get_http_url ( ) -> String ​

Returns the HTTP(S) base URL of the home automation server, without a trailing slash, or an empty string if the adapter does not expose one.

get_state (entity: String ) -> Variant ​

Returns the current state of an entity

get_state_history (entity_ids: Array , start: String , end: Variant = null ) -> Dictionary ​

Recorded states with attributes of several entities since start (ISO time): {entity_id: [{state, attributes, time}]}, oldest first. Empty if the adapter has no history.

get_todo_items (entity_id: String ) -> Array ​

Returns the items of a to-do list entity: [{uid, summary, status, due?}], or an empty array if the adapter can't list them.

get_voice_assistant ( ) -> VoiceHandler ​

Returns the VoiceHandler if the adapter has a voice assistant

has_connected ( ) -> Variant ​

Returns true if the adapter is connected to the home automation system

has_integration ( ) -> bool ​

Returns true if the adapter has an integration in the home automation system allowing to send the room position of the headset.

is_demo ( ) -> bool ​

Returns true while the demo mode runs, with made-up devices instead of a real home automation system.

set_state (entity: String , state: Variant , attributes: Dictionary = {} ) -> Variant ​

Updates the state of the entity and returns the resulting state

start ( ) -> Variant ​

Starts the adapter with the settings from the settings file

start_adapter (type: String , url: String , token: String ) -> Variant ​

Starts the adapter for the given type and url

start_demo ( ) -> Variant ​

Starts the demo mode with a freshly built demo apartment around the user. It's remembered, so the app starts in demo mode until stop_demo() is called.

stop_demo ( ) -> Variant ​

Leaves the demo mode and connects to the home automation system in the settings.

sync_floor_plan ( ) -> void ​

Sends the floor plan of the house (rooms, doors and the placed entities) to the home automation system, if it has an integration that stores it. Does nothing if the floor plan didn't change since the last sync.

unwatch_owner (target: Object ) -> Variant ​

Stops every state watch whose callback belongs to target. Entities call this when they are freed, so Home Assistant updates never reach a freed node.

update_room (room: String ) -> void ​

Updates the room position of the headset in the home automation system

watch_state (entity: String , callback: Callable ) -> Variant ​

Watches the state and each time it changes, calls the callback with the changed state, returns a function to stop watching the state