Skip to content

Updated pulse alerts#319

Merged
pantelisss merged 1 commit intomainfrom
feature/fe-2028-update-low-battery-messages-for-pulse
Oct 17, 2025
Merged

Updated pulse alerts#319
pantelisss merged 1 commit intomainfrom
feature/fe-2028-update-low-battery-messages-for-pulse

Conversation

@pantelisss
Copy link
Copy Markdown
Collaborator

@pantelisss pantelisss commented Oct 16, 2025

Why?

Update texts for pulse station alerts

How?

  • Updated the texts to be shown in the station alerts screen
  • Changes in notification alerts
    • Added texts for gateway battery alerts
    • Separated alert notifcation types from notifciation enable options

Testing

  • For station alerts
    Run the app with mock scheme and ensure the warnings in the station alerts screen are the expected
  • About the notifications
    It's a little tricky. Run the mock scheme on a real device. Pause the debugger (screenshot) and then run the following command and ensure the texts on each notification are the expected.
e -l objc -- (void)[[BGTaskScheduler sharedScheduler] _simulateLaunchForTaskWithIdentifier:@"com.weatherxm.app.fetch"]

If it's not easy to run it on a real device, check it codewise

Screenshots (if applicable)

Screenshot 2025-10-16 at 16 15 40

Additional context

fixes fe-2028

Summary by CodeRabbit

  • New Features

    • Added gateway battery level notifications to alert users when solar charge is low.
  • Documentation

    • Updated battery warning messages for improved clarity.
    • Refined terminology and messaging to emphasize sunlight exposure for optimal gateway and weather station performance.

@pantelisss pantelisss requested a review from PavlosTze October 16, 2025 13:18
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Oct 16, 2025

Walkthrough

Introduces gateway battery notification support by creating a new StationNotificationsSwitchOptions enum, adding gwBattery to StationNotificationsTypes, updating localization strings to use full terminology (Gateway/Weather Station), and implementing gateway low-battery alert logic in the alert manager.

Changes

Cohort / File(s) Summary
Notification Type Separation & Refactoring
PresentationLayer/UIComponents/Screens/WeatherStations/StationDetails/Notifications/StationNotificationsTypes.swift
Renamed extension from StationNotificationsTypes to StationNotificationsSwitchOptions; updated casesForDevice(_:) return type from [StationNotificationsTypes] to [Self]
View Model Updates
PresentationLayer/UIComponents/Screens/WeatherStations/StationDetails/Notifications/StationNotificationsViewModel.swift
Replaced StationNotificationsTypes with StationNotificationsSwitchOptions throughout; updated options storage type, computed properties, and method signatures to use new enum
Presentation Layer Extensions
PresentationLayer/Extensions/DomainExtensions/StationAlert+.swift
Added gwBattery case handling to notification title and description mappings with localized strings
Gateway Battery Alert Logic
PresentationLayer/Utils/StationAlertsManager.swift
Added shouldSendGWLowBatteryNotification(for:) helper to check gateway battery state and prevent duplicate notifications; integrated into checkStation(_:)
Domain Layer Use Case
wxm-ios/DomainLayer/DomainLayer/UseCases/StationNotificationsUseCase.swift
Replaced StationNotificationsTypes with StationNotificationsSwitchOptions in data structures, public API methods, and internal serialization logic
Use Case API Definitions
wxm-ios/DomainLayer/DomainLayer/UseCases/UseCaseApi/StationNotificationsUseCaseApi.swift
Introduced new public enum StationNotificationsSwitchOptions with cases activity, battery, firmwareUpdate, health; extended StationNotificationsTypes with gwBattery case; updated protocol methods to use new enum type
Localization Strings
wxm-ios/Resources/Localizable/Localizable.xcstrings
Updated battery-related keys to use explicit terminology (Gateway/Weather Station instead of abbreviations); added two new entries: notification_gw_battery_title and notification_gw_battery_description
Localization Enum
wxm-ios/Resources/Localizable/LocalizableString+Errors.swift
Added four new cases: notificationGwBatteryTitle and notificationGwBatteryDescription(String) to both LocalizableString outer enum and LocalizableString.Error nested enum with corresponding key mappings

Sequence Diagram

sequenceDiagram
    participant StationAlertsManager
    participant DeviceDetails
    participant StationNotificationsUseCase
    participant AlertNotification
    
    StationAlertsManager->>DeviceDetails: Check gatewayBatteryState
    alt Gateway Battery is Low
        StationAlertsManager->>StationNotificationsUseCase: isNotificationEnabled(.gwBattery, deviceId)
        StationNotificationsUseCase-->>StationAlertsManager: true/false
        alt Notification Enabled & Not Sent Today
            StationAlertsManager->>AlertNotification: Create gwBattery alert
            AlertNotification-->>StationAlertsManager: Alert created
            StationAlertsManager->>StationAlertsManager: Append to alerts array
        end
    end
    
    Note over StationAlertsManager: Mirrors existing low-battery<br/>notification flow for gateway
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

