Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions edge-apps/weather/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ The app accepts the following settings via `screenly.yml`:

| Setting | Description | Type | Default |
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | ------- |
| `display_errors` | For debugging purposes to display errors on the screen. | optional, advanced | `false` |
| `openweathermap_api_key` | OpenWeatherMap API key to access weather data and location information. Get your API key from the [OpenWeatherMap API](https://openweathermap.org/api) | required | - |
| `override_coordinates` | Comma-separated coordinates (e.g., `37.8267,-122.4233`) to override device location | optional | - |
| `override_locale` | Override the default locale with a supported language code | optional | `en` |
Expand Down
1 change: 1 addition & 0 deletions edge-apps/weather/e2e/screenshots.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const { screenlyJsContent } = createMockScreenlyForScreenshots(
location: 'Mountain View, CA',
},
{
display_errors: 'false',
override_timezone: 'America/Los_Angeles',
override_locale: 'en',
openweathermap_api_key: 'mock-api-key',
Expand Down
13 changes: 12 additions & 1 deletion edge-apps/weather/screenly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,20 @@ description: Displays the current weather and time
icon: https://playground.srly.io/edge-apps/weather/static/img/icon.svg
author: Screenly, Inc.
categories:
- Utilities
- Utilities
ready_signal: true
settings:
display_errors:
type: string
default_value: 'false'
title: Display Errors
optional: true
help_text:
properties:
advanced: true
help_text: For debugging purposes to display errors on the screen.
type: boolean
schema_version: 1
enable_analytics:
type: string
default_value: 'true'
Expand Down
13 changes: 12 additions & 1 deletion edge-apps/weather/screenly_qc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,20 @@ description: Displays the current weather and time
icon: https://playground.srly.io/edge-apps/weather/static/img/icon.svg
author: Screenly, Inc.
categories:
- Utilities
- Utilities
ready_signal: true
settings:
display_errors:
type: string
default_value: 'false'
title: Display Errors
optional: true
help_text:
properties:
advanced: true
help_text: For debugging purposes to display errors on the screen.
type: boolean
schema_version: 1
enable_analytics:
type: string
default_value: 'true'
Expand Down
67 changes: 33 additions & 34 deletions edge-apps/weather/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
getSetting,
getCityInfo,
resolveMeasurementUnit,
setupErrorHandling,
type MeasurementUnit,
} from '@screenly/edge-apps'
import '@screenly/edge-apps/components'
Expand Down Expand Up @@ -146,46 +147,44 @@ async function updateWeatherDisplay(
}

document.addEventListener('DOMContentLoaded', async () => {
try {
locationEl = document.querySelector('[data-location]')
temperatureEl = document.querySelector('[data-temperature]')
weatherDescriptionEl = document.querySelector('[data-weather-description]')
tempHighEl = document.querySelector('[data-temp-high]')
tempLowEl = document.querySelector('[data-temp-low]')
forecastItemsEl = document.querySelector('[data-forecast-items]')
forecastCardEl = document.querySelector('[data-forecast-card]')
forecastHeaderIconEl = document.querySelector('[data-forecast-header-icon]')

// Set forecast header icon
if (forecastHeaderIconEl) {
forecastHeaderIconEl.src = sunIcon
}
setupErrorHandling()

Comment on lines +150 to +151
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

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

With setupErrorHandling() enabled, errors thrown during initialization will only surface via panic-overlay if they reach window.onerror/unhandledrejection. The current top-level try/catch logs and swallows initialization failures, which likely prevents the on-screen error overlay from ever appearing for those failures. Consider rethrowing after logging (or conditionally rethrowing when display_errors is enabled) so the overlay can render the error.

Copilot uses AI. Check for mistakes.
locationEl = document.querySelector('[data-location]')
temperatureEl = document.querySelector('[data-temperature]')
weatherDescriptionEl = document.querySelector('[data-weather-description]')
tempHighEl = document.querySelector('[data-temp-high]')
tempLowEl = document.querySelector('[data-temp-low]')
forecastItemsEl = document.querySelector('[data-forecast-items]')
forecastCardEl = document.querySelector('[data-forecast-card]')
forecastHeaderIconEl = document.querySelector('[data-forecast-header-icon]')

// Set forecast header icon
if (forecastHeaderIconEl) {
forecastHeaderIconEl.src = sunIcon
}

const [latitude, longitude] = getCoordinates()
const [latitude, longitude] = getCoordinates()

timezone = await getTimeZone()
locale = await getLocale()
timezone = await getTimeZone()
locale = await getLocale()

const { cityName, countryCode } = await getCityInfo(latitude, longitude)
if (locationEl) {
locationEl.textContent = cityName
}
const { cityName, countryCode } = await getCityInfo(latitude, longitude)
if (locationEl) {
locationEl.textContent = cityName
}

// Get measurement unit from settings, or auto-detect based on location
measurementUnit = resolveMeasurementUnit(countryCode)
// Get measurement unit from settings, or auto-detect based on location
measurementUnit = resolveMeasurementUnit(countryCode)

await updateWeatherDisplay(latitude, longitude, timezone, measurementUnit)
await updateWeatherDisplay(latitude, longitude, timezone, measurementUnit)

// Refresh weather every 15 minutes
setInterval(
() => {
updateWeatherDisplay(latitude, longitude, timezone, measurementUnit)
},
15 * 60 * 1000,
)
} catch (error) {
console.error('Failed to initialize app:', error)
}
// Refresh weather every 15 minutes
setInterval(
() => {
updateWeatherDisplay(latitude, longitude, timezone, measurementUnit)
},
15 * 60 * 1000,
)

signalReady()
})