Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Home Assistant integration (MQTT publisher)

MyAstroBoard can publish its state to an MQTT broker, with Home Assistant MQTT Discovery: enable the connector, point it at the broker Home Assistant already uses, and a “MyAstroBoard” device appears in Home Assistant together with one device per location - sky period, night score, sun and moon times, tonight’s best window and top target, current weather-for-astro, upcoming events - and, for users who opted in, one device per user with their Astrodex counters, tonight’s plan and its equipment, observation log totals and the latest Astrodex picture.

It is publish-only: MyAstroBoard never reads commands from the broker. The only thing it subscribes to is Home Assistant’s own birth message, so entities come back by themselves after a Home Assistant restart.

Ready-made Lovelace cards live in a separate repository: lovelace-myastroboard-card.

MyAstroBoard itself can also run inside Home Assistant OS, as an app - see Installation, option 2. The MQTT integration below works the same whichever way MyAstroBoard is installed (broker host core-mosquitto when both run in Home Assistant).


Requirements

MQTT brokerAny MQTT 3.1.1 broker: the Home Assistant Mosquitto add-on, a standalone Mosquitto, EMQX… reachable from the MyAstroBoard container
Home Assistant2024.11 or newer (device-based MQTT discovery) with the MQTT integration configured and discovery enabled (the default)
MyAstroBoard1.6.0 or newer, an admin account

Setup

  1. Broker. Create a user for MyAstroBoard on the broker (Mosquitto add-on: Settings -> Add-ons -> Mosquitto -> Configuration, or a Home Assistant user - the add-on accepts those). Note the broker’s IP address and port (1883, or 8883 for TLS).
  2. MQTT connection. App settings -> Configuration -> MQTT connections -> Add a connection (see MQTT connections):
    • Display name: any name, shown in the connector’s picker.
    • Broker URL: mqtt://192.168.1.10:1883 (or mqtts://host:8883 for TLS). Use the IP address rather than a .local name - mDNS does not resolve inside the container.
    • Username / Password: the broker user. Leave both blank for an anonymous broker.
    • Press the test button (wifi icon): it opens one real connection to the broker with the settings as typed and reports Reachable or the reason it is not (refused, timeout, not authorized, TLS…). Save.
  3. Connector. App settings -> Connectors -> MQTT / Home Assistant -> Configure:
    • MQTT connection: pick the connection created above (the wifi button tests it).
    • Tick the modules you want (see Modules), switch Enable connector on, Save.
  4. Home Assistant. Settings -> Devices & services -> MQTT: within a minute a MyAstroBoard device and one MyAstroBoard - <location> device per location preset appear. The card’s status line shows Connected, the last publish time and the number of devices and entities.

Nothing has to be added to configuration.yaml.

Per-user activity

Location and board data are install-level and published as soon as the connector is on. A user’s data (Astrodex, plan, observation log, pictures) is private, so it is published only when that user asks for it: My settings -> Customize -> Publish my activity to Home Assistant (MQTT). The switch only shows once an admin has enabled the connector, and it only ever covers the user’s own data - an admin cannot publish another user’s activity. The admin-side User activity and Latest Astrodex picture modules must be on as well.


Modules

ModuleDefaultDeviceWhat it publishes
Sky conditionsonper locationsky period, night score, sun and moon times, dark window, best window, top target, SkyTonight night window
Weather nowonper locationcurrent weather for astrophotography: temperature, humidity, dew point, clouds by layer, wind, precipitation, pressure, visibility, plus seeing, transparency, limiting magnitude, dew risk, tracking impact, weather alert
Upcoming eventsoffper locationnext event, next ISS / CSS pass, aurora Kp and probability, next solar / lunar eclipse
User activityoffper opted-in userAstrodex counters, plan state and progress, current and next target, active equipment, observation log totals
Latest Astrodex pictureoffper opted-in userthe newest Astrodex picture as an image entity
Board diagnosticsonboardversion, update entity, cache readiness, SkyTonight scheduler state, last publish, published counts

Every location the cache scheduler keeps warm gets a device (in practice every preset). Disable the entities you do not need from the device page in Home Assistant.

Settings

FieldDefaultNotes
MQTT connection-One of the MQTT connections: the broker URL, username, password and self-signed certificate switch belong to it
Home Assistant MQTT DiscoveryonOff = only the plain state topics are published (for another consumer than Home Assistant)
Base topic (advanced)myastroboardRoot of every topic; two boards on one broker use two base topics
Discovery prefix (advanced)homeassistantMust match the MQTT integration’s discovery prefix
Publish interval (advanced)60 sMinimum 15 s. States are only sent when they changed; everything is resent every 30 min and whenever Home Assistant restarts
Client ID (advanced)generatedmyastroboard-<8 hex>, generated once and reused across restarts. Must differ from any other connector on the same connection

