| Title: | Interact with 'Home Assistant' |
|---|---|
| Description: | Provides tools to control smart home features via the API for 'Home Assistant' <https://developers.home-assistant.io/>. Allows for controlling states, services, and events. Supports configuring both local access and remote access. |
| Authors: | Christopher T. Kenny [aut, cre] (ORCID: <https://orcid.org/0000-0002-9386-6860>) |
| Maintainer: | Christopher T. Kenny <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.0.0.9000 |
| Built: | 2026-05-31 06:19:13 UTC |
| Source: | https://github.com/christopherkenny/ha |
Check if the API is running
ha_api(ip = NULL)ha_api(ip = NULL)
ip |
IP address. Default is |
A list containing the API information.
ha_api()ha_api()
Get Home Assistant configuration validity
ha_check_config(ip = NULL)ha_check_config(ip = NULL)
ip |
IP address. Default is |
A list containing the Home Assistant configuration check result.
ha_check_config()ha_check_config()
Remove Home Assistant State
ha_delete_states(entity_id, ip = NULL)ha_delete_states(entity_id, ip = NULL)
entity_id |
Entity ID. For example, |
ip |
IP address. Default is |
A list containing a confirmation message.
ha_set_states('rpkg.test', 'on') ha_delete_states('rpkg.test')ha_set_states('rpkg.test', 'on') ha_delete_states('rpkg.test')
Retrieve Home Assistant calendars
ha_get_calendars(ip = NULL)ha_get_calendars(ip = NULL)
ip |
IP address. Default is |
A list containing Home Assistant calendar information.
ha_get_calendars()ha_get_calendars()
Retrieve Home Assistant Configuration
ha_get_config(ip = NULL)ha_get_config(ip = NULL)
ip |
IP address. Default is |
A list containing the Home Assistant configuration.
ha_get_config()ha_get_config()
Retrieve Home Assistant Error Log
ha_get_error_log(ip = NULL)ha_get_error_log(ip = NULL)
ip |
IP address. Default is |
A character vector containing the Home Assistant error log.
ha_get_error_log()ha_get_error_log()
Retrieve Home Assistant Events
ha_get_events(ip = NULL)ha_get_events(ip = NULL)
ip |
IP address. Default is |
A list containing Home Assistant event information.
ha_get_events()ha_get_events()
Retrieve Home Assistant History
ha_get_history(entity_id, timestamp = NULL, ip = NULL)ha_get_history(entity_id, timestamp = NULL, ip = NULL)
entity_id |
Required. Entity ID. For example, |
timestamp |
Optional. Time in |
ip |
IP address. Default is |
A list containing Home Assistant history entries.
ha_get_history('update.home_assistant_core_update')ha_get_history('update.home_assistant_core_update')
Retrieve Home Assistant Logbook Entries
ha_get_logbook(timestamp = NULL, ip = NULL)ha_get_logbook(timestamp = NULL, ip = NULL)
timestamp |
Optional. Time in |
ip |
IP address. Default is |
A list containing Home Assistant logbook entries.
ha_get_logbook()ha_get_logbook()
Retrieve Home Assistant Services
ha_get_services(ip = NULL)ha_get_services(ip = NULL)
ip |
IP address. Default is |
A list containing Home Assistant service information.
ha_get_services()ha_get_services()
Retrieve Home Assistant States
ha_get_states(entity_id = NULL, ip = NULL)ha_get_states(entity_id = NULL, ip = NULL)
entity_id |
Optional. Entity ID. For example, |
ip |
IP address. Default is |
A list containing Home Assistant state information.
ha_get_states()ha_get_states()
Render a Home Assistant Template
ha_render_template(template, ip = NULL)ha_render_template(template, ip = NULL)
template |
a length one character vector containing the template to render. |
ip |
IP address. Default is |
A length one character vector containing the rendered template
ha_render_template("My living room light is {{ states('light.h6076') }}.")ha_render_template("My living room light is {{ states('light.h6076') }}.")
Set Home Assistant Events
ha_set_event(event_type, event_data = NULL, ip = NULL)ha_set_event(event_type, event_data = NULL, ip = NULL)
event_type |
The type of event to set, e.g. |
event_data |
Optional. A named list of data to send with the event. |
ip |
IP address. Default is |
A vector of events fired with a confirmation or detailed information
ha_set_event('light.test')ha_set_event('light.test')
Note that this requires use of "intents" for Home Assistant, which are not enabled by default. Using these without enabling them will create an error.
ha_set_intent(intent, ip = NULL)ha_set_intent(intent, ip = NULL)
intent |
an intent to fire |
ip |
IP address. Default is |
A list of intents
ha_set_intent(list(name = 'SetTimer', data = list(seconds = '30')))ha_set_intent(list(name = 'SetTimer', data = list(seconds = '30')))
Adds Home Assistant API key to .Renviron.
ha_set_key(key, overwrite = FALSE, install = FALSE, r_env = NULL)ha_set_key(key, overwrite = FALSE, install = FALSE, r_env = NULL)
key |
Character. API key to add to add. |
overwrite |
Defaults to FALSE. Boolean. Should existing |
install |
Defaults to FALSE. Boolean. Should this be added to an environment file, |
r_env |
Path to install to if |
key, invisibly
example_env <- tempfile(fileext = '.Renviron') ha_set_key('EXAMPLE-1234', r_env = example_env) # r_env should likely be: file.path(Sys.getenv('HOME'), '.Renviron')example_env <- tempfile(fileext = '.Renviron') ha_set_key('EXAMPLE-1234', r_env = example_env) # r_env should likely be: file.path(Sys.getenv('HOME'), '.Renviron')
Set Home Assistant Services
ha_set_services(domain, service, entity_id, ip = NULL)ha_set_services(domain, service, entity_id, ip = NULL)
domain |
An entity domain. For example, |
service |
A service name. For example, |
entity_id |
Entity ID. For example, |
ip |
IP address. Default is |
A list of changes made by the service call
ha_set_services('light', 'turn_off', 'light.h6076')ha_set_services('light', 'turn_off', 'light.h6076')
Set Home Assistant State
ha_set_states(entity_id, state, attributes = NULL, ip = NULL)ha_set_states(entity_id, state, attributes = NULL, ip = NULL)
entity_id |
Entity ID. For example, |
state |
A state value. For example, |
attributes |
Optional. A named list of attributes to set for the entity. |
ip |
IP address. Default is |
a list of information on the new or updated state
ha_set_states(entity_id = 'rpkg.test', state = 'on', attributes = list(version = '4.5.1'))ha_set_states(entity_id = 'rpkg.test', state = 'on', attributes = list(version = '4.5.1'))
Check or Get Home Assistant API Key
ha_has_key() ha_get_key()ha_has_key() ha_get_key()
logical if has, key if get
ha_has_key()ha_has_key()