Skip to content

SimulatedApi ​

Inherits: Node

Description ​

In-memory stand-in for the Home Assistant adapter (lib/home_apis/hass_ws/hass.gd).

Implements the same interface HomeApi forwards to, so entities can run without a server. set_state() simulates what the matching Home Assistant service would do and notifies watchers, so toggling a light really turns it on. Used by the entity gallery (test/content/entities) and, extended, by the demo mode (./demo.gd).

Properties ​

NameTypeDefault
_cover_movesDictionary{}
callsArray[]
devicesArray[]
entitiesDictionary{}
entity_callbacksCallbackMap

Methods ​

ReturnsName
String_format_duration ( seconds: float )
void_init ( initial_states: Dictionary = {} )
Variant_install_update ( entity: String )
Variant_move_cover ( entity: String, move_id: int, target: int )
Dictionary_normalize ( state: Dictionary )
int_parse_duration ( text: Variant )
Variant_simulate_alarm ( entity: String, current: Dictionary, state: Variant, service_data: Dictionary )
Variant_simulate_climate ( current: Dictionary, state: Variant, service_data: Dictionary )
Variant_simulate_cover ( entity: String, current: Dictionary, state: Variant, service_data: Dictionary )
Variant_simulate_fan ( current: Dictionary, state: Variant, service_data: Dictionary )
Variant_simulate_humidifier ( current: Dictionary, state: Variant, service_data: Dictionary )
Variant_simulate_light ( current: Dictionary, state: Variant, service_data: Dictionary )
Variant_simulate_lock ( entity: String, current: Dictionary, state: Variant )
Variant_simulate_media_player ( current: Dictionary, state: Variant, service_data: Dictionary )
Variant_simulate_timer ( current: Dictionary, state: Variant )
Variant_simulate_update ( entity: String, current: Dictionary, state: Variant )
Variant_simulate_vacuum ( entity: String, current: Dictionary, state: Variant, service_data: Dictionary )
Variant_simulate_water_heater ( current: Dictionary, state: Variant, service_data: Dictionary )
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 )
Variantget_todo_items ( entity_id: String )
Variantget_voice_assistant ( )
Varianthas_connected ( )
Varianthas_integration ( )
Variantset_state ( entity: String, state: Variant, attributes: Dictionary = {} )
Variantunwatch_owner ( target: Object )
Variantupdate_entity ( entity: String, state: Variant, attributes: Dictionary = {}, merge: bool = true )
Variantupdate_room ( _room: String )
Variantwatch_state ( entity: String, callback: Callable )

Signals ​

on_call (entity: String , state: Variant , attributes: Dictionary ) ​

No description provided yet.

on_connect ( ) ​

No description provided yet.

on_disconnect ( ) ​

No description provided yet.

Property Descriptions ​

_cover_moves: Dictionary ​

Increases on every cover command, so a running movement notices it was replaced.

calls: Array ​

Every service call an entity made, newest last: {entity, state, attributes}.

devices: Array ​

Devices in the shape of the Home Assistant adapter's get_devices() (see hass_ws/templates/devices.j2): [{id, name, area, manufacturer, model, entities: [{id, name}]}]

entities: Dictionary ​

No description provided yet.

entity_callbacks: CallbackMap ​

No description provided yet.

Method Descriptions ​

static _format_duration (seconds: float ) -> String ​

No description provided yet.

_init (initial_states: Dictionary = {} ) -> void ​

No description provided yet.

_install_update (entity: String ) -> Variant ​

No description provided yet.

_move_cover (entity: String , move_id: int , target: int ) -> Variant ​

No description provided yet.

_normalize (state: Dictionary ) -> Dictionary ​

No description provided yet.

static _parse_duration (text: Variant ) -> int ​

No description provided yet.

_simulate_alarm (entity: String , current: Dictionary , state: Variant , service_data: Dictionary ) -> Variant ​

Arming takes a moment ("arming"), disarming is immediate. A code_format panel checks the code against "_code".

_simulate_climate (current: Dictionary , state: Variant , service_data: Dictionary ) -> Variant ​

No description provided yet.

_simulate_cover (entity: String , current: Dictionary , state: Variant , service_data: Dictionary ) -> Variant ​

Covers move 10 % every 0.3 s and report opening/closing meanwhile. Covers without current_position switch after a second.

_simulate_fan (current: Dictionary , state: Variant , service_data: Dictionary ) -> Variant ​

No description provided yet.

_simulate_humidifier (current: Dictionary , state: Variant , service_data: Dictionary ) -> Variant ​

No description provided yet.

_simulate_light (current: Dictionary , state: Variant , service_data: Dictionary ) -> Variant ​

No description provided yet.

_simulate_lock (entity: String , current: Dictionary , state: Variant ) -> Variant ​

Locks report "locking"/"unlocking" first and settle a moment later, like real ones.

_simulate_media_player (current: Dictionary , state: Variant , service_data: Dictionary ) -> Variant ​

No description provided yet.

_simulate_timer (current: Dictionary , state: Variant ) -> Variant ​

No description provided yet.

_simulate_update (entity: String , current: Dictionary , state: Variant ) -> Variant ​

Installs in 10 % steps, then reports the latest version as installed.

_simulate_vacuum (entity: String , current: Dictionary , state: Variant , service_data: Dictionary ) -> Variant ​

No description provided yet.

_simulate_water_heater (current: Dictionary , state: Variant , service_data: Dictionary ) -> Variant ​

No description provided yet.

get_device (_id: String ) -> Variant ​

No description provided yet.

get_devices ( ) -> Variant ​

No description provided yet.

get_entity_ids (domains: Array ) -> Array ​

No description provided yet.

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

Fake hourly statistics: a smooth curve around the entity's current value.

get_http_url ( ) -> String ​

No description provided yet.

get_state (entity: String ) -> Variant ​

No description provided yet.

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

Made-up position history: every 10 minutes along a wandering route from the home zone to the current position (the same route every time for an entity).

get_todo_items (entity_id: String ) -> Variant ​

To-do items are kept in the entity's "_items" attribute.

get_voice_assistant ( ) -> Variant ​

No description provided yet.

has_connected ( ) -> Variant ​

No description provided yet.

has_integration ( ) -> Variant ​

No description provided yet.

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

No description provided yet.

unwatch_owner (target: Object ) -> Variant ​

No description provided yet.

update_entity (entity: String , state: Variant , attributes: Dictionary = {} , merge: bool = true ) -> Variant ​

Replaces the state of entity like a Home Assistant state_changed event would.

update_room (_room: String ) -> Variant ​

No description provided yet.

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

No description provided yet.