Add esper statistics

This commit is contained in:
uwap 2018-01-20 00:16:34 +01:00
parent 3ed861369e
commit 16d03ceacf
5 changed files with 209 additions and 136 deletions

View file

@ -3,27 +3,81 @@
export const rainbow = "rgba(200,120,120,0.5);"
+ "--before-background: linear-gradient(40deg, #FF0000 0%, #00FF00 50%, #0000FF 70%, #FFFF00 100%);";
export const esper_topics = (chip_id: string) => ({
[ `esper_${chip_id}_version` ]: {
export const esper_topics = (chip_id: string, name: string) => ({
[ `esper_${name}_version` ]: {
state: `/service/esper/${chip_id}/info`,
command: "",
defaultValue: "UNKNOWN",
values: {},
parseState: msg => JSON.parse(msg.toString()).version.esper
},
[ `esper_${name}_ip` ]: {
state: `/service/esper/${chip_id}/info`,
command: "",
defaultValue: "UNKNOWN",
values: {},
parseState: msg => JSON.parse(msg.toString()).network.ip
},
[ `esper_${name}_rssi` ]: {
state: `/service/esper/${chip_id}/info`,
command: "",
defaultValue: "UNKNOWN",
values: {},
parseState: msg => JSON.parse(msg.toString()).wifi.rssi
},
[ `esper_${name}_uptime` ]: {
state: `/service/esper/${chip_id}/info`,
command: "",
defaultValue: "UNKNOWN",
values: {},
parseState: msg => new Date(JSON.parse(msg.toString()).time.startup * 1000)
.toLocaleString()
},
[ `esper_${name}_device` ]: {
state: `/service/esper/${chip_id}/info`,
command: "",
defaultValue: "UNKNOWN",
values: {},
parseState: msg => JSON.parse(msg.toString()).device
}
});
export const esper_statistics = (chip_id: string,
export const esper_statistics = (name: string,
prev_ui: Array<ControlUI> = []) => (
prev_ui.concat([
{
type: "section",
text: "Funkdose"
},
{
type: "text",
text: "Device Variant",
icon: "chart-donut",
topic: `esper_${name}_device`
},
{
type: "text",
text: "Version",
topic: `esper_${chip_id}_version`
icon: "source-branch",
topic: `esper_${name}_version`
},
{
type: "text",
text: "IP",
icon: "access-point-network",
topic: `esper_${name}_ip`
},
{
type: "text",
text: "RSSI",
icon: "wifi",
topic: `esper_${name}_rssi`
},
{
type: "text",
text: "Running since…",
icon: "av-timer",
topic: `esper_${name}_uptime`
}
])
);