mirror of
https://github.com/home-assistant/frontend.git
synced 2025-12-19 18:28:42 +00:00
47 lines
1.0 KiB
TypeScript
47 lines
1.0 KiB
TypeScript
import type {
|
|
HassEntityAttributeBase,
|
|
HassEntityBase,
|
|
} from "home-assistant-js-websocket";
|
|
import { UNAVAILABLE } from "./entity/entity";
|
|
|
|
export type LawnMowerEntityState =
|
|
| "paused"
|
|
| "mowing"
|
|
| "returning"
|
|
| "docked"
|
|
| "error";
|
|
|
|
export const enum LawnMowerEntityFeature {
|
|
START_MOWING = 1,
|
|
PAUSE = 2,
|
|
DOCK = 4,
|
|
}
|
|
|
|
interface LawnMowerEntityAttributes
|
|
extends HassEntityAttributeBase, Record<string, any> {}
|
|
|
|
export interface LawnMowerEntity extends HassEntityBase {
|
|
attributes: LawnMowerEntityAttributes;
|
|
}
|
|
|
|
export function canStartMowing(stateObj: LawnMowerEntity): boolean {
|
|
if (stateObj.state === UNAVAILABLE) {
|
|
return false;
|
|
}
|
|
return stateObj.state !== "mowing";
|
|
}
|
|
|
|
export function canPause(stateObj: LawnMowerEntity): boolean {
|
|
if (stateObj.state === UNAVAILABLE) {
|
|
return false;
|
|
}
|
|
return stateObj.state !== "paused";
|
|
}
|
|
|
|
export function canDock(stateObj: LawnMowerEntity): boolean {
|
|
if (stateObj.state === UNAVAILABLE) {
|
|
return false;
|
|
}
|
|
return stateObj.state !== "docked";
|
|
}
|