The changes involve consistent refactoring across multiple layers (presentation, domain, API) with a clear pattern: renaming StationNotificationsTypes to StationNotificationsSwitchOptions and adding gateway battery notification support. While the scope spans 8 files and includes type signature updates, the changes are largely homogeneous and follow established patterns in the codebase. New logic in StationAlertsManager mirrors existing low-battery flows, reducing cognitive load.

Possibly related PRs

Suggested reviewers

  • PavlosTze

Poem

🐰 Hoppy news for Gateway care!
A notification so fair,
When batteries run low and dim,
The Gateway chirps its hopeful hymn:
"Sunlight, please—I'm feeling weak!" ☀️

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title Check ❓ Inconclusive The title “Updated pulse alerts” is too vague and does not clearly convey the primary changes such as adding gateway battery notifications and refactoring notification type handling. Please revise the title to succinctly reflect the main update, for example “Add gateway battery notifications and refactor notification type options.”
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed The pull request description adheres to the repository template by providing clear Why, How, Testing, Screenshots, and Additional context sections, each populated with relevant and actionable information.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/fe-2028-update-low-battery-messages-for-pulse

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
PresentationLayer/UIComponents/Screens/WeatherStations/StationDetails/Notifications/StationNotificationsTypes.swift (1)

11-44: LGTM! Extension updated to use the new switch options type.

The refactoring from StationNotificationsTypes to StationNotificationsSwitchOptions is consistent. The device-specific logic (non-Helium devices exclude firmware update notifications) is preserved.

Consider renaming this file to StationNotificationsSwitchOptions+Extensions.swift to better reflect that it now extends StationNotificationsSwitchOptions rather than StationNotificationsTypes. This would improve code navigation and clarity.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d6e353a and 1d3ba73.

📒 Files selected for processing (8)
  • PresentationLayer/Extensions/DomainExtensions/StationAlert+.swift (2 hunks)
  • PresentationLayer/UIComponents/Screens/WeatherStations/StationDetails/Notifications/StationNotificationsTypes.swift (2 hunks)
  • PresentationLayer/UIComponents/Screens/WeatherStations/StationDetails/Notifications/StationNotificationsViewModel.swift (3 hunks)
  • PresentationLayer/Utils/StationAlertsManager.swift (2 hunks)
  • wxm-ios/DomainLayer/DomainLayer/UseCases/StationNotificationsUseCase.swift (4 hunks)
  • wxm-ios/DomainLayer/DomainLayer/UseCases/UseCaseApi/StationNotificationsUseCaseApi.swift (1 hunks)
  • wxm-ios/Resources/Localizable/Localizable.xcstrings (7 hunks)
  • wxm-ios/Resources/Localizable/LocalizableString+Errors.swift (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
PresentationLayer/Utils/StationAlertsManager.swift (3)
wxm-ios/DomainLayer/DomainLayer/UseCases/StationNotificationsUseCase.swift (1)
  • isNotificationEnabled (53-56)
wxm-ios/DomainLayer/DomainLayer/UseCases/MeUseCase.swift (1)
  • lastNotificationAlertSent (174-179)
WeatherXMTests/PresentationLayer/MockUseCases/MockMeUseCase.swift (1)
  • lastNotificationAlertSent (192-194)
PresentationLayer/UIComponents/Screens/WeatherStations/StationDetails/Notifications/StationNotificationsViewModel.swift (1)
PresentationLayer/UIComponents/Screens/WeatherStations/StationDetails/Notifications/StationNotificationsTypes.swift (1)
  • casesForDevice (38-44)
wxm-ios/DomainLayer/DomainLayer/UseCases/UseCaseApi/StationNotificationsUseCaseApi.swift (2)
wxm-ios/DomainLayer/DomainLayer/UseCases/StationNotificationsUseCase.swift (4)
  • areNotificationsEnabledForDevice (23-30)
  • setNotificationsForDevice (32-36)
  • setNotificationEnabled (38-51)
  • isNotificationEnabled (53-56)
WeatherXMTests/DomainLayer/UseCases/StationNotificationsUseCaseTests.swift (1)
  • setNotificationsForDevice (24-29)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: WeatherXM | Unit tests | wxm-ios - iOS
🔇 Additional comments (7)
PresentationLayer/Utils/StationAlertsManager.swift (1)

112-124: LGTM! Gateway battery notification logic is correct.

The implementation correctly mirrors the existing shouldSendLowBatteryNotification pattern. Note that checking .battery on line 114 (rather than a non-existent .gwBattery switch option) is intentional—gateway battery shares the same UI switch as regular battery but sends a distinct .gwBattery alert type.

wxm-ios/DomainLayer/DomainLayer/UseCases/StationNotificationsUseCase.swift (2)

10-10: LGTM! Typealias updated to reflect new switch options type.

The change from StationNotificationsTypes to StationNotificationsSwitchOptions correctly reflects the architectural separation between UI switch options (4 cases) and alert types (5 cases including gwBattery).


38-56: LGTM! Public API updated consistently.

Both methods correctly use StationNotificationsSwitchOptions for the type parameter. The default behavior (missing options default to true on line 55) is preserved.

PresentationLayer/Extensions/DomainExtensions/StationAlert+.swift (1)

21-22: LGTM! Gateway battery notification strings wired correctly.

The new gwBattery case is properly integrated into both notificationTitle and notificationDescription(for:), referencing the newly added localization keys.

Also applies to: 36-37

wxm-ios/DomainLayer/DomainLayer/UseCases/UseCaseApi/StationNotificationsUseCaseApi.swift (1)

10-23: LGTM! Clean separation between switch options and alert types.

The introduction of StationNotificationsSwitchOptions (UI switches, 4 cases) alongside the expanded StationNotificationsTypes (alert types, 5 cases) is well-designed. Gateway battery notifications share the battery switch but send a distinct gwBattery alert type, which is logical and maintains UI simplicity.

wxm-ios/Resources/Localizable/LocalizableString+Errors.swift (1)

80-81: LGTM! Gateway battery localization strings added correctly.

The new notificationGwBatteryTitle and notificationGwBatteryDescription cases follow the existing pattern for notification localization, including proper string interpolation support for the station name.

Also applies to: 108-108, 256-259

PresentationLayer/UIComponents/Screens/WeatherStations/StationDetails/Notifications/StationNotificationsViewModel.swift (1)

19-22: LGTM! View model consistently updated to use switch options type.

All properties, methods, and helpers are correctly updated from StationNotificationsTypes to StationNotificationsSwitchOptions. The analytics tracking and option persistence logic are preserved.

Also applies to: 34-45, 76-87

Comment on lines 5365 to 5367
"state" : "translated",
"value" : "Low GW battery"
"value" : "Low Gateway battery"
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Restore title casing for consistency.

Line 5366 currently reads “Low Gateway battery”, but every other alert title keeps Title Case (“Low Gateway Battery”). Please align the casing:

-            "value" : "Low Gateway battery"
+            "value" : "Low Gateway Battery"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"state" : "translated",
"value" : "Low GW battery"
"value" : "Low Gateway battery"
}
"state" : "translated",
"value" : "Low Gateway Battery"
}
🤖 Prompt for AI Agents
In wxm-ios/Resources/Localizable/Localizable.xcstrings around lines 5365 to
5367, the alert title uses inconsistent casing ("Low Gateway battery"); change
the value string to Title Case ("Low Gateway Battery") to match other alert
titles and keep localization consistency.

