feat: Support HA event entities as triggers (#2506)
This commit is contained in:
committed by
dermotduffy
parent
f1fad59a89
commit
4b72fcd629
@@ -3,7 +3,7 @@ import { StateWatcherSubscriptionInterface } from '../card-controller/hass/state
|
||||
import { PTZAction, PTZActionPhase } from '../config/schema/actions/custom/ptz';
|
||||
import { CameraConfig } from '../config/schema/cameras';
|
||||
import { EnabledProxyConfig, resolveProxyConfig } from '../config/schema/common/proxy';
|
||||
import { isTriggeredState } from '../ha/is-triggered-state';
|
||||
import { getTriggerEventType } from '../ha/get-trigger-event-type';
|
||||
import { HassStateDifference, HomeAssistant } from '../ha/types';
|
||||
import { localize } from '../localize/localize';
|
||||
import { CapabilitiesRaw, CapabilityKey, Endpoint } from '../types';
|
||||
@@ -262,10 +262,14 @@ export class Camera {
|
||||
}
|
||||
|
||||
protected _stateChangeHandler = (difference: HassStateDifference): void => {
|
||||
const type = getTriggerEventType(difference);
|
||||
if (type === null) {
|
||||
return;
|
||||
}
|
||||
this._eventCallback?.({
|
||||
cameraID: this.getID(),
|
||||
id: difference.entityID,
|
||||
type: isTriggeredState(difference.newState.state) ? 'new' : 'end',
|
||||
type,
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -157,7 +157,8 @@ export interface CameraEvent {
|
||||
| 'new' // A new event has started.
|
||||
| 'update' // An update for an event is available (except GenAI).
|
||||
| 'end' // An event has ended.
|
||||
| 'genai'; // An AI based update is available.
|
||||
| 'genai' // An AI based update is available.
|
||||
| 'signal'; // A momentary signal (no start/end, just an instant).
|
||||
|
||||
// When fidelity is `high`, the engine is assumed to provide exact details of
|
||||
// what new media is available. Otherwise all media types are assumed to be
|
||||
|
||||
Reference in New Issue
Block a user