OBS Streaming: obs-websocket

Has anyone integrated the OBS WebAPI (obs-websocket) into HASS core? I want to use a zwave lightswitch to trigger OBS functions and I haven’t seen anyone on either forum mentioning the other product. Here’s a list of available language APIs for obs-websocket, anyone have an idea on what the easiest way to link a below API with HASS?

Link to main GitHub if desired.

1 Like

i’m interested in this as well… i have started live-streaming yard work and wanted to use motion detectors to switch the camera view.

I will look into this and see how difficult it would be to create an integration.

1 Like

That would be awesome. I would love to see what you come up with! I don’t even know where to start but let me know if there is anything I can do to assist.

I have been thinking about this over the past week and have some ideas but wanted to see what you thought, in terms of making this part of HomeAssistant.

This is the protocol doc, as in everything OBS Websocket can control:

At a bare minimum, features I would want are

  1. Start/stop stream
  2. start/stop recording
  3. Switch scenes
  4. Enable/disable sources in scenes
  5. Adjust audio (volume/mute) on sources

I think that the best way to represent OBS is as a “media player” entity.

  • input sources would represent scenes (changing input source would change the selected scene in OBS)
  • Streaming is handled by play/pause

Recording on/off would be a separate switch entity as the media player does not have a record option.

That gets us #1-3.

#4-5 are more difficult and i have a couple ideas

  1. Create services for enabling/disabling & adjusting audio on sources. This kind of sucks because you have to create your own scripts and input entities to control this.
  2. Create two switches for each source to enable/disable. Can’t handle volume in this way.
  3. Create media_player entities for each source (on/off controls visibility, gives audio control). This could be a challenge if you have a lot of sources, as there will be many media_player entities

Which one do you think is most manageable from the UI?

an additional challenge is that the “official” Python library to interact with the websocket connection is not using co-routines (making it sort of not friendly with HomeAssistant), but I think I can work around that

Somehow I missed these posts… Did you get any farther on this?

i’d also love something like this, i use OBS for a webcam so would love something that launched the app, powered on my camera and then loaded a profile and started the virtual camera via an automation

I am also looking for a solution, or looking to develop a solution for this. I did however stumble upon this OBS Python - Real-time MQTT Status | OBS Forums

I have not been able to get this one working, but I have modified it, and will create a link to my github as well as instructions on how to get it working

1 Like

So here is the script. It isn’t using the obs-websocket, rather the script function built into obs

4 Likes

Nice! This is really useful, thanks!

I have updated the gist and now you can start and stop streaming with a switch in HA

3 Likes

Awesome! I this is the link between the two I think I needed, thank U! Excited to finish my project now.


Just passing by to thank you for the python script HeedfulCrayon, I use it to automate the streaming lighting. Is there any chance that we can change the scene from HA or retrieve the scene name in use?

i read there:

“…mqtt autodiscovery is on…”

where is this option in HA`?

image

seems that this default on

possible to add a OBS Hotkey in HA`?