Comment on lines +6751 to +6753
"state" : "translated",
"value" : "To avoid data interruptions, please make sure the Gateway of %@ is properly exposed to sunlight."
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Tighten the new gateway notification copy.

“Gateway of %@” feels awkward in English. Switching to the possessive keeps the voice consistent with the rest of the file:

-            "value" : "To avoid data interruptions, please make sure the Gateway of %@ is properly exposed to sunlight."
+            "value" : "To avoid data interruptions, please make sure %@’s gateway is properly exposed to sunlight."
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"state" : "translated",
"value" : "To avoid data interruptions, please make sure the Gateway of %@ is properly exposed to sunlight."
}
"state" : "translated",
"value" : "To avoid data interruptions, please make sure %@'s gateway is properly exposed to sunlight."
}
🤖 Prompt for AI Agents
In wxm-ios/Resources/Localizable/Localizable.xcstrings around lines 6751 to
6753, the string "To avoid data interruptions, please make sure the Gateway of
%@ is properly exposed to sunlight." uses an awkward "Gateway of %@" phrasing;
change it to the possessive form to match the file's voice—e.g. "To avoid data
interruptions, please make sure %@'s Gateway is properly exposed to
sunlight."—or alternatively "To avoid data interruptions, please make sure the
%@ Gateway is properly exposed to sunlight.", and update the localized value
accordingly.

@weatherxmdev
Copy link
Copy Markdown
Collaborator

Code Coverage Summary

Framework Source Files Coverage
DataLayer.framework 49 66.77%
DomainLayer.framework 66 83.66%
Toolkit.framework 30 53.18%
WeatherXM.app 404 14.17%
station-intent.appex 2 83.33%
station-widgetExtension.appex 45 34.20%

@pantelisss pantelisss merged commit f430bf4 into main Oct 17, 2025
4 checks passed
@pantelisss pantelisss deleted the feature/fe-2028-update-low-battery-messages-for-pulse branch October 17, 2025 12:17
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

Successfully merging this pull request may close these issues.

3 participants