Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repos still up to date? #8

Open
DevJasperNL opened this issue Jun 24, 2022 · 3 comments
Open

Repos still up to date? #8

DevJasperNL opened this issue Jun 24, 2022 · 3 comments

Comments

@DevJasperNL
Copy link

DevJasperNL commented Jun 24, 2022

Is this repos still up to date with the latest home assistant socket implementation?

I am asking as I do not seem to receive any events. Am I missing something here?

public async Task ConnectAsync()
{
    var connectionParameters = ConnectionParameters.CreateFromInstanceBaseUrl(_url, _token);
    await _hassWSApi.ConnectAsync(connectionParameters);

    await _hassWSApi.AddEventHandlerSubscriptionAsync(OnEvent);
}

private void OnEvent(object sender, EventResultInfo e)
{
    Console.WriteLine(e.Data.ToString());
}
@jimmyeao
Copy link

jimmyeao commented Jul 9, 2023

I too am not receiving events :/

  private async Task SubscribeToEvents()
        {
            if (connected)
            {
                var hassWSApi = new HassWSApi();
                var connectionParameters = ConnectionParameters.CreateFromInstanceBaseUrl(_baseUrl, _apiKey);
                await hassWSApi.ConnectAsync(connectionParameters);
                var entityIds = new List<string> { "switch.hats_camera", "switch.hats_microphone", "switch.hats_blurred", "switch.hats_recording" }; // Replace with your entity IDs
                // lets subscribe to the events
                IEnumerable<StateModel> states = await hassWSApi.GetStatesAsync();
                hassWSApi.StateChagedEventListener.SubscribeEntityStatusChanged("switch.hats_camera", this.hats_camera_StateChanged);
                hassWSApi.StateChagedEventListener.SubscribeEntityStatusChanged("switch.hats_microphone", this.hats_microphone_StateChanged);
                hassWSApi.StateChagedEventListener.SubscribeEntityStatusChanged("switch.hats_blurred", this.hats_blurred_StateChanged);
                hassWSApi.StateChagedEventListener.SubscribeEntityStatusChanged("switch.hats_recording", this.hats_recording_StateChanged);



            }

        }

        private void hats_camera_StateChanged(object sender, StateChangedEvent stateChangedArgs)
        {
            Debug.WriteLine($"hats_camera_StateChanged {stateChangedArgs.EntityId} is now {stateChangedArgs.NewState.State}");
        }
        private void hats_microphone_StateChanged(object sender, StateChangedEvent stateChangedArgs)
        {
            Debug.WriteLine($"hats_microphone_StateChanged {stateChangedArgs.EntityId} is now {stateChangedArgs.NewState.State}");
        }
        private void hats_blurred_StateChanged(object sender, StateChangedEvent stateChangedArgs)
        {
            Debug.WriteLine($"hats_blurred_StateChanged {stateChangedArgs.EntityId} is now {stateChangedArgs.NewState.State}");
        }
        private void hats_recording_StateChanged(object sender, StateChangedEvent stateChangedArgs)
        {
            Debug.WriteLine($"hats_recording_StateChanged {stateChangedArgs.EntityId} is now {stateChangedArgs.NewState.State}");
        }

@vicfergar
Copy link
Owner

Hi @Tsuy89 and @jimmyeao, I've been out of this project for a while not giving it support and updates for a while. I just run the CI and it looks like there are some things broken.

I'll try to give it a look, but I'm in the middle of a lot of things and it's difficult to spend time on this library.

@vicfergar
Copy link
Owner

Even though there are some tests broken (~33 tests), it seems that the ones related to events are working as expected. Are you trying with the main branch right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants