jimmyeao / TEAMS2HA

23 stars 1 forks source link

With latest release (501) waking from standby doens't update sensors anymore #49

Closed mhoogenbosch closed 3 months ago

mhoogenbosch commented 3 months ago

Describe the bug With the previous (unofficial, I believe 419, but can't recall entirely) release everything was working just fine. Now after waking from Standby the sensors don't update anymore. It does say MQTT and teams are connected.

Restarting TEAMS2HA resolves the issue.

jimmyeao commented 3 months ago

Thanks, I'll take a look at this tonight, I thought I had fixed this but clearly more work needed!

jimmyeao commented 3 months ago

was it the sensors or the switches (or both) that stopped updating? We did change from using senor. to binary_sensor. for entities, did you see this change?

mhoogenbosch commented 3 months ago

hi, yes, this morning I updated the version and with MQTT explorer deleted all 'old' sensors adjusted my sensors and automations. After returning from lunch, I noticed this.

jimmyeao commented 3 months ago

Ok, thanks - just about to push an update that should fix this.

jimmyeao commented 3 months ago

Your app should update next time you run it, all seems to be working here, hopefully this has fixed it for you :)

mhoogenbosch commented 3 months ago

Going to update tonight and will report back in

jimmyeao commented 3 months ago

I think I have identified another issue, another bugfix will be incoming shortly

jimmyeao commented 3 months ago

Fix tested and pushed :)

mhoogenbosch commented 3 months ago

Just updated. Will try tomorrow when working from home. Today was an office day.

mhoogenbosch commented 3 months ago

I'm now using version 524 but it doesn't reflect the changes in teams at all anymore. I restarted the app, but it doesn't start.

Changing the entity in HA doesn't do anything either. When I turn on the hand raised, but turns off again.

I now have deleted everything from MQTT and will restart.

jimmyeao commented 3 months ago

Could you double check the entity names, I included a fix for having multiple computers using the app on the same MQTT broker, this looks like it has changed the entity names again (Sorry! 😢 ). I got so tied up in sorting the code out I forgot to check!

mhoogenbosch commented 3 months ago

Could you double check the entity names, I included a fix for having multiple computers using the app on the same MQTT broker, this looks like it has changed the entity names again (Sorry! 😢 ). I got so tied up in sorting the code out I forgot to check!

After deleting everything, it creates the entities again (same name) and i think it works again.

jimmyeao commented 3 months ago

This should be the last time I mess with entity names, its been a learning experience writing this app and learning more about MQTT. Thanks for all the feedback :)

mhoogenbosch commented 3 months ago

This should be the last time I mess with entity names, its been a learning experience writing this app and learning more about MQTT. Thanks for all the feedback :)

Really love your work! So all is forgiven. ;-)

After lunch I can check if it now works after standby.

mhoogenbosch commented 3 months ago

small side question, what should binary_sensor.martijnlaptop_hasunreadmessages do? I have lots and lots of unread messages, but this is always off.

jimmyeao commented 3 months ago

martijnlaptop_hasunreadmessages

I believe its for un-read chat messages specifically in the meeting you are in. Unfortunately the MS docs are almost non existant for the API

mhoogenbosch commented 3 months ago

Unfortunately it doesn't work. After waking from standby there are no updates.

With closing and restarting the app the status get updated again.

jimmyeao commented 3 months ago

could you send the logs over please and Ill take another look.

mhoogenbosch commented 3 months ago

Teams2ha_Log20240329.log

logs of today

mhoogenbosch commented 3 months ago

I went off to lunch around 12.00 and returned around 12:30

jimmyeao commented 3 months ago

so this is the interesting part:

2024-03-29 12:30:23.676 +01:00 [DBG] Teams Client Disconnected
2024-03-29 12:30:23.677 +01:00 [INF] Force Publishing configuration for teamsrunning with state False.
2024-03-29 12:30:23.677 +01:00 [INF] Publishing configuration for teamsrunning with state False.
2024-03-29 12:30:23.677 +01:00 [INF] Error during MQTT publish: The client is not connected.
2024-03-29 12:30:23.677 +01:00 [INF] Reconnecting to MQTT
2024-03-29 12:30:23.678 +01:00 [INF] Attempting to connect to MQTT (Attempt 1/2)
2024-03-29 12:30:35.175 +01:00 [INF] Logger Created
2024-03-29 12:30:35.211 +01:00 [DBG] Set Folder Path to C:\Users\MHOOGEN82\AppData\Local\TEAMS2HA
2024-03-29 12:30:35.345 +01:00 [DBG] Settings file path is C:\Users\MHOOGEN82\AppData\Local\TEAMS2HA\settings.json
2024-03-29 12:30:35.934 +01:00 [INF] Configuring MQTT client for TCP without TLS connection to 1x.x.x.x:1883
2024-03-29 12:30:35.939 +01:00 [DBG] InitializeMqttPublishTimer: MQTT Publish Timer Initialized
2024-03-29 12:30:35.940 +01:00 [INF] Configuring MQTT client for TCP without TLS connection to 1x.x.x:1883
2024-03-29 12:30:35.940 +01:00 [DBG] InitializeMqttPublishTimer: MQTT Publish Timer Initialized
2024-03-29 12:30:35.944 +01:00 [INF] Attempting to connect to MQTT (Attempt 1/2)
2024-03-29 12:30:37.004 +01:00 [INF] Connected to MQTT broker.
2024-03-29 12:30:37.039 +01:00 [INF] Subscribed to homeassistant/switch/MARTIJNLAPTOP/+/set
2024-03-29 12:30:37.046 +01:00 [DBG] Websocket Client Started
2024-03-29 12:30:37.048 +01:00 [DBG] Token: REDACTED
2024-03-29 12:30:39.201 +01:00 [DBG] Connected to ws://localhost:8124/?token=REDACTED&protocol-version=2.0.0&manufacturer=JimmyWhite&device=PC&app=THFHA&app-version=2.0.26
2024-03-29 12:30:39.202 +01:00 [DBG] TeamsConnectionStatusChanged: Teams Connection Status Changed Teams: Connected
2024-03-29 12:30:39.202 +01:00 [DBG] Teams Connection Status Changed: True
2024-03-29 12:30:39.202 +01:00 [DBG] IsConnected: True

in my testing, when my laptop resumes from sleep, i get an entry in the logs System is waking up from sleep. Re-establishing connections... which I am not seeing in your logs. This is good, as it mean I now know what I need to fix :)

jimmyeao commented 3 months ago

Ok, I'm confident I have got this. Re-wrote the MQTT connection logic to be a singleton and added reconnection logic. have tested by puttingg devices to sleep and pulling the network and reconnecting, in both cases it reconnects for me. Just pushed an update, let me know how it goes for you. Oh, and also a bunch more sensors in this release, we now expose all the meeting permisions and the abillity to "react" (Although I'm not sure how useful this will be!)

mhoogenbosch commented 3 months ago

Will let you know when I'm going to work again. Tuesday probably. Nice going!


Updated, will let you know.

mhoogenbosch commented 3 months ago

Works, i'm going to close the issue. Many many thanks