MQTT connections

A broker is declared once, in App settings -> Configuration -> MQTT connections, and each MQTT connector picks one. Several connectors can share a connection: each one opens its own client, which is why two connectors on one connection cannot be saved with the same client ID (a broker keeps one session per client ID and would disconnect them in turn).

FieldDefaultNotes
Display name-Unique; shown in the connectors’ picker
Broker URL-mqtt://host[:1883] or mqtts://host[:8883]
Username / PasswordblankThe password is stored in the connector secrets store, outside the configuration, and is never part of a backup or config export: re-enter it after restoring a backup on another machine. Clearing the username drops the password
Accept self-signed certificatesoffmqtts:// only - skips certificate verification for a LAN broker with its own CA

The list shows, for each connection, whether the broker answers (checked when the page opens and with the wifi button) and which connectors use it. A connection still picked by a connector cannot be deleted: pick another one in that connector first. Editing a connection makes every connector using it reconnect.

Upgrading from 1.7.1 or earlier: a configured connector’s broker becomes a connection named Home Assistant, already picked by the connector, with its password - nothing to re-enter.

Buttons

  • Publish now - full republish of discovery and every state on the next tick (a few seconds).
  • Remove from Home Assistant - switches the connector off and deletes every retained MyAstroBoard topic from the broker; Home Assistant drops the devices (their history is lost). Broker settings and modules are kept, so enabling the connector again recreates everything. Simply switching the connector off, by contrast, leaves the devices in place as unavailable. See Long-term statistics for the one thing a removal leaves behind.

Long-term statistics

Home Assistant records long-term statistics for every sensor that declares a state_class, and keeps them after the entity disappears. Only the six counters that track your own progress declare one (state_class: total): Astrodex objects, objects with pictures, pictures, constellations, observation sessions and total integration - the numbers a Statistics graph card can show growing month after month. Everything else (sky, Moon, best window, weather, aurora, plan progress) is an ephemeris or a forecast that MyAstroBoard recomputes at any time, so it deliberately records no long-term statistics; the recorder’s short-term history (10 days by default) still draws them in a history graph.

After Remove from Home Assistant (or a user opting out), those six series per user stay in the recorder as orphans. Home Assistant lists them under Developer tools -> Statistics with a Fix issue action that deletes them; Spook reports the same list. Nothing else is left behind.


Automation ideas

# Red observatory light at astronomical dusk
trigger:
  - platform: state
    entity_id: sensor.myastroboard_backyard_sky_period
    to: astronomical_night
action:
  - service: light.turn_on
    target: { entity_id: light.observatory }
    data: { rgb_color: [255, 0, 0], brightness: 40 }

# Tonight looks good
trigger:
  - platform: numeric_state
    entity_id: sensor.myastroboard_backyard_observation_score
    above: 7
condition:
  - condition: state
    entity_id: binary_sensor.myastroboard_backyard_astronomical_night
    state: "on"
action:
  - service: notify.mobile_app_phone
    data:
      message: "Night score {{ states('sensor.myastroboard_backyard_observation_score') }} - top target {{ states('sensor.myastroboard_backyard_top_target_tonight') }}"

Privacy and security

  • Outbound only. No command topic exists; nothing Home Assistant publishes is acted upon.
  • The password lives in the connector secrets store, never in the configuration, backups, the config export or any API response (the connection list only sees a mask).
  • The connection test never pairs the stored password with a URL that differs from the saved one, and the MQTT and MQTT connection routes are admin-only.
  • mqtts:// gives TLS; Accept self-signed certificates is meant for a LAN broker with its own CA, nothing else.
  • A user’s data is published only while that user’s own switch is on. Location devices carry the preset name and timezone, not its coordinates; pictures are published without location data.

Troubleshooting

SymptomLikely causeFix
Test says connection refusedwrong IP / port, or the broker only listens on localhostuse the LAN IP, check the broker’s listener (0.0.0.0:1883)
Test says not authorizedwrong user / password, or the broker requires onecreate a broker user, re-enter the password
Test says TLS handshake failedself-signed certificatemqtts:// + Accept self-signed certificates, or use mqtt:// on the LAN
Status shows Connected but no device in Home Assistantdiscovery off, or the discovery prefix differs from the MQTT integration’stick Home Assistant MQTT Discovery, align the prefix (homeassistant by default)
Devices are unavailablethe connector is off or the container is downenable the connector / check the card’s status line and data/myastroboard.log
No user devicethe user has not opted in, or the User activity module is offMy settings -> Customize -> Publish my activity…; module on
No picture entityLatest Astrodex picture module off, no picture yet, or the picture exceeds 1 MB even at 640 pxsee the log line; the entity appears after the next picture is added
Values show unknownthe cache behind them is not warm yet (fresh install, new location)wait for the cache scheduler’s next cycle
Two boards on one broker fight over devicessame base topicgive each board its own base topic
Stale devices after renaming the base topicold retained topicsRemove from Home Assistant before renaming, or delete the topics with mosquitto_sub/your broker’s tools

