feat: Allow 2-way audio detection to be skipped and timed (#2355)
- For #2313
This commit is contained in:
@@ -85,15 +85,13 @@ export class Camera {
|
||||
): Promise<Capabilities> {
|
||||
const rawCapabilities = await this._getRawCapabilities(options);
|
||||
const config = this.getConfig();
|
||||
const has2WayAudio = await liveProviderSupports2WayAudio(
|
||||
options.hass,
|
||||
config,
|
||||
this._getGo2RTCMetadataEndpoint(),
|
||||
this.getProxyConfig(),
|
||||
);
|
||||
const has2WayAudio = await this._has2WayAudioCapability(options.hass);
|
||||
|
||||
return new Capabilities(
|
||||
{ ...rawCapabilities, '2-way-audio': has2WayAudio },
|
||||
{
|
||||
...rawCapabilities,
|
||||
'2-way-audio': has2WayAudio,
|
||||
},
|
||||
{
|
||||
disable: config.capabilities?.disable,
|
||||
disableExcept: config.capabilities?.disable_except,
|
||||
@@ -101,6 +99,26 @@ export class Camera {
|
||||
);
|
||||
}
|
||||
|
||||
protected async _has2WayAudioCapability(hass: HomeAssistant): Promise<boolean> {
|
||||
if (this._config.capabilities?.disable?.includes('2-way-audio')) {
|
||||
return false;
|
||||
}
|
||||
const disableExcept = this._config.capabilities?.disable_except;
|
||||
if (disableExcept?.length && !disableExcept.includes('2-way-audio')) {
|
||||
return false;
|
||||
}
|
||||
if (this._config.capabilities?.force?.includes('2-way-audio')) {
|
||||
return true;
|
||||
}
|
||||
return await liveProviderSupports2WayAudio(
|
||||
hass,
|
||||
this.getConfig(),
|
||||
this.getConfig().go2rtc.metadata_fetch_timeout_seconds,
|
||||
this._getGo2RTCMetadataEndpoint(),
|
||||
this.getProxyConfig(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get raw capabilities for this camera. Subclasses should override
|
||||
* and call super._getRawCapabilities() to extend defaults.
|
||||
|
||||
Reference in New Issue
Block a user