1.0.0-alpha.1 • Published 1 year ago
@ebelong-lib/scene v1.0.0-alpha.1
自动化场景字段类型声明
Intuitive, type safe 无任何注入,只有类型声明和部分常量
- 💡 Intuitive
- 🔑 Type Safe
- ⚙️ Devtools support
- 🔌 Extensible
- 🏗 Modular by design
des
FAQ
A few notes about the project and possible questions:
Q:
A:
Installation
# or pnpm or yarn
yarn build
yalc publish
# 其他项目中
yalc add @ebelong-lib/sceneUsage
SceneRule 主要针对自动化场景联动模块,if,when,then数据的类型安全规范,
import { SceneRule, SelectType } from "@ebelong-lib/scene";
// if数据
const ifData: SceneRule.IF.Root = {
triggers: [],
};
// when数据
const whenData: SceneRule.WHEN.Root = {
conditions: {
type: TermCondType.TermConditionTypeOr,
terms: [],
},
invalidRanges: [],
validRanges: [],
};
// then数据
const thenData: SceneRule.THEN.Root = {
actions: [],
};
await fetchClient.POST("/api/v1/things/rule/scene/info/update", {
body: {
id: parseInt(sceneId),
areaID: _areaID,
if: JSON.stringify(ifData),
when: JSON.stringify(whenData),
then: JSON.stringify(thenData),
type: SceneType.SceneTypeAuto,
name: editScenceNameState.name,
},
});部分枚举类型
import { TriggerType } from "@ebelong-lib/scene";
const triggerType = TriggerType.TriggerTypeDevice // "device" 表示设备触发
// 其他枚举说明可查看源码标注(待补充)
// SelectType
// TriggerDeviceType
// StateKeepType
// ExecType
// RepeatType
// WeatherType
// CmpType
// ActionType
// ActionAlarmMode
// NotifyUserType
// ActionDeviceType
// SceneType
// Status
// DateRangeType
// TimeRangeType
// TermCondType
// TermColumnType
// TimeType1.0.0-alpha.1
1 year ago