parent
0f08e9f1ee
commit
a44eea520a
5 changed files with 14 additions and 6 deletions
|
|
@ -493,6 +493,11 @@ const config: Config = {
|
||||||
min: 0,
|
min: 0,
|
||||||
max: 255,
|
max: 255,
|
||||||
text: "Helligkeit",
|
text: "Helligkeit",
|
||||||
|
marks: [
|
||||||
|
{ value: 1, label: "Dunkel" },
|
||||||
|
{ value: 120, label: "Medium" },
|
||||||
|
{ value: 254, label: "Hell" }
|
||||||
|
],
|
||||||
icon: svg(icons.mdiBrightness7),
|
icon: svg(icons.mdiBrightness7),
|
||||||
topic: "livingroombrightness"
|
topic: "livingroombrightness"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,7 @@ class App extends React.PureComponent<AppProps & Classes, AppState> {
|
||||||
const topic = topics[i];
|
const topic = topics[i];
|
||||||
const stateTopic = this.topics[topic].state;
|
const stateTopic = this.topics[topic].state;
|
||||||
const typeConversion = stateTopic?.type?.from ?? stateTopic?.type;
|
const typeConversion = stateTopic?.type?.from ?? stateTopic?.type;
|
||||||
const val = (typeConversion ?? ((x) => x.toString()))(message);
|
const val = (typeConversion ?? ((x: Buffer) => x.toString()))(message);
|
||||||
this.setMqttStateDebounced(
|
this.setMqttStateDebounced(
|
||||||
{mqttState: Object.assign({},
|
{mqttState: Object.assign({},
|
||||||
merge(this.state.mqttState, { [topic]: val}))});
|
merge(this.state.mqttState, { [topic]: val}))});
|
||||||
|
|
@ -152,7 +152,7 @@ class App extends React.PureComponent<AppProps & Classes, AppState> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const rawTopic = commandTopic.name;
|
const rawTopic = commandTopic.name;
|
||||||
const typeConversion = commandTopic.type?.to ?? commandTopic.type;
|
const typeConversion = commandTopic?.type?.to ?? commandTopic.type;
|
||||||
const value = (typeConversion ?? Buffer.from)(val);
|
const value = (typeConversion ?? Buffer.from)(val);
|
||||||
this.state.mqttSend(rawTopic, value);
|
this.state.mqttSend(rawTopic, value);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,12 @@ const BaseComponent = ({Icon, Label}, item, state, changeState) => (
|
||||||
<Label />
|
<Label />
|
||||||
<SliderComponent
|
<SliderComponent
|
||||||
value={parseFloat(getValue(item, state))}
|
value={parseFloat(getValue(item, state))}
|
||||||
min={item.min || 0} max={item.max || 100}
|
min={item.min ?? 0} max={item.max ?? 100}
|
||||||
step={item.step || 1}
|
step={item.step}
|
||||||
|
marks={item.marks ?? false}
|
||||||
onChange={changeSliderValue(item, changeState)}
|
onChange={changeSliderValue(item, changeState)}
|
||||||
disabled={isDisabled(item, state)}
|
disabled={isDisabled(item, state)}
|
||||||
|
valueLabelDisplay="auto"
|
||||||
style={{marginLeft: 40}} />
|
style={{marginLeft: 40}} />
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -58,9 +58,10 @@ export type UISlider = $ReadOnly<{|
|
||||||
topic: string,
|
topic: string,
|
||||||
icon?: Icon,
|
icon?: Icon,
|
||||||
enableCondition?: (s: State) => boolean,
|
enableCondition?: (s: State) => boolean,
|
||||||
|
marks?: boolean | Array<{ value: number, label: string}>,
|
||||||
min?: number,
|
min?: number,
|
||||||
max?: number,
|
max?: number,
|
||||||
step?: number
|
step?: ?number
|
||||||
|}>;
|
|}>;
|
||||||
|
|
||||||
export type UISection = $ReadOnly<{|
|
export type UISection = $ReadOnly<{|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ export const json = (path: string, innerType?: TopicType): TopicType => {
|
||||||
from: (msg) => parseAgain(Buffer.from(
|
from: (msg) => parseAgain(Buffer.from(
|
||||||
at(JSON.parse(msg.toString()), path)[0].toString())),
|
at(JSON.parse(msg.toString()), path)[0].toString())),
|
||||||
to: (msg) => Buffer.from(
|
to: (msg) => Buffer.from(
|
||||||
JSON.serialize(set({}, path, parseFirst(msg).toString())))
|
JSON.stringify(set({}, path, parseFirst(msg).toString())))
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue