[mqtt.homeassistant] Fix python packages path on Windows (#19249)

So explicitly add the *nix-style path to the syspath, so that
even on Windows the installed packages can be found.

Signed-off-by: Cody Cutrer <cody@cutrer.us>
This commit is contained in:
Cody Cutrer
2025-08-27 09:19:48 +02:00
committed by GitHub
parent 0e37ae1ed2
commit fda5a9ce1a
@@ -60,6 +60,14 @@ public class HomeAssistantPythonBridge {
context.eval(PYTHON,
"""
# we need to set up the path just like it would have been set up on Linux, even if we're
# on Windows
import os
import sys
if os.sep != '/':
sys.path.append(os.path.join(sys.prefix, "lib", "python%d.%d" % sys.version_info[:2], "site-packages"))
from homeassistant.helpers.template import Template
from homeassistant.components.mqtt.models import MqttCommandTemplate, MqttValueTemplate
from homeassistant.components.mqtt.discovery import process_discovery_config