lwitzani / homebridgeStatusWidget

MIT License
371 stars 143 forks source link

Feature Request: Notification if UI-Service not reachable. #42

Closed JeffroDB closed 1 year ago

JeffroDB commented 2 years ago

I travel outside of my home's wifi network frequently and sometimes I forget to turn on my iPhone's VPN service thus making the Homebridge UI unreachable from my iPhone's Safari web browser.

When I do turn it on I have a seperate Safari bookmark, having my VPN's assigned IP in the URL, allowing me to reach the Homebridge UI.

I've currently created two versions of your script, one for home, one for away from home each having the appropriate IP address and "widgetTitle"s.

Using the two scripts I've created two widgets.

Currently, if my iPhone's VPN service is off, the away from home widget displays "X UI-Service not reachable!" reminding me to turn on my VPN if I'm actually away from home.

It would be great if the script could perform a notification when it encounters a "UI-Service not reachable" condition and have this notification be a true/false configuration option. Typically, real world, the user choosing to receive it would receive the notification long before they would swipe their iPhone to view the widget itself.

lwitzani commented 2 years ago

Hi, you can try to add this single line in the script that needs the VPN at around line 274

scheduleNotification('VPN Connection not established');

The result (on the right in the pic) should look like this

image

This should create a push notifications every time your homebridge is not reachable (which is what you wanted i think). Negative side here is probably that it will really annoy you with push messages every time the script runs ;) as long as you do not establish the VPN connection. With my supported notification i fixed this problem by saving the point of time of the last push message in a persisted json file. This would need some extra time to do.

JeffroDB commented 2 years ago

I thought about that, being bombarded with these notifications.

Will having "notificationIntervalInDays" set to 1 also limit this?

Also, I believe this would be a great general feature for your already EXCELLENT script:

scheduleNotification('UI-Service not reachable!');

lwitzani commented 2 years ago

changing notificationIntervalInDays will not have an effect here because this is used in the method function isTimeToNotifyAgain(dateToCheck) { which itself is not called inside the mentioned method "scheduleNotification".

Also having one script for within the local network and one for out of the network would result in firing one push notification if you are inside the network and one as soon as you are out of the network. So one would need to implement this feature with being able to turn it completely off