mqtt-control-map/types/types.js
uwap efc5af37ce Now with sliders!
Seriously, someone really should clean this mess of code up soon
2017-09-17 05:35:20 +02:00

50 lines
994 B
JavaScript

declare type Map<K,V> = { [K]: V };
declare type Topic = {
state: string,
command: string,
value: any,
values: Map<string,any>,
parseState?: (msg: Object) => any
};
declare type Topics = Map<string,Topic>;
declare type ControlUI = {
type: "toggle" | "dropDown" | "slider",
text: string,
topic: string,
enableCondition?: (val: any) => boolean,
// TOGGLE optional properties
on?: string, // on override for toggle
off?: string, // off override for toggle
toggled?: (val: any) => boolean,
// DROPDOWN optional properties
options?: Map<string,any>, //options for dropDown
// SLIDER optional properties
min?: number,
max?: number,
step?: number
};
declare type Control = {
name: string,
position: Array<number>,
icon: string,
ui: Array<ControlUI>
};
declare type Controls = Map<string,Control>;
declare type Config = {
topics: Topics,
controls: Controls
};
declare type State = {
mqtt: ?any,
ui: ?string,
values: Map<string,any>
};