diff --git a/lib/aprsme_web/live/weather_live/callsign_view.html.heex b/lib/aprsme_web/live/weather_live/callsign_view.html.heex
index 3d2432d..f81a828 100644
--- a/lib/aprsme_web/live/weather_live/callsign_view.html.heex
+++ b/lib/aprsme_web/live/weather_live/callsign_view.html.heex
@@ -182,7 +182,7 @@
{gettext("Raw comment")}: {@weather_packet.comment ||
- @weather_packet["comment"]}
+ Map.get(@weather_packet, "comment")}
diff --git a/test/aprsme_web/live/weather_live/callsign_view_test.exs b/test/aprsme_web/live/weather_live/callsign_view_test.exs
index 88df5dc..e28e746 100644
--- a/test/aprsme_web/live/weather_live/callsign_view_test.exs
+++ b/test/aprsme_web/live/weather_live/callsign_view_test.exs
@@ -95,6 +95,71 @@ defmodule AprsmeWeb.WeatherLive.CallsignViewTest do
end
end
+ describe "mount with existing weather packet" do
+ import Aprsme.PacketsFixtures
+
+ test "renders weather data when a weather packet exists", %{conn: conn} do
+ _p =
+ packet_fixture(%{
+ sender: "WXSTA-1",
+ base_callsign: "WXSTA",
+ ssid: "1",
+ received_at: DateTime.utc_now(),
+ lat: Decimal.new("33.0"),
+ lon: Decimal.new("-96.0"),
+ has_position: true,
+ has_weather: true,
+ data_type: "weather",
+ temperature: 72.5,
+ humidity: 55,
+ pressure: 1013.0,
+ wind_speed: 5.5,
+ wind_direction: 180,
+ wind_gust: 10.0,
+ rain_1h: 0.0,
+ rain_24h: 0.25,
+ rain_since_midnight: 0.1,
+ comment: "A brief note"
+ })
+
+ {:ok, _lv, html} = live(conn, ~p"/weather/WXSTA-1", on_error: :warn)
+ assert html =~ "WXSTA-1"
+ end
+
+ test "broadcast of new weather packet for tracked callsign updates the view", %{conn: conn} do
+ _p =
+ packet_fixture(%{
+ sender: "WXTRK-1",
+ base_callsign: "WXTRK",
+ ssid: "1",
+ received_at: DateTime.add(DateTime.utc_now(), -3600, :second),
+ lat: Decimal.new("33.0"),
+ lon: Decimal.new("-96.0"),
+ has_weather: true,
+ temperature: 70.0,
+ humidity: 50
+ })
+
+ {:ok, lv, _html} = live(conn, ~p"/weather/WXTRK-1", on_error: :warn)
+
+ # Newer packet for the SAME callsign with weather data — should trigger update.
+ new_packet = %{
+ sender: "WXTRK-1",
+ received_at: DateTime.utc_now(),
+ temperature: 72.0,
+ humidity: 55,
+ pressure: 1015.0,
+ wind_speed: 3,
+ wind_direction: 90,
+ rain_1h: 0
+ }
+
+ send(lv.pid, {:postgres_packet, new_packet})
+ Process.sleep(50)
+ assert Process.alive?(lv.pid)
+ end
+ end
+
describe "live packet broadcast handling" do
test "ignores non-matching postgres_packet broadcasts", %{conn: conn} do
{:ok, lv, _html} = live(conn, ~p"/weather/OWNCALL", on_error: :warn)