Skip to content

Comments

[WIP] MQTT Support / Home Assistant Integration#1195

Draft
PH89 wants to merge 6 commits intojetkvm:devfrom
PH89:mqtt_client
Draft

[WIP] MQTT Support / Home Assistant Integration#1195
PH89 wants to merge 6 commits intojetkvm:devfrom
PH89:mqtt_client

Conversation

@PH89
Copy link
Contributor

@PH89 PH89 commented Feb 7, 2026

Summary

  • Adds a full-featured MQTT client to JetKVM with Home Assistant Auto-Discovery support
  • Publishes device state (video signal, USB, cloud connection, active sessions, network info, system metrics, virtual media) as retained MQTT messages
  • Supports TLS connections with validation against rootcerts and optional insecure mode
  • Implements controllable entities via MQTT: mouse jiggler (switch), DC power (switch), ATX buttons, device reboot, firmware update, and virtual media selection
  • Adds EnableActions config toggle — when disabled, controllable entities are replaced with read-only sensors/binary sensors while keeping full monitoring capability. The firmware update entity remains visible but without install command.
  • Firmware update entity reports real-time in_progress status and update_percentage during OTA updates
  • Virtual media select entity dynamically updates its options list, supports storage-based and HTTP-mounted images, and exposes a source attribute (storage/url/none)
  • System metrics sensors: CPU load (with state_class: measurement for graphs), SoC temperature, memory usage, storage used/free
  • Extension-aware discovery: ATX and DC entities are published/removed based on the active extension
  • Proper cleanup: discovery entries and state topics are cleared when MQTT or HA Discovery is disabled
  • Adds MQTT settings page to the UI with full configuration (broker, port, TLS, credentials, base topic, HA Discovery toggle, actions toggle)
  • Includes English and German localization for all MQTT settings

Related Issues:

Test plan

  • Enable MQTT and verify connection to broker (with and without TLS)
  • Verify HA Auto-Discovery creates all expected entities
  • Toggle EnableActions off → confirm switches become binary sensors, buttons disappear, select becomes sensor, update entity loses install button
  • Toggle EnableActions on → confirm controllable entities reappear
  • Trigger firmware update via HA → confirm progress bar and percentage are displayed and update is applied in the background.
  • Mount a local disk image via the virtual media select → confirm state updates
  • Mount an HTTP image externally → confirm select shows extracted filename and source attribute is url
  • Switch active extension (ATX ↔ DC ↔ Serial ↔ none) → confirm discovery updates accordingly
  • Disable HA Discovery → confirm all discovery entries are removed from the broker (homeassistant topic)
  • Disable MQTT entirely → confirm all topics and discovery entries are cleaned up
  • Verify system metrics sensors (CPU load, temperature, memory, storage) update periodically and support HA graphs

Preview

JetKVM_MQTT

@PH89 PH89 mentioned this pull request Feb 7, 2026
2 tasks
@Igglybuff
Copy link

@PH89 I've tested this on my JetKVM device and it seems to work well - I'll play around with it next week to see if I spot any issues.

I wonder if there's a simple way to add a debounce delay for certain things like ATX HDD LED which can flick on and off repeatedly/quickly for long read/write sessions (if I'm using my NAS, this spams my broker and Home Assistant 😅).

@PH89
Copy link
Contributor Author

PH89 commented Feb 10, 2026

I will check this out. Normally it should be possible. But should be configurable. For MQTT server it should not be a problem to handle such change frequency. On the Home Assistant site it could cause a quick pollution of the history log. So maybe it is better to disable logging for these entities.

@CLAassistant
Copy link

CLAassistant commented Feb 13, 2026

CLA assistant check
All committers have signed the CLA.

@PH89 PH89 force-pushed the mqtt_client branch 2 times, most recently from 1be2637 to 6aa24d5 Compare February 13, 2026 16:03
@PH89
Copy link
Contributor Author

PH89 commented Feb 13, 2026

@Igglybuff Integrated debounce delay for ATX HDD Led.

PH89 and others added 6 commits February 13, 2026 17:11
…n be

  executed. When disabled, controllable entities (switches, buttons, select)
  are replaced with read-only sensors/binary sensors. The firmware update
  entity remains visible but without install capability.

- Fix update entity progress feedback by removing value_template which
  prevented HA from parsing in_progress/update_percentage fields. Add
  updateRequested flag and lastKnownLatestVersion cache to bridge the gap
  between MQTT command and OTA state transitions.

- Add system metrics sensors: CPU Load (with state_class measurement for
  graphs), SoC Temperature, Memory Used, Storage Used, Storage Free.

- Add Virtual Media select entity with dynamic options list, mount/unmount
  support, source attribute (url/storage)
…s too flaky states in HA.

- Changes on entities like mouse jiggler, virtual media, or active sessions are now published to MQTT instantly.
Previously, these changes only appeared in Home Assistant after the next periodic update cycle.
Additionally, all current states (ATX/DC, jiggler, virtual media,
sessions, network, system, video, etc.) are now published immediately
when the MQTT connection is first established, so Home Assistant knows
the full device state right away on startup or reconnect.

- Also fixes slow session disconnect detection: ICE 'Disconnected' state
now triggers an immediate connection close instead of waiting for the
ICE timeout (5-30s) before transitioning through 'Failed' to 'Closed'.
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