vicfergar / HassClient

A Home Assistant client using Web Sockect API
GNU General Public License v3.0
18 stars 10 forks source link

Fire an Event #7

Closed shaonianzhentan closed 1 year ago

shaonianzhentan commented 2 years ago

Again thanks for HassClient This project is great and has helped me a lot But I didn't find a way to trigger the event

vicfergar commented 2 years ago

Hi @shaonianzhentan,

I'm not sure about what is the issue you are reporting. This library allows you to consume events from the Hass instance server using WS communication. The way you can consume these events is on the Readme: https://github.com/vicfergar/HassClient#event-subscription

shaonianzhentan commented 2 years ago

Thank you for your reply I customized an event and I want to trigger it instead of subscribing to it

vicfergar commented 2 years ago

Ok, I didn't notice that they have included an fire_event command in the WS API. Currently there is no specific methods to fire events in the API, but you can do it using raw commands feature: https://github.com/vicfergar/HassClient#raw-commands

Check WebSocket API docs from HASS to see how the command should contains: https://developers.home-assistant.io/docs/api/websocket#fire-an-event

shaonianzhentan commented 2 years ago

I look forward to you adding this featureļ¼ŒThanks again

vicfergar commented 2 years ago

I have integrated fire event feature in the branch https://github.com/vicfergar/HassClient/tree/feature/update_ws_api