No release in over 3 years
Used to connect Legion to Home Assistant
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

 Project Readme

lex-home-assistant

LegionIO extension for Home Assistant integration via the Home Assistant REST API.

Installation

Add to your Gemfile:

gem 'lex-home-assistant'

Standalone Usage

require 'legion/extensions/home_assistant'

client = Legion::Extensions::HomeAssistant::Client.new(
  url:   'http://homeassistant.local:8123/api',
  token: 'your-long-lived-access-token'
)

# Entities
client.list_entities
client.get_entity(entity_id: 'light.living_room')

# Services
client.list_services
client.call_service(domain: 'light', service: 'turn_on', entity_id: 'light.living_room')
client.call_service(domain: 'light', service: 'turn_on', entity_id: 'light.living_room', data: { brightness: 200 })

# States
client.get_state(entity_id: 'sensor.temperature')
client.set_state(entity_id: 'sensor.temperature', state: '21.5', attributes: { unit_of_measurement: '°C' })

Authentication

Home Assistant requires a long-lived access token passed as a Bearer token in the Authorization header. Generate a token from your Home Assistant profile page under Long-Lived Access Tokens.

License

MIT