Skip to content

OBS MQTT Status to Home Assistant

Notifications You must be signed in to change notification settings

gritting/hass-obs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

OBS Status via MQTT to Home Assistant

Introduction & Attribution Note:

This is my personal fork of dlsniper's clone of HeedfulCrayon's original script. This fork is not affiliated with or endorsed by the previous/original authors, but I thank them for their helpful foundations that have made my little version of this script possible.

  • Original work and copyrighted by @HeedfulCrayon
  • Virtual Camera support added by @dlsniper
  • This fork by @gritting:
    1. New "model name" option for MQTT config, useful for identifying the machine running the script in Home Assistant.
    2. New script defaults: Updated to include changes like MQTT base topic and username settings.
    3. Minor bug fixes and improvements (see commit history for full details)

Compatibility

  • Tested with: OBS Studio 30.2.1-1 and Home Assistant 2024.11.1

Setup Instructions:

Prerequisites

  1. Download the script
  2. Install mqtt-wrapper by running pip install mqtt-wrapper
  3. Open OBS Studio:
    • Add a script (Tools -> Scripts)
  4. Configure Parameters: The default base channel is homeassistant, and default sensor name is obs_state. This will create a path like homeassistant/sensor/obs_state. Make sure you set all of your config options before setting the password to prevent unintentionally sending the wrong base topic/sensor name.
  5. Click the script refresh button to load the script.

With MQTT Autodiscovery Enabled

  1. If you have enabled MQTT Autodiscovery in Home Assistant: you should see sensors for recording, streaming, virtual camera, and profile controls automatically appear under your MQTT integration.

  2. You can check if the topic appears as expected in your broker with a tool like MQTT Explorer.

With MQTT Autodiscovery Disabled

  1. **You must add manual configuration if MQTT Autodiscovery is not turned on, similar to below:
    • Sensor Configuration:

      - platform: "mqtt"
          name: "OBS State"
          state_topic: "obs_state/state"
          icon: "mdi:video-wireless"
          force_update: true
          qos: 1
          json_attributes_topic: "obs_state/attributes"
    • Switch for Controlling Recording:

      - platform: "mqtt"
          name: OBS Record Switch
          state_topic: "homeassistant/switch/obs_state/record/state"
          command_topic: "homeassistant/switch/obs_state/record/set"
          available_topic: "homeassistant/switch/obs_state/record/available"
          payload_on: "ON"
          payload_off: "OFF"
          icon: mdi:record
    • Switch for Controlling Streaming:

      - platform: "mqtt"
          name: OBS Stream Switch
          state_topic: "homeassistant/switch/obs_state/stream/state"
          command_topic: "homeassistant/switch/obs_state/stream/set"
          available_topic: "homeassistant/switch/obs_state/stream/available"
          payload_on: "ON"
          payload_off: "OFF"
          icon: mdi:broadcast
    • Switch for Controlling Virtual Camera

      - platform: "mqtt"
          name: OBS Virtual Camera Switch
          state_topic: "homeassistant/switch/obs_state/virtual_camera/state"
          command_topic: "homeassistant/switch/obs_state/virtual_camera/set"
          available_topic: "homeassistant/switch/obs_state/virtual_camera/available"
          payload_on: "ON"
          payload_off: "OFF"
          icon: mdi:camera-wireless
    • Switch for Controlling Profiles (add one switch per profile):

      - platform: "mqtt"
          name: OBS Test Profile
          state_topic: "homeassistant/switch/profile_name/state"
          command_topic: "homeassistant/switch/profile_name/profile/set"
          payload_on: "ON"
          payload_off: "OFF"
          icon: mdi:alpha-p-box

Sensor States:

  • Recording
  • Streaming
  • Streaming and Recording
  • Virtual Camera
  • Stopped (OBS Open)
  • Off (OBS Closed)

Updating with Autodiscovery:

If you update the script while autodiscovery is enabled, remove the following topics to avoid duplicates showing up in the Home Assistant MQTT integration. You can use a tool like MQTT Explorer to delete these topics from your broker easily.

  • homeassistant/sensor/obs_state/config for sensor state.
  • homeassistant/switch/obs_state_stream/config for stream switch.
  • homeassistant/switch/obs_state_record/config for record switch.
  • homeassistant/switch/obs_state_virtual_camera/config for virtual

About

OBS MQTT Status to Home Assistant

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%