Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/data/camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { timeCacheEntityPromiseFunc } from "../common/util/time-cache-entity-pro
import { HomeAssistant } from "../types";
import { getSignedPath } from "./auth";

export const CAMERA_ORIENTATIONS = [1, 2, 3, 4, 6, 8];
export const CAMERA_SUPPORT_ON_OFF = 1;
export const CAMERA_SUPPORT_STREAM = 2;

Expand All @@ -26,6 +27,7 @@ export interface CameraEntity extends HassEntityBase {

export interface CameraPreferences {
preload_stream: boolean;
orientation: number;
Comment thread
uvjustin marked this conversation as resolved.
}

export interface CameraThumbnail {
Expand Down Expand Up @@ -114,6 +116,7 @@ export const updateCameraPrefs = (
entityId: string,
prefs: {
preload_stream?: boolean;
orientation?: number;
}
) =>
hass.callWS<CameraPreferences>({
Expand Down
56 changes: 53 additions & 3 deletions src/panels/config/entities/entity-registry-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ import { computeDomain } from "../../../common/entity/compute_domain";
import { domainIcon } from "../../../common/entity/domain_icon";
import { supportsFeature } from "../../../common/entity/supports-feature";
import { stringCompare } from "../../../common/string/compare";
import { LocalizeFunc } from "../../../common/translations/localize";
import {
LocalizeFunc,
LocalizeKeys,
} from "../../../common/translations/localize";
import "../../../components/ha-alert";
import "../../../components/ha-area-picker";
import "../../../components/ha-expansion-panel";
Expand All @@ -32,6 +35,7 @@ import type { HaSwitch } from "../../../components/ha-switch";
import "../../../components/ha-textfield";
import {
CameraPreferences,
CAMERA_ORIENTATIONS,
CAMERA_SUPPORT_STREAM,
fetchCameraPrefs,
STREAM_TYPE_HLS,
Expand Down Expand Up @@ -581,12 +585,12 @@ export class EntityRegistrySettings extends SubscribeMixin(LitElement) {
<ha-settings-row>
<span slot="heading"
>${this.hass.localize(
"ui.dialogs.entity_registry.editor.preload_stream"
"ui.dialogs.entity_registry.editor.stream.preload_stream"
)}</span
>
<span slot="description"
>${this.hass.localize(
"ui.dialogs.entity_registry.editor.preload_stream_description"
"ui.dialogs.entity_registry.editor.stream.preload_stream_description"
)}</span
>
<ha-switch
Expand All @@ -595,6 +599,38 @@ export class EntityRegistrySettings extends SubscribeMixin(LitElement) {
>
</ha-switch>
</ha-settings-row>
<ha-settings-row>
<span slot="heading"
>${this.hass.localize(
"ui.dialogs.entity_registry.editor.stream.stream_orientation"
)}</span
>
<span slot="description"
>${this.hass.localize(
"ui.dialogs.entity_registry.editor.stream.stream_orientation_description"
)}</span
>
<ha-select
.label=${this.hass.localize(
"ui.dialogs.entity_registry.editor.stream.stream_orientation"
)}
naturalMenuWidth
fixedMenuPosition
@selected=${this._handleCameraOrientationChanged}
@closed=${stopPropagation}
>
${CAMERA_ORIENTATIONS.map((num) => {
const localizeStr =
"ui.dialogs.entity_registry.editor.stream.stream_orientation_" +
num.toString();
return html`
<mwc-list-item value=${num}>
${this.hass.localize(localizeStr as LocalizeKeys)}
</mwc-list-item>
`;
})}
</ha-select>
</ha-settings-row>
`
: ""}
<ha-expansion-panel
Expand Down Expand Up @@ -836,6 +872,20 @@ export class EntityRegistrySettings extends SubscribeMixin(LitElement) {
}
}

private async _handleCameraOrientationChanged(ev) {
try {
this._cameraPrefs = await updateCameraPrefs(
this.hass,
this.entry.entity_id,
{
orientation: ev.currentTarget.value,
}
);
} catch (err: any) {
showAlertDialog(this, { text: err.message });
}
}

private _viewStatusChanged(ev: CustomEvent): void {
switch ((ev.target as any).value) {
case "enabled":
Expand Down
16 changes: 14 additions & 2 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -896,8 +896,20 @@
"follow_device_area": "Follow device area",
"change_device_area": "Change device area",
"configure_state": "{integration} options",
"preload_stream": "Preload camera stream",
"preload_stream_description": "This keeps the camera stream open in the background so it shows quicker. Warning! This is device intensive."
"stream": {
"preload_stream": "Preload camera stream",
"preload_stream_description": "This keeps the camera stream open in the background so it shows quicker. Warning! This is device intensive.",
"stream_orientation": "Camera stream orientation",
"stream_orientation_description": "The orientation transformation to use for the camera stream.",
"stream_orientation_1": "No orientation transform",
"stream_orientation_2": "Mirror",
"stream_orientation_3": "Rotate 180",
"stream_orientation_4": "Flip",
"stream_orientation_5": "Rotate left and flip",
"stream_orientation_6": "Rotate left",
"stream_orientation_7": "Rotate right and flip",
"stream_orientation_8": "Rotate right"
}
}
},
"helper_settings": {
Expand Down