home-assistant / home-assistant-js-websocket

:aerial_tramway: JavaScript websocket client for Home Assistant

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can this library be used to call services/fire events in HASS?

ChristopherLMiller opened this issue · comments

Trying to integrate home assistant into a dashboard app I'm building and its nice to get states of entities but I was wondering if I'm just being thick or is there not a way to fire events to home assistant from this?

You can't fire events since that's a developer thing. It's available via the Rest API.

Firing events is possible by sending a message as seen here: https://developers.home-assistant.io/docs/api/websocket/#fire-an-event

Example:

connection.sendMessage({
    type: 'fire_event',
    event_type: 'your_event_type',
})