88from .homeassistant import APIHomeAssistant
99from .host import APIHost
1010from .network import APINetwork
11+ from .proxy import APIProxy
1112from .supervisor import APISupervisor
1213from .security import APISecurity
1314from .snapshots import APISnapshots
@@ -63,9 +64,9 @@ def register_supervisor(self, supervisor, snapshots, addons, host_control,
6364 '/supervisor/options' , api_supervisor .options )
6465 self .webapp .router .add_get ('/supervisor/logs' , api_supervisor .logs )
6566
66- def register_homeassistant (self , dock_homeassistant ):
67+ def register_homeassistant (self , homeassistant ):
6768 """Register homeassistant function."""
68- api_hass = APIHomeAssistant (self .config , self .loop , dock_homeassistant )
69+ api_hass = APIHomeAssistant (self .config , self .loop , homeassistant )
6970
7071 self .webapp .router .add_get ('/homeassistant/info' , api_hass .info )
7172 self .webapp .router .add_get ('/homeassistant/logs' , api_hass .logs )
@@ -75,10 +76,21 @@ def register_homeassistant(self, dock_homeassistant):
7576 self .webapp .router .add_post ('/homeassistant/stop' , api_hass .stop )
7677 self .webapp .router .add_post ('/homeassistant/start' , api_hass .start )
7778 self .webapp .router .add_post ('/homeassistant/check' , api_hass .check )
79+
80+ def register_proxy (self , homeassistant , websession ):
81+ """Register HomeAssistant API Proxy."""
82+ api_proxy = APIProxy (self .loop , homeassistant , websession )
83+
84+ self .webapp .router .add_get (
85+ '/homeassistant/api/websocket' , api_proxy .websocket )
86+ self .webapp .router .add_get (
87+ '/homeassistant/websocket' , api_proxy .websocket )
7888 self .webapp .router .add_post (
79- '/homeassistant/api/{path:.+}' , api_hass .api )
89+ '/homeassistant/api/{path:.+}' , api_proxy .api )
90+ self .webapp .router .add_get (
91+ '/homeassistant/api/{path:.+}' , api_proxy .api )
8092 self .webapp .router .add_get (
81- '/homeassistant/api/{path:.+} ' , api_hass .api )
93+ '/homeassistant/api' , api_proxy .api )
8294
8395 def register_addons (self , addons ):
8496 """Register homeassistant function."""
0 commit comments