Log lines are prefixed MQTT publisher: in data/myastroboard.log.

Tested against Home Assistant 2024.11+ discovery format; re-check the release notes of the Home Assistant version you run if entities fail to appear.


Entities

Home Assistant builds each entity id from the device name and the entity name (never from the JSON key): the Top target tonight sensor of the “MyAstroBoard - Backyard” device is sensor.myastroboard_backyard_top_target_tonight, the Astronomical night binary sensor is binary_sensor.myastroboard_backyard_astronomical_night, the picture is image.myastroboard_alice_latest_astrodex_picture. unique_id is <base>_loc_<location_id>_<key>, so renaming a preset later keeps the entity history. The tables below are generated from backend/connectors/mqtt_payloads.py.

Board device (Board diagnostics)

KeyEntity nameKindNotes
versionVersionsensordiagnostic
updateUpdateupdatediagnostic - installed/latest version, links to the changelog; no Install button (no remote self-update)
caches_readyCaches readybinary sensordiagnostic
skytonight_runningSkyTonight calculatingbinary sensor (running)diagnostic
skytonight_last_runSkyTonight last runsensor (timestamp)diagnostic
skytonight_next_runSkyTonight next runsensor (timestamp)diagnostic
last_publishLast publishsensor (timestamp)updated every publish cycle - a heartbeat; diagnostic
locations_publishedLocations publishedsensordiagnostic
users_publishedUsers publishedsensordiagnostic

Location device - Sky conditions

KeyEntity nameKindNotes
sky_periodSky periodsensor (enum)day, civil_twilight, nautical_twilight, astronomical_twilight, astronomical_night, unknown
next_periodNext sky periodsensor (enum)
next_period_atNext sky period atsensor (timestamp)
is_astronomical_nightAstronomical nightbinary sensor
observation_scoreObservation scoresensorthe app-wide night score (same value as the sky widget)
sunriseSunrisesensor (timestamp)
sunsetSunsetsensor (timestamp)
civil_duskCivil dusksensor (timestamp)
civil_dawnCivil dawnsensor (timestamp)
nautical_duskNautical dusksensor (timestamp)
nautical_dawnNautical dawnsensor (timestamp)
astronomical_duskAstronomical dusksensor (timestamp)
astronomical_dawnAstronomical dawnsensor (timestamp)
true_night_hoursTrue night durationsensor (duration, h)
moon_phaseMoon phasesensor
moon_illuminationMoon illuminationsensor (%)
moon_altitudeMoon altitudesensor (°)
moon_azimuthMoon azimuthsensor (°)
moon_distanceMoon distancesensor (distance, km)
next_moonriseNext moonrisesensor (timestamp)
next_moonsetNext moonsetsensor (timestamp)
next_full_moonNext full moonsensor (timestamp)
next_new_moonNext new moonsensor (timestamp)
dark_window_startDark window startsensor (timestamp)next moonless astronomical night
dark_window_endDark window endsensor (timestamp)
best_window_startBest window startsensor (timestamp)the practical best window
best_window_endBest window endsensor (timestamp)
best_window_durationBest window durationsensor (duration, h)
best_window_scoreBest window scoresensor
best_window_moonBest window moon conditionsensor
top_targetTop target tonightsensorattributes: type, constellation, magnitude, max altitude, observable hours, top_targets (top 5)
top_target_scoreTop target AstroScoresensor
night_startSkyTonight night startsensor (timestamp)
night_endSkyTonight night endsensor (timestamp)
skytonight_calculated_atSkyTonight calculated atsensor (timestamp)diagnostic

Location device - Weather now

Nearest hourly forecast row plus the astro analysis.

KeyEntity nameKindNotes
temperatureTemperaturesensor (temperature, °C)
dew_pointDew pointsensor (temperature, °C)
humidityHumiditysensor (humidity, %)
cloud_coverCloud coversensor (%)
cloud_cover_lowLow cloudssensor (%)
cloud_cover_midMid cloudssensor (%)
cloud_cover_highHigh cloudssensor (%)
wind_speedWind speedsensor (wind_speed, km/h)
wind_directionWind directionsensor (°)
precipitation_probabilityPrecipitation probabilitysensor (%)
precipitationPrecipitationsensor (precipitation, mm)
pressurePressuresensor (atmospheric_pressure, hPa)
visibilityVisibilitysensor (distance, m)
weather_codeWeather codesensorWMO weather code
seeingSeeingsensorPickering scale
transparencyTransparencysensor
limiting_magnitudeLimiting magnitudesensor
dew_riskDew risksensor (enum)LOW, MODERATE, HIGH, CRITICAL, UNKNOWN
dew_point_spreadDew point spreadsensor (temperature, °C)
wind_tracking_impactWind tracking impactsensor (enum)NONE, LOW, MODERATE, HIGH, SEVERE, UNKNOWN
tracking_stabilityTracking stabilitysensor
weather_alertWeather alertsensorfirst alert; attributes: all alerts
forecast_updated_atForecast updated atsensor (timestamp)diagnostic

