Add basic esper status info support
This commit is contained in:
parent
832ed3d1bf
commit
da7105c90b
5 changed files with 51 additions and 6 deletions
|
|
@ -7,7 +7,7 @@ const config : Config = {
|
||||||
color: "orange",
|
color: "orange",
|
||||||
mqtt: "ws://map.rzl:1884"
|
mqtt: "ws://map.rzl:1884"
|
||||||
},
|
},
|
||||||
topics: {
|
topics: Object.assign({}, {
|
||||||
led_stahltraeger: {
|
led_stahltraeger: {
|
||||||
state: "/service/openhab/out/pca301_ledstrips/state",
|
state: "/service/openhab/out/pca301_ledstrips/state",
|
||||||
command: "/service/openhab/in/pca301_ledstrips/command",
|
command: "/service/openhab/in/pca301_ledstrips/command",
|
||||||
|
|
@ -116,8 +116,9 @@ const config : Config = {
|
||||||
command: "/service/openhab/in/pca301_infoscreen/command",
|
command: "/service/openhab/in/pca301_infoscreen/command",
|
||||||
defaultValue: "OFF",
|
defaultValue: "OFF",
|
||||||
values: { on: "ON", off: "OFF" }
|
values: { on: "ON", off: "OFF" }
|
||||||
}
|
}},
|
||||||
},
|
utils.esper_topics("afba40")
|
||||||
|
),
|
||||||
controls: {
|
controls: {
|
||||||
led_stahltrager: {
|
led_stahltrager: {
|
||||||
name: "LED Stahlträger",
|
name: "LED Stahlträger",
|
||||||
|
|
@ -220,14 +221,14 @@ const config : Config = {
|
||||||
position: [450, 590],
|
position: [450, 590],
|
||||||
icon: "fire",
|
icon: "fire",
|
||||||
iconColor: ({flyfry}) => flyfry == "on" ? "#6666FF" : "#000000",
|
iconColor: ({flyfry}) => flyfry == "on" ? "#6666FF" : "#000000",
|
||||||
ui: [
|
ui: utils.esper_statistics("afba40", [
|
||||||
{
|
{
|
||||||
type: "toggle",
|
type: "toggle",
|
||||||
text: "Fliegenbratgerät",
|
text: "Fliegenbratgerät",
|
||||||
topic: "flyfry",
|
topic: "flyfry",
|
||||||
icon: "power"
|
icon: "power"
|
||||||
}
|
}
|
||||||
]
|
])
|
||||||
},
|
},
|
||||||
artnet: {
|
artnet: {
|
||||||
name: "Artnet",
|
name: "Artnet",
|
||||||
|
|
|
||||||
|
|
@ -2,3 +2,28 @@
|
||||||
|
|
||||||
export const rainbow = "rgba(200,120,120,0.5);"
|
export const rainbow = "rgba(200,120,120,0.5);"
|
||||||
+ "--before-background: linear-gradient(40deg, #FF0000 0%, #00FF00 50%, #0000FF 70%, #FFFF00 100%);";
|
+ "--before-background: linear-gradient(40deg, #FF0000 0%, #00FF00 50%, #0000FF 70%, #FFFF00 100%);";
|
||||||
|
|
||||||
|
export const esper_topics = (chip_id: string) => ({
|
||||||
|
[ `esper_${chip_id}_version` ]: {
|
||||||
|
state: `/service/esper/${chip_id}/info`,
|
||||||
|
command: "",
|
||||||
|
defaultValue: "UNKNOWN",
|
||||||
|
values: {},
|
||||||
|
parseState: msg => JSON.parse(msg.toString()).version.esper
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export const esper_statistics = (chip_id: string,
|
||||||
|
prev_ui: Array<ControlUI> = []) => (
|
||||||
|
prev_ui.concat([
|
||||||
|
{
|
||||||
|
type: "section",
|
||||||
|
text: "Funkdose"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "text",
|
||||||
|
text: "Version",
|
||||||
|
topic: `esper_${chip_id}_version`
|
||||||
|
}
|
||||||
|
])
|
||||||
|
);
|
||||||
|
|
|
||||||
|
|
@ -172,3 +172,12 @@ export class Section extends UiItem<UISection> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class Text extends UiItem<UIText> {
|
||||||
|
render() {
|
||||||
|
return [
|
||||||
|
<ListItemText key="label" primary={this.props.item.text} />,
|
||||||
|
<ListItemText key="val" secondary={this.getValue().internal} />
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ import Button from "material-ui/Button";
|
||||||
import Slider from "material-ui-old/Slider";
|
import Slider from "material-ui-old/Slider";
|
||||||
import MuiThemeProvider from "material-ui-old/styles/MuiThemeProvider";
|
import MuiThemeProvider from "material-ui-old/styles/MuiThemeProvider";
|
||||||
|
|
||||||
import { Toggle, DropDown, Link, Section } from "./UiItem";
|
import { Toggle, DropDown, Link, Section, Text } from "./UiItem";
|
||||||
|
|
||||||
export type UiItemListProps = {
|
export type UiItemListProps = {
|
||||||
controls: Array<ControlUI>,
|
controls: Array<ControlUI>,
|
||||||
|
|
@ -78,6 +78,11 @@ export default class UiItemList extends React.Component<UiItemListProps> {
|
||||||
case "slider": {
|
case "slider": {
|
||||||
return this.renderSlider(control);
|
return this.renderSlider(control);
|
||||||
}
|
}
|
||||||
|
case "text": {
|
||||||
|
return <Text item={control}
|
||||||
|
state={this.props.state}
|
||||||
|
onChangeState={this.props.onChangeState} />;
|
||||||
|
}
|
||||||
default: {
|
default: {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Unknown UI type "${control.type}" for "${control.text}" component`
|
`Unknown UI type "${control.type}" for "${control.text}" component`
|
||||||
|
|
|
||||||
|
|
@ -50,12 +50,17 @@ declare type UILink = {
|
||||||
link: string
|
link: string
|
||||||
} & UIBase;
|
} & UIBase;
|
||||||
|
|
||||||
|
declare type UIText = {
|
||||||
|
type: "text"
|
||||||
|
} & UIBase;
|
||||||
|
|
||||||
declare type ControlUI =
|
declare type ControlUI =
|
||||||
UIToggle
|
UIToggle
|
||||||
| UIDropDown
|
| UIDropDown
|
||||||
| UISlider
|
| UISlider
|
||||||
| UISection
|
| UISection
|
||||||
| UILink
|
| UILink
|
||||||
|
| UIText
|
||||||
|
|
||||||
declare type Control = {
|
declare type Control = {
|
||||||
name: string,
|
name: string,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue