jimmyeao / TEAMS2HA

23 stars 1 forks source link

[bug] Crash after waking from standby #10

Closed mhoogenbosch closed 6 months ago

mhoogenbosch commented 8 months ago

Using 1.0.0.2 (according to app, downloaded your 1.0.0.1 release). When it runs it's fine, but after waking from standby it is 'gone'. Can't seem to find anything in my eventlogs.

Maybe your new version from upcoming weekend will fix this, but if it doesn't, then this is already opened.

Usecase: During lunch my home computer goes into standby because i have left the premises (espresense). When returning from lunch it resumes.

jimmyeao commented 8 months ago

thanks, ill look into this

jimmyeao commented 8 months ago

have added some code to the next version that should cope with this, should be released tomorrow

jimmyeao commented 8 months ago

should be fixed by V1.1.0.8

mhoogenbosch commented 8 months ago

Isn't fixed for me unfortunately.

After waking from standby:

image

but

image

After killing and starting the entity is back.

By checking with mqtt explorer the information isn't present in mqtt either.

I just now saw you have released a new version with a specific port number field. I havent checked with this version yet.

jimmyeao commented 8 months ago

Ok, I'll keep investigating - the newer versions already have reconnection logic in place, and I haven't been able to replicate this, but I'll keep trying

jimmyeao commented 8 months ago

Testing a fix for this, all being well i will push an update tomorrow.

mhoogenbosch commented 8 months ago

I will be able to test tomorrow afternoon.

Verstuurd vanaf mijn iPhone

Op 19 dec 2023 om 21:17 heeft Jimmy White @.***> het volgende geschreven:



Testing a fix for this, all being well i will push an update tomorrow.

— Reply to this email directly, view it on GitHubhttps://github.com/jimmyeao/TEAMS2HA/issues/10#issuecomment-1863416063, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIZQWDWBGLR5VKP2KARF33LYKHY3TAVCNFSM6AAAAABAWOL3BKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNRTGQYTMMBWGM. You are receiving this because you authored the thread.Message ID: @.***>

jimmyeao commented 8 months ago

New version has been pushed, hopefully you have it now (App should auto-update)

mhoogenbosch commented 8 months ago

I'm going to try and see if this works, but that'll probably be next week because i'm on leave starting later today. But i'll keep you posted. thanks for your commitement

Egglestron commented 6 months ago

Hi @jimmyeao, hi @mhoogenbosch,

I notice a similar issue (even though entities are retained in HA): when waking the computer from sleep, the meeting states (pushed from Teams to HA) update correctly, but I cannot push anything from HA to Teams (mute my mic, or any other switch action).

Looking at the logs, I see that upon first connection, TEAMS2HA subscribes to the topic and monitors the homeassistant/switch/xxxx states:

2024-02-19 10:21:37.030 +01:00 [INF] Connected to MQTT broker. 2024-02-19 10:21:37.066 +01:00 [INF] Subscribing.MQTTnet.Client.MqttClientSubscribeOptions 2024-02-19 10:21:37.067 +01:00 [DBG] MQTT Client Connected in InitializeMQTTConnection

However, after reconnection to the broker (after sleep or any other network interruption I suppose), it seems like TEAMS2HA loses the subscription and doesn't attempt to subscribe again:

2024-02-19 12:17:47.125 +01:00 [DBG] CheckMqttConnection: MQTT Client Not Connected. Attempting reconnection. 2024-02-19 12:17:47.125 +01:00 [INF] Attempting to connect to MQTT (Attempt 1/5) 2024-02-19 12:17:47.199 +01:00 [INF] Connected to MQTT broker. 2024-02-19 12:17:49.101 +01:00 [DBG] ReceiveLoopAsync: Message Received: {"meetingUpdate":{"meetingState":{"isMuted":true,"isVideoOn":false,"isHandRaised":false,"isInMeeting":true,"isRecordingOn":false,"isBackgroundBlurred":false,"isSharing":false,"hasUnreadMessages":false},"meetingPermissions":{"canToggleMute":true,"canToggleVideo":true,"canToggleHand":true,"canToggleBlur":false,"canLeave":true,"canReact":true,"canToggleShareTray":true,"canToggleChat":true,"canStopSharing":false,"canPair":false}}

Maybe it would be wise to subscribe again after reconnection and not only after the initial one?

Egglestron commented 6 months ago

Looking at the code, what do you think about adding this line: https://github.com/jimmyeao/TEAMS2HA/blob/f602af420ef22f9a19850e4bc96e55dc4dee6b1d/MainWindow.xaml.cs#L341 to this function? https://github.com/jimmyeao/TEAMS2HA/blob/f602af420ef22f9a19850e4bc96e55dc4dee6b1d/MainWindow.xaml.cs#L428

jimmyeao commented 6 months ago

That could work, Ill do some testing

jimmyeao commented 6 months ago

ok it doesnt seem to break anything, new version pushed

Egglestron commented 6 months ago

Hi! Not fully solved mon my side, maybe it should be added elsewhere: I see other instances of await mqttClientWrapper.ConnectAsync(); which are not followed by mqttClientWrapper.SubscribeAsync()

I found two other functions: https://github.com/jimmyeao/TEAMS2HA/blob/f602af420ef22f9a19850e4bc96e55dc4dee6b1d/MainWindow.xaml.cs#L458 https://github.com/jimmyeao/TEAMS2HA/blob/f602af420ef22f9a19850e4bc96e55dc4dee6b1d/MainWindow.xaml.cs#L583

In my case, I just tried to disable my Wi-Fi connection and CheckMqttConnection() apparently got called (based on logs) and I reproduced the issue. :)

jimmyeao commented 6 months ago

found a couple more places & updated the app - I really need to refactor the mqtt connection logic at some point! Thanks for your diligent work :)

mhoogenbosch commented 6 months ago

I really love the recent adjustments. The entities get updated constantly, even after recovering from standby or when coming from a network where the MQTT broker isn't available.

On my behave, this issue can and may be closed. But I don't know if you'd like to keep it open for your refactoring of MQTT connection logic.

jimmyeao commented 6 months ago

I really love the recent adjustments. The entities get updated constantly, even after recovering from standby or when coming from a network where the MQTT broker isn't available.

On my behave, this issue can and may be closed. But I don't know if you'd like to keep it open for your refactoring of MQTT connection logic.

Thanks, I'll close it for now - one of my biggest challenges is finding the official MS documentation for the API, I can find none, and I am aware there is a 'feature' where the new Teams doesn't always send the blur state to the API unless it is delivered together with another action, say muting or un muting.