ctucx.git: mqtt-webui

webui for mqtt, can be used to control/display data in mqtt-topics

1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 
29 
30 
31 
32 
33 
34 
35 
36 
37 
38 
39 
40 
41 
42 
43 
44 
45 
46 
47 
48 
49 
50 
51 
52 
53 
54 
55 
56 
57 
58 
59 
60 
61 
62 
63 
64 
65 
66 
67 
68 
69 
70 
71 
72 
73 
74 
75 
76 
77 
78 
79 
80 
81 
82 
83 
84 
85 
86 
87 
88 
89 
90 
91 
92 
93 
94 
95 
96 
97 
98 
99 
100 
101 
102 
103 
104 
105 
106 
107 
108 
109 
110 
111 
112 
113 
114 
115 
116 
117 
118 
119 
120 
121 
122 
123 
124 
125 
126 
127 
128 
129 
130 
131 
132 
133 
134 
135 
136 
137 
138 
139 
140 
141 
142 
143 
144 
145 
146 
147 
148 
149 
150 
151 
152 
153 
154 
155 
156 
157 
158 
159 
160 
161 
162 
163 
164 
165 
166 
167 
168 
169 
170 
171 
172 
173 
174 
175 
176 
177 
178 
179 
180 
181 
182 
183 
{
  "appName": "Smart-Home",
  "disableAuth": false,
  "extraCSS": "./test.css",
  "pages": [
    {
      "icon": "favicon-512x512.png",
      "id": "mainpage",
      "sections": [
        {
          "items": [
            {
              "icon": "icons/electric_range.png",
              "link": "#page1",
              "title": "Click me!",
              "type": "text"
            }
          ],
          "title": "Sub-Pages"
        },
        {
          "items": [
            {
              "icon": "icons/power_button.png",
              "title": "Switch",
              "topic": {
                "get": "zigbee2mqtt/ikea_lamp_l",
                "set": "zigbee2mqtt/ikea_lamp_l/set"
              },
              "transform": {
                "get": "return (message.state == 'ON') ? true : false",
                "set": "return JSON.stringify({state: (input) ? 'ON' : 'OFF'})"
              },
              "type": "switch"
            },
            {
              "icon": "icons/bulb.png",
              "sliderMaxValue": 254,
              "sliderMinValue": 0,
              "sliderStepValue": 1,
              "title": "Slider",
              "topic": {
                "get": "zigbee2mqtt/ikea_lamp_l",
                "set": "zigbee2mqtt/ikea_lamp_l/set"
              },
              "transform": {
                "get": "return message.brightness",
                "set": "return JSON.stringify({brightness: Number(input)})"
              },
              "type": "slider"
            },
            {
              "icon": "icons/bulb.png",
              "sliderMaxValue": 254,
              "sliderMinValue": 0,
              "sliderStepValue": 1,
              "title": "Number",
              "topic": {
                "get": "zigbee2mqtt/ikea_lamp_l",
                "set": "zigbee2mqtt/ikea_lamp_l/set"
              },
              "transform": {
                "get": "return message.brightness",
                "set": "return JSON.stringify({brightness: Number(input)})"
              },
              "type": "number"
            },
            {
              "buttons": [
                {
                  "label": "On",
                  "value": "ON"
                },
                {
                  "label": "Off",
                  "value": "OFF"
                }
              ],
              "icon": "icons/bulb.png",
              "title": "Buttons",
              "topic": {
                "get": "zigbee2mqtt/ikea_lamp_l_rgb",
                "set": "zigbee2mqtt/ikea_lamp_l_rgb/set"
              },
              "transform": {
                "get": "return message.state;",
                "set": "return JSON.stringify({state: input});"
              },
              "type": "button"
            },
            {
              "icon": "icons/bulb.png",
              "selectOptions": [
                {
                  "label": "Red",
                  "value": "0.71,0.26"
                },
                {
                  "label": "Green",
                  "value": "0.19,0.78"
                },
                {
                  "label": "Blue",
                  "value": "0.09,0.13"
                }
              ],
              "title": "Select",
              "topic": {
                "get": "zigbee2mqtt/ikea_lamp_l_rgb",
                "set": "zigbee2mqtt/ikea_lamp_l_rgb/set"
              },
              "transform": {
                "get": "return message.color.x + ','+message.color.y",
                "set": "return JSON.stringify({color: {x: input.split(',')[0], y: input.split(',')[1]}})"
              },
              "type": "select"
            },
            {
              "icon": "icons/temperature.png",
              "title": "Text",
              "topic": "lacrosse2mqtt/5",
              "transform": "return Math.round((message.temperature + Number.EPSILON) * 100) / 100 + ' °C - ' + message.humidity + ' %'",
              "type": "text"
            },
            {
              "html": "this is html! <b>bold</b> <u>underline</u><h1>H1</h1>",
              "type": "html"
            }
          ],
          "title": "Available Elements:"
        }
      ],
      "title": "Some Title"
    },
    {
      "icon": "favicon-512x512.png",
      "id": "page1",
      "sections": [
        {
          "items": [
            {
              "icon": "icons/power.png",
              "title": "Voltage",
              "topic": "sdm2mqtt/leah",
              "transform": "return Math.round((message.voltage + Number.EPSILON) * 100) / 100 + ' V'",
              "type": "text"
            },
            {
              "icon": "icons/power.png",
              "title": "Power",
              "topic": "sdm2mqtt/leah",
              "transform": "return Math.round((message.power + Number.EPSILON) * 100) / 100 + ' W'",
              "type": "text"
            },
            {
              "icon": "icons/power.png",
              "title": "Frequency",
              "topic": "sdm2mqtt/leah",
              "transform": "return message.frequency + ' Hz'",
              "type": "text"
            },
            {
              "icon": "icons/power.png",
              "title": "cos φ",
              "topic": "sdm2mqtt/leah",
              "transform": "return Math.round((message.cosphi + Number.EPSILON) * 100) / 100",
              "type": "text"
            },
            {
              "icon": "icons/power.png",
              "title": "Total Import",
              "topic": "sdm2mqtt/leah",
              "transform": "return Math.round((message.import + Number.EPSILON) * 100) / 100 + ' kWh'",
              "type": "text"
            }
          ],
          "title": "Power-Meter"
        }
      ],
      "title": "I'm a sub-page!"
    }
  ]
}