Location device - Upcoming events

KeyEntity nameKindNotes
next_eventNext eventsensorsame “next event” as the dashboard banner; attributes: event_type, description, start / peak / end, importance, events_count, plus the event’s raw (untranslated) variable piece where applicable - eclipse_type (solar/lunar eclipses), planet/planet2 (planetary conjunction/opposition/elongation/retrograde, moon conjunction), shower_name (meteor showers), comet_name (comet appearances); state and description are English-only by design (MQTT is a background publish loop with no session language to read) - clients that want a localized display should translate client-side off event_type and these attributes, the same way top_target_attributes.object_type already needs to be
next_event_atNext event atsensor (timestamp)
next_iss_pass_atNext ISS passsensor (timestamp)
next_iss_pass_peak_altitudeNext ISS pass peak altitudesensor (°)
next_iss_pass_durationNext ISS pass durationsensor (duration, min)
next_iss_pass_scoreNext ISS pass visibility scoresensor
next_css_pass_atNext CSS passsensor (timestamp)
next_css_pass_peak_altitudeNext CSS pass peak altitudesensor (°)
next_css_pass_durationNext CSS pass durationsensor (duration, min)
next_css_pass_scoreNext CSS pass visibility scoresensor
aurora_kpAurora Kp indexsensor
aurora_probabilityAurora probabilitysensor (%)
aurora_visibilityAurora visibilitysensor
next_solar_eclipse_atNext solar eclipsesensor (timestamp)attributes: type, obscuration, start, end, visible
next_lunar_eclipse_atNext lunar eclipsesensor (timestamp)attributes: type, start, end, visible

User device - User activity

KeyEntity nameKindNotes
astrodex_objectsAstrodex objectssensor
astrodex_objects_with_picturesAstrodex objects with picturessensor
astrodex_picturesAstrodex picturessensor
astrodex_constellationsAstrodex constellationssensor
astrodex_last_picture_atLast Astrodex picturesensor (timestamp)
astrodex_last_picture_objectLast Astrodex picture objectsensorattributes: catalogue, type, constellation, date, equipment, rating
plan_statePlan statesensor (enum)none, current, previous
plan_activePlan in progressbinary sensor (running)the plan’s night is in progress
plan_progressPlan progresssensor (%)
plan_current_targetPlan current targetsensorattributes: catalogue, type, planned minutes, slot start / end, visibility, meridian flip
plan_next_targetPlan next targetsensor
plan_night_startPlan night startsensor (timestamp)
plan_night_endPlan night endsensor (timestamp)
plan_targets_totalPlan targetssensor
plan_targets_donePlan targets donesensor
plan_locationPlan locationsensor
active_equipmentActive equipmentsensorthe plan’s combination; attributes: telescope, camera, guide camera, mount, filters, accessories, focal length, aperture, disabled
sessions_totalObservation sessionssensor
integration_hours_totalTotal integrationsensor (duration, h)observation log
last_session_dateLast observation sessionsensor (date)

User device - Latest Astrodex picture

KeyEntity nameKindNotes
latest_pictureLatest Astrodex pictureimageraw JPEG resized to 1280 px / 1 MB max; attributes: object, catalogue, date, equipment, rating, picture id. Picture coordinates are never published

Topics

<base> is the base topic (myastroboard by default), <prefix> the discovery prefix.

TopicPayloadRetained
<base>/statusonline / offline (last will) - the availability of every entityyes
<base>/board/stateJSON, board diagnosticsyes
<base>/location/<location_id>/stateJSON, one object with every enabled location module’s keysyes
<base>/user/<user_id>/stateJSON, user activity keysyes
<base>/user/<user_id>/astrodex/latest_imageraw JPEG (max 1280 px, max 1 MB)yes
<prefix>/device/<base>_board/configdevice discovery messageyes
<prefix>/device/<base>_loc_<location_id>/configdevice discovery messageyes
<prefix>/device/<base>_user_<user_id>/configdevice discovery messageyes

Every timestamp is ISO 8601 with a UTC offset; an unknown value is JSON null (the entity shows unknown). A location device carries location_id, location_name and timezone next to the entity keys; a user device carries user_id and username.

The MQTT integration’s own homeassistant/status topic is the connector’s only subscription: online triggers a full republish.

Last updated 2026-11-13