Compare commits

..

90 commits

Author SHA1 Message Date
b1c59d866a Fix watch command not working 2022-11-23 12:07:32 +01:00
3528e8179d
Merge pull request #177 from Ranlvor/patch-41
Various uwap-home changes
2022-11-23 11:45:37 +01:00
a67aaade0a
Merge pull request #155 from uwap/dependabot/npm_and_yarn/lodash-4.17.21
Bump lodash from 4.17.20 to 4.17.21
2022-11-23 11:36:25 +01:00
dependabot[bot]
bb8f5be644
Bump lodash from 4.17.20 to 4.17.21
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.20 to 4.17.21.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.20...4.17.21)

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-23 10:32:54 +00:00
dd198d8aaa Update webpack and leaflet 2022-11-23 11:31:40 +01:00
60178de93b Update dependencies 2022-11-22 21:23:53 +01:00
e89fd10c23 Update to mui v5 2022-11-22 21:21:06 +01:00
6f3fb4dc0a Update dependencies 2022-11-22 20:13:13 +01:00
Ranlvor
8e002e3b1a
add button for wled office auto on/off 2022-11-15 17:56:52 +01:00
Ranlvor
58c9ae1125
remove debugstatement accidently left in 2022-10-29 13:15:58 +02:00
Ranlvor
c2ed2fd37a
add option to disable auto-reclose on blinds 2022-10-29 13:15:01 +02:00
Ranlvor
eb7d1f7c5d
Addjust blind icon threshold to maximum window-open-save extention 2022-09-06 00:16:39 +02:00
Ranlvor
b6c7ba89cb
show office blinds position in icon 2022-09-05 21:40:51 +02:00
Ranlvor
14d72d626c add office blinds 2022-08-20 12:50:05 +02:00
Ranlvor
d73ee95178
add fountain 2022-08-17 14:15:58 +02:00
Ranlvor
fa8d403076
two more boolean home-rust-settings 2022-04-22 13:14:22 +02:00
Ranlvor
38de936bdd
+soundbar 2022-04-21 21:06:49 +02:00
Ranlvor
060dfa61d8
add link to kodi webinterface 2022-01-28 23:34:50 +01:00
Ranlvor
ca2bef4248
office: +color_temp 2022-01-18 19:23:20 +01:00
Ranlvor
f2f5e3441b
add kittchen bulbs 2022-01-18 16:02:08 +01:00
Ranlvor
eab431f13b
show office led lwt
because it takes a few seconds to respond to a brightness request when current state ist standby, but it immediatly leaves standby giving feedback that something is happening
2022-01-15 14:37:46 +01:00
Ranlvor
53911db686
+wled office 2022-01-13 21:43:18 +01:00
Ranlvor
51d410fbd3
Webinterface Bulb Office 2021-12-21 19:26:02 +01:00
Ranlvor
4d39149e77
bulb_office is now rgb, too 2021-12-21 16:10:33 +01:00
Ranlvor
5b62bc9325
add wled strip 2021-12-11 23:13:58 +01:00
Ranlvor
9e8765711a
show mic state on lamp color, too 2021-12-11 12:15:14 +01:00
Ranlvor
cbc3084eff
show mic/webcam status 2021-12-11 12:10:37 +01:00
Ranlvor
9b0c554e54
allow all temperature warning levels to be set individually 2021-12-11 12:00:17 +01:00
Ranlvor
4806973c0a
changes 2021-10-04 22:51:49 +02:00
Ranlvor
167d58d670
uwap-home: add printer 2021-05-20 20:49:54 +02:00
Ranlvor
b4b85fdb17
uwap-home: add toggle for projector auto off 2021-05-13 18:44:09 +02:00
Ranlvor
8c91dee9b8
uwap-home: add projector 2021-05-12 21:26:29 +02:00
Ranlvor
db62d59f67
uwap-home, NAS: revert to LWL based nas-online-check
Because the network topology changed and now the nas is on an non-MQTT-switchport
2021-04-29 20:05:40 +02:00
Ranlvor
3208de65d4
Add snapcast and tvheadend webinterfaces 2021-04-29 20:04:31 +02:00
Ranlvor
bb334ca7bc
uwap-home: Add UI for new Livingroom/Diningroom-Heating-Controller 2021-03-20 13:07:52 +01:00
Ranlvor
fa07cdc784
Switch an die neue stelle gepackt 2021-03-20 12:59:44 +01:00
Ranlvor
9d44540ebc
uwap-home: move nas to new location and make it behave more like tucana for faster feedback 2021-02-20 17:04:22 +01:00
Ranlvor
e6b26dbac1
Add switch for office_heating/self_control
This switch decides if the control algorithm for the office temperature runs inside of home-rust or in the heating valve itself. Former guarentees 100% open/close to avoid noise, later is way better (states like partial open, lower latency, lower temperature-shootovers and shootunders, etc, etc)
2021-01-14 20:36:16 +01:00
Ranlvor
27a9544092
uwap-home, heating: support temperature offsets 2020-12-23 13:08:56 +01:00
Ranlvor
6b78cc0a2f
uwap-home: Allow manual control of office heater 2020-12-23 10:08:33 +01:00
Ranlvor
6e63404724
bugfix for boostactiveendtime 2020-12-19 16:37:16 +01:00
Ranlvor
6028302a64
refactoring to give bedroom the new diningroom-controls 2020-12-19 16:33:33 +01:00
Ranlvor
a6aef2ee9a
uwap-home, heater diningroom: show boost/window open state 2020-12-19 16:19:42 +01:00
Ranlvor
01ed36e5be
uwap-home: Display current kitchen temperature
Because we are subscribed to that topic anyway
2020-12-07 20:25:00 +01:00
Ranlvor
a25d7cc01d
uwap-home: Add kittchen temperature warning 2020-12-07 20:20:21 +01:00
Ranlvor
57655b0f66
uwap-home: nicer topic order 2020-12-07 20:03:01 +01:00
Ranlvor
b7b0bd7cac
uwap-home, lights livingroom: add new winter mode 2020-12-07 19:58:23 +01:00
Ranlvor
6c80eb2bd4
uwap-home: Add new light in the office 2020-12-07 19:57:52 +01:00
Ranlvor
9a070dcc2b
summeractive is now a JSON-Value instead of a dedicated topic 2020-11-16 10:04:37 +01:00
Ranlvor
424aef1991
Properly include Buffer to fix linter errors
Thank you for the line, @uwap.
2020-11-15 03:58:38 +01:00
Ranlvor
e3eb924f1f
Formating for the linter 2020-11-15 03:30:51 +01:00
Ranlvor
9e388f4ae9
+Heating Bedroom 2020-11-15 03:27:03 +01:00
Ranlvor
dc2728b59a
uglify the code for the linter 2020-11-10 23:45:09 +01:00
Ranlvor
94aafdfbdd
Use the wrong type (String instead of Number) to make Flow happy 2020-11-10 23:34:09 +01:00
Ranlvor
ee4800d087
Add heater diningroom 2020-11-10 23:21:22 +01:00
Ranlvor
b898455f56
Pat the linter 2020-11-08 14:47:21 +01:00
Ranlvor
4e316f9e47
rework Lüftung/Heizung Büro 2020-11-08 14:42:17 +01:00
Ranlvor
fdb49f79a5
uwap-home: Add heating controls office 2020-11-06 19:36:51 +01:00
Ranlvor
39c364c742
use new mark feature to clean up fan settings 2020-10-19 18:35:51 +02:00
Ranlvor
c298a58a47
Merge remote-tracking branch 'origin/master' into fork/patch-41 2020-10-19 18:29:53 +02:00
0a0639e994 Update dependencies 2020-10-19 07:40:14 +02:00
d9096b13e4 Various small changes 2020-10-19 07:12:38 +02:00
a44eea520a Better sliders!
Add marks and value indication. (Fixes #146)
2020-10-19 06:24:04 +02:00
0f08e9f1ee Minor home-map changes 2020-10-19 05:49:35 +02:00
ccd9bcd3b5 Types are now bidirectional
It is still possible to define types as functions (Buffer => string for 
state topics, string => Buffer for command topics). Otherwise types have 
from and to properties.
(Fixes #101)
2020-10-19 05:45:09 +02:00
Ranlvor
550e0c7479
Fix spelling error the linter tempted me to do 2020-10-17 19:06:49 +02:00
Ranlvor
3fd432b2d2
Make the linter happy 2020-10-17 16:50:21 +02:00
Ranlvor
263507871b
Change some default values to home-rust compile-time-defaults
Because after losing MQTT-Broker-State and restarting home-rust it
reverts to compile-time-defaults but does not write this defaults
back to the MQTT-Broker. So the map should just assume that any
parameter not received via MQTT should be set to the compile-time-values.
2020-10-17 16:48:07 +02:00
Ranlvor
65452ac0cb
Add Light Diningroom 2020-10-17 16:28:15 +02:00
Ranlvor
d50ea6fd49
fix linting error 2020-10-17 16:23:22 +02:00
Ranlvor
53d547bc65
Merge remote-tracking branch 'origin/master' into fork/patch-41
Convert to new icon format.
2020-10-17 16:23:01 +02:00
2997ff8862 Various improvements 2020-10-08 20:31:42 +02:00
e43842fbed Link to the wiki 2020-10-08 18:05:40 +02:00
1c1de6356c Define icon transformations on withState
(Closes #148)
2020-10-08 17:40:42 +02:00
9a5557db03 Fix sidebar close icon not being visible
(Closes #147)
2020-10-08 17:24:51 +02:00
8376f404e4 Fix eslint errors 2020-10-08 08:46:06 +02:00
856aab41ad Improve the entire icon logic
- Tree Shaking for Icons (Closes #53)
- New API for the config (See 
https://github.com/uwap/mqtt-control-map/wiki/Icons)
- Icons can now be colored everywhere, not just on the map
2020-10-08 08:36:56 +02:00
43a33c3ab3 Fix minor eslint warnings 2020-10-05 22:02:30 +02:00
Ranlvor
5bae8025bd
Add LEDs Livingroom 2020-10-05 02:25:59 +02:00
Ranlvor
d338093eee
Fix icon raspberry-pi 2020-10-05 00:50:33 +02:00
8917402888 Fix whirlpool type comparison 2020-10-04 19:00:52 +02:00
af89238999 Greenkeeper is deprecated 2020-10-04 18:56:00 +02:00
Ranlvor
42e7697bf8
Add basic controls of the Vorstandswhirlpool (#104) 2020-10-04 18:54:29 +02:00
Ranlvor
66ff91da2d
uwap-home: Add second hallway light (#135)
* uwap-home: Add second hallway light

* show bulb on/off state on map icon

* Add icon for nas

* Use new zigbee2mqtt state-topics

The new state-topics-feature of zigbee2mqtt makes the translation-layer
in home-rust obsolete for simple (non color-changing) bulbs.

* uwap-home: Show tucana, Show Lüften Erinnerung

* Refactor topics: more template-functions, less spaghetti code

* uwap-home: Add office switch

* tucana: Support displaying half duplex, too

* Increase target temperature slider range

After a hot summer it can be usefull to be able to set the slider to e.G. 25°C
2020-10-04 18:52:37 +02:00
d39e547623 Fix svg import & update dependencies
(Fixes #132)
2020-10-04 18:46:37 +02:00
greenkeeper[bot]
2e1d9d83c8 Update file-loader to the latest version 🚀 (#131)
* chore(package): update file-loader to version 5.0.0

* chore(package): update lockfile yarn.lock
2019-12-09 08:24:05 +01:00
greenkeeper[bot]
9af88a02a4 Update @mdi/font to the latest version 🚀 (#123)
* fix(package): update @mdi/font to version 4.0.96

* chore(package): update lockfile

https://npm.im/greenkeeper-lockfile
2019-12-09 08:23:49 +01:00
Ranlvor
195728631a uwap-home-stuff (#127)
* Move Icons to match new background

* Use step 0.1 for temperatures

Because I want to set the target to 21.5 (which is the max of the slider anyway)

* Add officeLight
2019-12-09 08:23:33 +01:00
Ranlvor
890960fe23 RZL: Update onkyo station list (#130) 2019-11-24 13:40:24 +01:00
Ranlvor
15cf79f547 RZL: +Licht Dunstabzugshaube (#129) 2019-11-12 23:07:12 +01:00
37 changed files with 6381 additions and 6024 deletions

View file

@ -1,7 +1,10 @@
{ {
"presets": [ "presets": [
["@babel/preset-env", { ["@babel/preset-env", {
modules: false modules: false,
corejs: "3.6",
useBuiltIns: "entry",
targets: "last 3 years"
}], }],
"@babel/preset-react", "@babel/preset-react",
"@babel/preset-flow" "@babel/preset-flow"

View file

@ -7,7 +7,8 @@ module.exports = {
"extends": [ "extends": [
"eslint:recommended", "eslint:recommended",
"plugin:flowtype/recommended", "plugin:flowtype/recommended",
"plugin:react/recommended" "plugin:react/recommended",
"plugin:react-hooks/recommended"
], ],
"parserOptions": { "parserOptions": {
"ecmaFeatures": { "ecmaFeatures": {

View file

@ -10,9 +10,8 @@ types/types.js
types/mqtt.js types/mqtt.js
[options] [options]
esproposal.export_star_as=enable
module.system.node.resolve_dirname=node_modules module.system.node.resolve_dirname=node_modules
module.system.node.resolve_dirname=./src module.system.node.resolve_dirname=src
[lints] [lints]
all=warn all=warn

View file

@ -4,10 +4,6 @@ node_js:
script: script:
- yarn travis - yarn travis
before_install: yarn global add greenkeeper-lockfile@1
before_script: greenkeeper-lockfile-update
after_script: greenkeeper-lockfile-upload
after_success: after_success:
- ./travis-upload-artifacts.sh - ./travis-upload-artifacts.sh

View file

@ -1,7 +1,6 @@
# MQTT Control Map # MQTT Control Map
[![Build Status](https://travis-ci.org/uwap/mqtt-control-map.svg?branch=master)](https://travis-ci.org/uwap/mqtt-control-map) [![Build Status](https://travis-ci.org/uwap/mqtt-control-map.svg?branch=master)](https://travis-ci.org/uwap/mqtt-control-map)
[![Greenkeeper badge](https://badges.greenkeeper.io/uwap/mqtt-control-map.svg)](https://greenkeeper.io/)
## Development / Configuration ## Development / Configuration
@ -12,33 +11,6 @@ your the mqtt control map for the given CONFIG everytime something changes.
for the given config. for the given config.
4. run `yarn build CONFIG` to generate all files for production use. 4. run `yarn build CONFIG` to generate all files for production use.
## Config ## Documentation
See `config/`. The documentation can be found in our [mqtt-control-map wiki](https://github.com/uwap/mqtt-control-map/wiki).
The Config format consists out of two sections. Topics and Controls.
### Topics
The topics section defines the mqtt interfaces.
### Controls
The Controls define the UI Controls.
| Name | Type | Optional? | Default | Description |
|-----------------|-------------------|------------|-----------------|-------------|
| type | "toggle" \| "dropDown" \| "slider" | No | | The type of the UI element. |
| text | string | No | | The text displayed right next to the UI element. |
| topic | string | No | | The topic the UI element is supposed to change and/or receive its status from. |
| enableCondition | (key: string, value: *) => boolean | Yes | () => true | This option allows you to enable or disable UI elements, depending on the current state. The first parameter is the internal representation of the value. For example "off". The second parameter is the actual value that was received via MQTT. Return true to enable the element and false to disable it. |
| **Toggle Options** |
| on | string | Yes | "on" | If the state is equal to the value of this option the toggle will be toggled on (if the toggled function is not overriden). This is also the value that will be sent when the button is toggled on. |
| off | string | Yes | "off" | If the state is equal to the value of this option the toggle will be toggled off (if the toggled function is not overriden). This is also the value that will be sent when the button is toggled off. |
| toggled | (key: string, value: *) => boolean | Yes | Use the on and off options | This is the function that decides whether the button should be in a toggled state or not. The parameters are equivalent to those of `enableCondition`. Return true to set the button to a toggled state. Return false to set it to the untoggled state. |
| **DropDown Options** |
| options | Map<string,string>| Yes | {} | This is an attribute set that will map all values defined in the topics section to a description text. For example `{ on: "Lights On", off: "Lights Off" }` will give the drop down element two options, one that is named `Lights On` and one that is named `Lights Off`. |
| **Slider Options** |
| min | number | Yes | 0 | The minimum value of that slider. |
| max | number | Yes | 1 | The maximum value of that slider. |
| step | number | Yes | 1 | The smallest step of the slider. |

View file

@ -1,8 +1,8 @@
// @flow // @flow
import type { Config } from "config/flowtypes"; import type { Config } from "config/flowtypes";
import { hex } from "config/colors";
import * as types from "config/types"; import * as types from "config/types";
import { mdi } from "config/icon"; import * as icons from "@mdi/js";
import { svg } from "config/icon";
const config: Config = { const config: Config = {
space: { space: {
@ -32,20 +32,19 @@ const config: Config = {
hauptraumTableLight: { hauptraumTableLight: {
name: "Hauptraum Tisch", name: "Hauptraum Tisch",
position: [450, 450], position: [450, 450],
icon: mdi("white-balance-iridescent"), icon: svg(icons.mdiWhiteBalanceIridescent),
iconColor: () => hex("#000000"),
ui: [ ui: [
{ {
type: "toggle", type: "toggle",
text: "Licht", text: "Licht",
topic: "hauptraumTableLight", topic: "hauptraumTableLight",
icon: mdi("power") icon: svg(icons.mdiPower)
}, },
{ {
type: "toggle", type: "toggle",
text: "Licht", text: "Licht",
topic: "hauptraumTableLightOnHack", topic: "hauptraumTableLightOnHack",
icon: mdi("power") icon: svg(icons.mdiPower)
} }
] ]
} }

View file

@ -2,8 +2,9 @@
import type { Config } from "config/flowtypes"; import type { Config } from "config/flowtypes";
import * as types from "config/types"; import * as types from "config/types";
import { hex, rainbow } from "config/colors"; import { hex, rainbow } from "config/colors";
import { mdi, rawMdi } from "config/icon"; import { svg, withState } from "config/icon";
import { esper, tasmota } from "./utils"; import { esper, tasmota } from "./utils";
import * as icons from "@mdi/js";
import * as onkyo from "./onkyo"; import * as onkyo from "./onkyo";
import * as olymp from "./olymp"; import * as olymp from "./olymp";
@ -225,6 +226,35 @@ const config: Config = {
type: types.option({ on: "ON", off: "OFF" }) type: types.option({ on: "ON", off: "OFF" })
}, },
defaultValue: "off" defaultValue: "off"
},
whirlpoolTemperatureSetpoint: {
state: {
name: "/service/whirlpool/state",
type: types.json("temperatureSetpointC")
},
command: {
name: "/service/whirlpool/set/temperature",
type: types.string
},
defaultValue: "0"
},
whirlpoolBubbles: {
state: {
name: "/service/whirlpool/state",
type: types.json("bubbles")
},
command: {
name: "/service/whirlpool/set/bubbles",
type: types.string
},
defaultValue: "0"
},
whirlpoolTemperature: {
state: {
name: "/service/whirlpool/state",
type: types.json("waterTemperatureC")
},
defaultValue: "0"
} }
}, },
//Tasmota-Dosen //Tasmota-Dosen
@ -246,29 +276,28 @@ const config: Config = {
ledStahltrager: { ledStahltrager: {
name: "LED Stahlträger", name: "LED Stahlträger",
position: [340, 590], position: [340, 590],
icon: mdi("white-balance-iridescent"), icon: svg(icons.mdiWhiteBalanceIridescent).color(({ledStahltraeger}) =>
iconColor: ({ledStahltraeger}) => (ledStahltraeger === "on" ? rainbow : hex("#000000"))),
(ledStahltraeger === "on" ? rainbow : hex("#000000")),
ui: [ ui: [
{ {
type: "toggle", type: "toggle",
text: "Stahlträger LED", text: "Stahlträger LED",
topic: "ledStahltraeger", topic: "ledStahltraeger",
icon: mdi("power") icon: svg(icons.mdiPower)
} }
] ]
}, },
snackbar: { snackbar: {
name: "Snackbar", name: "Snackbar",
position: [510, 500], position: [510, 500],
icon: mdi("fridge"), icon: svg(icons.mdiFridge).color(
iconColor: tasmota.iconColor("snackbar", hex("#E20074")), tasmota.iconColor("snackbar", hex("#E20074"))),
ui: [ ui: [
{ {
type: "toggle", type: "toggle",
text: "Snackbar", text: "Snackbar",
topic: "snackbar", topic: "snackbar",
icon: mdi("power") icon: svg(icons.mdiPower)
}, },
{ {
type: "section", type: "section",
@ -278,7 +307,7 @@ const config: Config = {
type: "text", type: "text",
text: "LED-Streifen", text: "LED-Streifen",
topic: "snackbarLedOnline", topic: "snackbarLedOnline",
icon: mdi("white-balance-iridescent") icon: svg(icons.mdiWhiteBalanceIridescent)
}, },
{ {
type: "dropDown", type: "dropDown",
@ -297,7 +326,7 @@ const config: Config = {
"11": "Rainbow Pattern", "11": "Rainbow Pattern",
"12": "Fire Pattern" "12": "Fire Pattern"
}, },
icon: mdi("settings"), icon: svg(icons.mdiCog),
enableCondition: ({ snackbarLedOnline }) => snackbarLedOnline === "on" enableCondition: ({ snackbarLedOnline }) => snackbarLedOnline === "on"
}, },
{ {
@ -306,7 +335,7 @@ const config: Config = {
topic: "snackbarDimmmer", topic: "snackbarDimmmer",
min: 0, min: 0,
max: 100, max: 100,
icon: mdi("brightness-7"), icon: svg(icons.mdiBrightness7),
enableCondition: ({ snackbarLedOnline }) => snackbarLedOnline === "on" enableCondition: ({ snackbarLedOnline }) => snackbarLedOnline === "on"
}, },
{ {
@ -315,7 +344,7 @@ const config: Config = {
topic: "snackbarSpeed", topic: "snackbarSpeed",
min: 0, min: 0,
max: 20, max: 20,
icon: mdi("speedometer"), icon: svg(icons.mdiSpeedometer),
enableCondition: ({ snackbarLedOnline }) => snackbarLedOnline === "on" enableCondition: ({ snackbarLedOnline }) => snackbarLedOnline === "on"
} }
] ]
@ -323,155 +352,151 @@ const config: Config = {
twinkle: { twinkle: {
name: "Twinkle", name: "Twinkle",
position: [530, 560], position: [530, 560],
icon: ({twinkle}) => icon: withState(({twinkle}) =>
(twinkle === "on" ? rawMdi("led-on flip-v") : rawMdi("led-off flip-v")), (twinkle === "on" ? svg(icons.mdiLedOn).flipV().color(rainbow)
iconColor: ({twinkle}) => (twinkle === "on" ? rainbow : hex("#000000")), : svg(icons.mdiLedOff).flipV())
),
ui: [ ui: [
{ {
type: "toggle", type: "toggle",
text: "Twinkle", text: "Twinkle",
topic: "twinkle", topic: "twinkle",
icon: mdi("power") icon: svg(icons.mdiPower)
} }
] ]
}, },
fan: { fan: {
name: "Ventilator", name: "Ventilator",
position: [530, 440], position: [530, 440],
icon: mdi("fan"), icon: svg(icons.mdiFan).color(({fan}) =>
iconColor: ({fan}) => (fan === "on" ? hex("#00FF00") : hex("#000000")), (fan === "on" ? hex("#00FF00") : hex("#000000"))),
ui: [ ui: [
{ {
type: "toggle", type: "toggle",
text: "Ventilator", text: "Ventilator",
topic: "fan", topic: "fan",
icon: mdi("power") icon: svg(icons.mdiPower)
} }
] ]
}, },
cashdesk: { cashdesk: {
name: "Cashdesk", name: "Cashdesk",
position: [510, 467], position: [510, 467],
icon: mdi("coin"), icon: svg(icons.mdiCurrencyUsdCircle),
ui: [ ui: [
{ {
type: "link", type: "link",
link: "http://cashdesk.rzl:8000/", link: "http://cashdesk.rzl:8000/",
text: "Open Cashdesk", text: "Open Cashdesk",
icon: mdi("open-in-new") icon: svg(icons.mdiOpenInNew)
} }
] ]
}, },
flyfry: { flyfry: {
name: "Fliegenbratgerät", name: "Fliegenbratgerät",
position: [450, 570], position: [450, 570],
icon: mdi("fire"), icon: svg(icons.mdiFire).color(({flyfry}) =>
iconColor: ({flyfry}) => (flyfry === "on" ? hex("#6666FF") : hex("#000000"))),
(flyfry === "on" ? hex("#6666FF") : hex("#000000")),
ui: esper.statistics("flyfry", [ ui: esper.statistics("flyfry", [
{ {
type: "toggle", type: "toggle",
text: "Fliegenbratgerät", text: "Fliegenbratgerät",
topic: "flyfry", topic: "flyfry",
icon: mdi("power") icon: svg(icons.mdiPower)
} }
]) ])
}, },
projector: { projector: {
name: "Beamer", name: "Beamer",
position: [380, 590], position: [380, 590],
icon: mdi("projector flip-v"), icon: svg(icons.mdiProjector).flipV().color(({projector}) =>
iconColor: ({projector}) =>
({ ({
transientOn: hex("#b3b300"), transientOn: hex("#b3b300"),
transientOff: hex("#b3b300"), transientOff: hex("#b3b300"),
on: hex("#00ff00"), on: hex("#00ff00"),
off: hex("#000000"), off: hex("#000000"),
unknown: hex("#888888") unknown: hex("#888888")
})[projector], })[projector]),
ui: [ ui: [
{ {
type: "toggle", type: "toggle",
text: "Beamer", text: "Beamer",
topic: "projector", topic: "projector",
toggled: (val) => val === "transientOn" || val === "on", toggled: (val) => val === "transientOn" || val === "on",
icon: mdi("power") icon: svg(icons.mdiPower)
} }
] ]
}, },
loetarbeitsplatz4: { loetarbeitsplatz4: {
name: "Lötarbeitsplatz", name: "Lötarbeitsplatz",
position: [205, 455], position: [205, 455],
icon: mdi("eyedropper-variant"), icon: svg(icons.mdiEyedropperVariant).color(({loetarbeitsplatz4}) =>
iconColor: ({loetarbeitsplatz4}) => (loetarbeitsplatz4 === "on" ? hex("#FF0000") : hex("#000000"))),
(loetarbeitsplatz4 === "on" ? hex("#FF0000") : hex("#000000")),
ui: [ ui: [
{ {
type: "text", type: "text",
text: "Status", text: "Status",
topic: "loetarbeitsplatz4", topic: "loetarbeitsplatz4",
icon: mdi("eyedropper-variant") icon: svg(icons.mdiEyedropperVariant)
} }
] ]
}, },
loetarbeitsplatz5: { loetarbeitsplatz5: {
name: "Lötarbeitsplatz", name: "Lötarbeitsplatz",
position: [205, 405], position: [205, 405],
icon: mdi("eyedropper-variant"), icon: svg(icons.mdiEyedropperVariant).color(({loetarbeitsplatz4}) =>
iconColor: ({loetarbeitsplatz5}) => (loetarbeitsplatz4 === "on" ? hex("#FF0000") : hex("#000000"))),
(loetarbeitsplatz5 === "on" ? hex("#FF0000") : hex("#000000")),
ui: [ ui: [
{ {
type: "text", type: "text",
text: "Status", text: "Status",
topic: "loetarbeitsplatz5", topic: "loetarbeitsplatz5",
icon: mdi("eyedropper-variant") icon: svg(icons.mdiEyedropperVariant)
} }
] ]
}, },
door: { door: {
name: "Tür", name: "Tür",
position: [455, 350], position: [455, 350],
icon: mdi("swap-vertical"), icon: svg(icons.mdiSwapVertical).color(({doorStatus}) =>
iconColor: ({doorStatus}) => (doorStatus === "on" ? hex("#00FF00") : hex("#FF0000"))),
(doorStatus === "on" ? hex("#00FF00") : hex("#FF0000")),
ui: [ ui: [
{ {
type: "link", type: "link",
link: "http://s.rzl.so", link: "http://s.rzl.so",
text: "Open Status Page", text: "Open Status Page",
icon: mdi("open-in-new") icon: svg(icons.mdiOpenInNew)
}, },
{ {
type: "link", type: "link",
// eslint-disable-next-line max-len // eslint-disable-next-line max-len
link: "http://kunterbunt.vm.rzl/dashboard/db/allgemeines-copy-ranlvor?orgId=1", link: "http://kunterbunt.vm.rzl/dashboard/db/allgemeines-copy-ranlvor?orgId=1",
text: "RZL-Dashboard", text: "RZL-Dashboard",
icon: mdi("open-in-new") icon: svg(icons.mdiOpenInNew)
}, },
{ {
type: "text", type: "text",
text: "Anwesend", text: "Anwesend",
topic: "presenceStatus", topic: "presenceStatus",
icon: mdi("account") icon: svg(icons.mdiAccount)
}, },
{ {
type: "text", type: "text",
text: "Devices", text: "Devices",
topic: "devicesStatus", topic: "devicesStatus",
icon: mdi("wifi") icon: svg(icons.mdiWifi)
}, },
{ {
type: "toggle", type: "toggle",
text: "Deko", text: "Deko",
topic: "deko", topic: "deko",
icon: mdi("invert-colors") icon: svg(icons.mdiInvertColors)
}, },
{ {
type: "text", type: "text",
text: "Power Hauptraum", text: "Power Hauptraum",
topic: "powerConsumption", topic: "powerConsumption",
icon: mdi("speedometer") icon: svg(icons.mdiSpeedometer)
} }
] ]
@ -479,56 +504,56 @@ const config: Config = {
infoscreen: { infoscreen: {
name: "Infoscreen", name: "Infoscreen",
position: [255, 495], position: [255, 495],
icon: mdi("television-guide flip-v"), icon: svg(icons.mdiTelevisionGuide).flipV().color(
iconColor: tasmota.iconColor("infoscreen", hex("#4444FF")), tasmota.iconColor("infoscreen", hex("#4444FF"))
),
ui: [ ui: [
{ {
type: "toggle", type: "toggle",
text: "Infoscreen", text: "Infoscreen",
topic: "infoscreen", topic: "infoscreen",
icon: mdi("power") icon: svg(icons.mdiPower)
}, },
{ {
type: "link", type: "link",
link: "http://cashdesk.rzl:3030/rzl", link: "http://cashdesk.rzl:3030/rzl",
text: "Open Infoscreen", text: "Open Infoscreen",
icon: mdi("open-in-new") icon: svg(icons.mdiOpenInNew)
} }
] ]
}, },
pilze: { pilze: {
name: "Pilze", name: "Pilze",
position: [48, 499], position: [48, 499],
icon: ({pilze}) => icon: withState(({pilze}) =>
(pilze === "on" ? rawMdi("led-on") : rawMdi("led-off")), (pilze === "on" ? svg(icons.mdiLedOn) : svg(icons.mdiLedOff))).color(
iconColor: tasmota.iconColor("pilze", rainbow), tasmota.iconColor("pilze", rainbow)),
ui: [ ui: [
{ {
type: "toggle", type: "toggle",
text: "Pilze", text: "Pilze",
topic: "pilze", topic: "pilze",
icon: mdi("power") icon: svg(icons.mdiPower)
} }
] ]
}, },
printer3D: { printer3D: {
name: "Ultimaker 3", name: "Ultimaker 3",
position: [754, 560], position: [754, 560],
icon: mdi("printer-3d"), icon: svg(icons.mdiPrinter3d).color(({printer3DStatus}) =>
iconColor: ({printer3DStatus}) =>
({ ({
awaitingInteraction: hex("#b3b300"), awaitingInteraction: hex("#b3b300"),
printing: hex("#00ff00"), printing: hex("#00ff00"),
idle: hex("#000000"), idle: hex("#000000"),
unavailable: hex("#888888"), unavailable: hex("#888888"),
error: hex("#ff0000") error: hex("#ff0000")
})[printer3DStatus], })[printer3DStatus]),
ui: [ ui: [
{ {
type: "link", type: "link",
link: "http://ultimaker.rzl/", link: "http://ultimaker.rzl/",
text: "Open Webinterface", text: "Open Webinterface",
icon: mdi("open-in-new") icon: svg(icons.mdiOpenInNew)
}, },
{ {
type: "section", type: "section",
@ -536,7 +561,7 @@ const config: Config = {
}, },
{ {
type: "progress", type: "progress",
icon: mdi("rotate-right"), icon: svg(icons.mdiRotateRight),
min: 0, min: 0,
max: 1, max: 1,
text: "Printing Progress", text: "Printing Progress",
@ -545,7 +570,7 @@ const config: Config = {
{ {
type: "text", type: "text",
text: "Time Left", text: "Time Left",
icon: mdi("clock"), icon: svg(icons.mdiClock),
topic: "printer3Dremaining" topic: "printer3Dremaining"
} }
] ]
@ -553,51 +578,87 @@ const config: Config = {
partkeepr: { partkeepr: {
name: "Partkeepr", name: "Partkeepr",
position: [48, 450], position: [48, 450],
icon: mdi("chip"), icon: svg(icons.mdiChip),
ui: [ ui: [
{ {
type: "link", type: "link",
link: "http://partkeepr.rzl/", link: "http://partkeepr.rzl/",
text: "Open Partkeepr", text: "Open Partkeepr",
icon: mdi("open-in-new") icon: svg(icons.mdiOpenInNew)
} }
] ]
}, },
printerAnnette: { printerAnnette: {
name: "Drucker", name: "Drucker",
position: [800, 350], position: [800, 350],
icon: mdi("printer"), icon: svg(icons.mdiPrinter).color(tasmota.iconColor("printerAnnette")),
iconColor: tasmota.iconColor("printerAnnette"),
ui: [ ui: [
{ {
type: "toggle", type: "toggle",
text: "Drucker", text: "Drucker",
topic: "printerAnnette", topic: "printerAnnette",
icon: mdi("power") icon: svg(icons.mdiPower)
}, },
{ {
type: "link", type: "link",
link: "http://annette.rzl/", link: "http://annette.rzl/",
text: "Open Annette", text: "Open Annette",
icon: mdi("open-in-new") icon: svg(icons.mdiOpenInNew)
} }
] ]
}, },
nebenraumPowerStatus: { nebenraumPowerStatus: {
name: "Strom Fablab", name: "Strom Fablab",
position: [613, 537], position: [613, 537],
icon: ({nebenraumPowerStatus}) => icon: withState(({nebenraumPowerStatus}) =>
(nebenraumPowerStatus === "on" ? rawMdi("flash") : rawMdi("flash-off")), (nebenraumPowerStatus === "on" ?
iconColor: ({nebenraumPowerStatus}) => svg(icons.mdiFlash).color(hex("#00FF00")) : svg(icons.mdiFlashOff))),
(nebenraumPowerStatus === "on" ? hex("#00ff00") : hex("#000000")),
ui: [ ui: [
{ {
type: "text", type: "text",
icon: mdi("power"), icon: svg(icons.mdiPower),
text: "Strom Fablab", text: "Strom Fablab",
topic: "nebenraumPowerStatus" topic: "nebenraumPowerStatus"
} }
] ]
},
whirlpool: {
name: "Vorstandswhirlpool",
position: [1413, 500],
icon: svg(icons.mdiPool).color(
({whirlpoolBubbles}) =>
(parseInt(whirlpoolBubbles, 10) > 0 ? hex("#00ff00")
: hex("#000000"))),
ui: [
{
type: "text",
icon: svg(icons.mdiOilTemperature),
text: "Temperatur",
topic: "whirlpoolTemperature"
},
{
type: "text",
icon: svg(icons.mdiOilTemperature),
text: "Temperatur Sollwert",
topic: "whirlpoolTemperatureSetpoint"
},
{
type: "slider",
min: 4,
max: 100,
text: "Temperatur Sollwert",
icon: svg(icons.mdiOilTemperature),
topic: "whirlpoolTemperatureSetpoint"
},
{
type: "slider",
min: 0,
max: 9,
text: "Bubbles",
icon: svg(icons.mdiChartBubble),
topic: "whirlpoolBubbles"
}
]
} }
}, },
layers: [ layers: [

View file

@ -1,9 +1,10 @@
// @flow // @flow
import type { Topics, Controls } from "config/flowtypes"; import type { Topics, Controls } from "config/flowtypes";
import { mdi, mdiBattery } from "config/icon"; import { svg, mdiBattery } from "config/icon";
import { hex } from "config/colors"; import { hex } from "config/colors";
import * as types from "config/types"; import * as types from "config/types";
import { floalt, tradfri } from "./utils"; import { floalt, tradfri, tasmota } from "./utils";
import * as icons from "@mdi/js";
export const topics: Topics = { export const topics: Topics = {
//Kuechen-Floalts //Kuechen-Floalts
@ -20,6 +21,8 @@ export const topics: Topics = {
...tradfri.remote.topics("65542"), ...tradfri.remote.topics("65542"),
...tradfri.remote.topics("65546"), ...tradfri.remote.topics("65546"),
...tasmota.topics("10", "lichtDunstabzug"),
kitchenLightColor: { kitchenLightColor: {
state: { state: {
name: "/service/openhab/out/kitchen_light_all_color_temperature" name: "/service/openhab/out/kitchen_light_all_color_temperature"
@ -63,7 +66,7 @@ export const controls: Controls = {
kitchenLight: { kitchenLight: {
name: "Deckenlicht Küche", name: "Deckenlicht Küche",
position: [325, 407], position: [325, 407],
icon: mdi("ceiling-light"), icon: svg(icons.mdiCeilingLight),
ui: [ ui: [
{ {
type: "toggle", type: "toggle",
@ -72,14 +75,14 @@ export const controls: Controls = {
toggled: (n) => parseInt(n, 10) > 0, toggled: (n) => parseInt(n, 10) > 0,
topic: "kitchenLightBrightness", topic: "kitchenLightBrightness",
text: "Ein/Ausschalten", text: "Ein/Ausschalten",
icon: mdi("power") icon: svg(icons.mdiPower)
}, },
{ {
type: "slider", type: "slider",
min: 0, min: 0,
max: 100, max: 100,
text: "Helligkeit", text: "Helligkeit",
icon: mdi("brightness-7"), icon: svg(icons.mdiBrightness7),
topic: "kitchenLightBrightness" topic: "kitchenLightBrightness"
}, },
{ {
@ -87,7 +90,7 @@ export const controls: Controls = {
min: 0, min: 0,
max: 100, max: 100,
text: "Farbtemperatur", text: "Farbtemperatur",
icon: mdi("weather-sunset-down"), icon: svg(icons.mdiWeatherSunsetDown),
topic: "kitchenLightColor" topic: "kitchenLightColor"
}, },
{ {
@ -99,7 +102,7 @@ export const controls: Controls = {
min: 0, min: 0,
max: 100, max: 100,
text: "Helligkeit", text: "Helligkeit",
icon: mdi("brightness-7"), icon: svg(icons.mdiBrightness7),
topic: floalt.brightness("65537") topic: floalt.brightness("65537")
}, },
{ {
@ -107,7 +110,7 @@ export const controls: Controls = {
min: 0, min: 0,
max: 100, max: 100,
text: "Farbtemperatur", text: "Farbtemperatur",
icon: mdi("weather-sunset-down"), icon: svg(icons.mdiWeatherSunsetDown),
topic: floalt.color("65537") topic: floalt.color("65537")
}, },
{ {
@ -119,7 +122,7 @@ export const controls: Controls = {
min: 0, min: 0,
max: 100, max: 100,
text: "Helligkeit", text: "Helligkeit",
icon: mdi("brightness-7"), icon: svg(icons.mdiBrightness7),
topic: floalt.brightness("65538") topic: floalt.brightness("65538")
}, },
{ {
@ -127,7 +130,7 @@ export const controls: Controls = {
min: 0, min: 0,
max: 100, max: 100,
text: "Farbtemperatur", text: "Farbtemperatur",
icon: mdi("weather-sunset-down"), icon: svg(icons.mdiWeatherSunsetDown),
topic: floalt.color("65538") topic: floalt.color("65538")
}, },
{ {
@ -139,7 +142,7 @@ export const controls: Controls = {
min: 0, min: 0,
max: 100, max: 100,
text: "Helligkeit", text: "Helligkeit",
icon: mdi("brightness-7"), icon: svg(icons.mdiBrightness7),
topic: floalt.brightness("65539") topic: floalt.brightness("65539")
}, },
{ {
@ -147,7 +150,7 @@ export const controls: Controls = {
min: 0, min: 0,
max: 100, max: 100,
text: "Farbtemperatur", text: "Farbtemperatur",
icon: mdi("weather-sunset-down"), icon: svg(icons.mdiWeatherSunsetDown),
topic: floalt.color("65539") topic: floalt.color("65539")
}, },
{ {
@ -159,7 +162,7 @@ export const controls: Controls = {
min: 0, min: 0,
max: 100, max: 100,
text: "Helligkeit", text: "Helligkeit",
icon: mdi("brightness-7"), icon: svg(icons.mdiBrightness7),
topic: floalt.brightness("65540") topic: floalt.brightness("65540")
}, },
{ {
@ -167,7 +170,7 @@ export const controls: Controls = {
min: 0, min: 0,
max: 100, max: 100,
text: "Farbtemperatur", text: "Farbtemperatur",
icon: mdi("weather-sunset-down"), icon: svg(icons.mdiWeatherSunsetDown),
topic: floalt.color("65540") topic: floalt.color("65540")
} }
] ]
@ -175,7 +178,7 @@ export const controls: Controls = {
kitchenSinkLight: { kitchenSinkLight: {
name: "Licht Spüle", name: "Licht Spüle",
position: [300, 345], position: [300, 345],
icon: mdi("wall-sconce-flat"), icon: svg(icons.mdiWallSconceFlat),
ui: [ ui: [
{ {
type: "toggle", type: "toggle",
@ -184,14 +187,14 @@ export const controls: Controls = {
toggled: (n) => parseInt(n, 10) > 0, toggled: (n) => parseInt(n, 10) > 0,
topic: "kitchenSinkLightBrightness", topic: "kitchenSinkLightBrightness",
text: "Ein/Ausschalten", text: "Ein/Ausschalten",
icon: mdi("power") icon: svg(icons.mdiPower)
}, },
{ {
type: "slider", type: "slider",
min: 0, min: 0,
max: 100, max: 100,
text: "Helligkeit", text: "Helligkeit",
icon: mdi("brightness-7"), icon: svg(icons.mdiBrightness7),
topic: "kitchenSinkLightBrightness" topic: "kitchenSinkLightBrightness"
} }
] ]
@ -199,7 +202,7 @@ export const controls: Controls = {
kitchenCounterLight: { kitchenCounterLight: {
name: "Deckenlicht Theke", name: "Deckenlicht Theke",
position: [400, 440], position: [400, 440],
icon: mdi("ceiling-light"), icon: svg(icons.mdiCeilingLight),
ui: [ ui: [
{ {
type: "section", type: "section",
@ -210,7 +213,7 @@ export const controls: Controls = {
min: 0, min: 0,
max: 100, max: 100,
text: "Helligkeit", text: "Helligkeit",
icon: mdi("brightness-7"), icon: svg(icons.mdiBrightness7),
topic: floalt.brightness("65544") topic: floalt.brightness("65544")
}, },
{ {
@ -218,7 +221,7 @@ export const controls: Controls = {
min: 0, min: 0,
max: 100, max: 100,
text: "Farbtemperatur", text: "Farbtemperatur",
icon: mdi("weather-sunset-down"), icon: svg(icons.mdiWeatherSunsetDown),
topic: floalt.color("65544") topic: floalt.color("65544")
}, },
{ {
@ -230,7 +233,7 @@ export const controls: Controls = {
min: 0, min: 0,
max: 100, max: 100,
text: "Helligkeit", text: "Helligkeit",
icon: mdi("brightness-7"), icon: svg(icons.mdiBrightness7),
topic: floalt.brightness("65543") topic: floalt.brightness("65543")
}, },
{ {
@ -238,15 +241,29 @@ export const controls: Controls = {
min: 0, min: 0,
max: 100, max: 100,
text: "Farbtemperatur", text: "Farbtemperatur",
icon: mdi("weather-sunset-down"), icon: svg(icons.mdiWeatherSunsetDown),
topic: floalt.color("65543") topic: floalt.color("65543")
} }
] ]
}, },
lichtDunstabzug: {
name: "Licht Dunstabzugshaube",
position: [252, 405],
icon: svg(icons.mdiCeilingLight),
iconColor: tasmota.iconColor("lichtDunstabzug"),
ui: [
{
type: "toggle",
text: "Licht Dunstabzugshaube",
topic: "lichtDunstabzug",
icon: svg(icons.mdiPower)
}
]
},
remotes: { remotes: {
name: "Fernbedinungen", name: "Fernbedinungen",
position: [400, 344], position: [400, 344],
icon: mdi("light-switch"), icon: svg(icons.mdiLightSwitch),
iconColor: (state) => //if any remote is low make icon red iconColor: (state) => //if any remote is low make icon red
(["65536", "65542", "65546", "65547"] (["65536", "65542", "65546", "65547"]
.some((x) => state[tradfri.remote.low(x)] === "true") .some((x) => state[tradfri.remote.low(x)] === "true")

View file

@ -1,11 +1,14 @@
// @flow // @flow
import type { Topics, Controls } from "config/flowtypes"; import type { Topics, Controls } from "config/flowtypes";
import { mdi } from "config/icon"; import { svg } from "config/icon";
import { hex, rainbow } from "config/colors"; import { hex, rainbow } from "config/colors";
import * as types from "config/types"; import * as types from "config/types";
import { tasmota, esper } from "./utils"; import { tasmota, esper } from "./utils";
import * as icons from "@mdi/js";
export const topics: Topics = { export const topics: Topics = {
...tasmota.topics("8", "ledOlymp"),
...esper.topics("afba45", "alarm"),
videogames: { videogames: {
state: { state: {
name: "/service/openhab/out/pca301_videogames/state", name: "/service/openhab/out/pca301_videogames/state",
@ -38,75 +41,70 @@ export const topics: Topics = {
type: types.option({ on: "ON", off: "OFF" }) type: types.option({ on: "ON", off: "OFF" })
}, },
defaultValue: "off" defaultValue: "off"
}, }
...tasmota.topics("8", "ledOlymp"),
...esper.topics("afba45", "alarm")
}; };
export const controls: Controls = { export const controls: Controls = {
ledOlymp: { ledOlymp: {
name: "LED Olymp", name: "LED Olymp",
position: [196, 154], position: [196, 154],
icon: mdi("white-balance-iridescent rotate-45"), icon: svg(icons.mdiWhiteBalanceIridescent).rotate(45).color(
iconColor: tasmota.iconColor("ledOlymp", rainbow), tasmota.iconColor("ledOlymp", rainbow)),
ui: [ ui: [
{ {
type: "toggle", type: "toggle",
text: "LED Olymp", text: "LED Olymp",
topic: "ledOlymp", topic: "ledOlymp",
icon: mdi("power") icon: svg(icons.mdiPower)
} }
] ]
}, },
videogames: { videogames: {
name: "Videospiele", name: "Videospiele",
position: [100, 100], position: [100, 100],
icon: mdi("gamepad-variant"), icon: svg(icons.mdiGamepadVariant).color(({videogames}) =>
iconColor: ({videogames}) => (videogames === "on" ? hex("#00FF00") : hex("#000000"))),
(videogames === "on" ? hex("#00FF00") : hex("#000000")),
ui: [ ui: [
{ {
type: "toggle", type: "toggle",
text: "Videospiele", text: "Videospiele",
topic: "videogames", topic: "videogames",
icon: mdi("power") icon: svg(icons.mdiPower)
} }
] ]
}, },
olympPC: { olympPC: {
name: "Rechner", name: "Rechner",
position: [297, 90], position: [297, 90],
icon: mdi("desktop-classic"), icon: svg(icons.mdiDesktopClassic).color(({olympPC}) =>
iconColor: ({olympPC}) => (olympPC === "on" ? hex("#00FF00") : hex("#000000"))),
(olympPC === "on" ? hex("#00FF00") : hex("#000000")),
ui: [ ui: [
{ {
type: "toggle", type: "toggle",
text: "Rechner", text: "Rechner",
topic: "olympPC", topic: "olympPC",
icon: mdi("power") icon: svg(icons.mdiPower)
} }
] ]
}, },
rundumleuchte: { rundumleuchte: {
name: "Rundumleuchte", name: "Rundumleuchte",
position: [310, 275], position: [310, 275],
icon: mdi("alarm-light"), icon: svg(icons.mdiAlarmLight).color(({rundumleuchte}) =>
iconColor: ({rundumleuchte}) => (rundumleuchte === "on" ? hex("#F0DF10") : hex("#000000"))),
(rundumleuchte === "on" ? hex("#F0DF10") : hex("#000000")),
ui: [ ui: [
{ {
type: "toggle", type: "toggle",
text: "Rundumleuchte", text: "Rundumleuchte",
topic: "rundumleuchte", topic: "rundumleuchte",
icon: mdi("power") icon: svg(icons.mdiPower)
} }
] ]
}, },
alarm: { alarm: {
name: "Alarm", name: "Alarm",
position: [340, 250], position: [340, 250],
icon: mdi("alarm-bell"), icon: svg(icons.mdiAlarmBell),
iconColor: () => hex("#000000"), iconColor: () => hex("#000000"),
ui: esper.statistics("alarm") ui: esper.statistics("alarm")
} }

View file

@ -1,8 +1,9 @@
// @flow // @flow
import type { Topics, Controls } from "config/flowtypes"; import type { Topics, Controls } from "config/flowtypes";
import { mdi } from "config/icon"; import { svg } from "config/icon";
import { hex } from "config/colors"; import { hex } from "config/colors";
import * as types from "config/types"; import * as types from "config/types";
import * as icons from "@mdi/js";
export const topics: Topics = { export const topics: Topics = {
onkyoConnection: { onkyoConnection: {
@ -94,6 +95,10 @@ export const topics: Topics = {
NPR08: "somafmLush", NPR08: "somafmLush",
NPR09: "somafmBeatblender", NPR09: "somafmBeatblender",
NPR0a: "ponyville", NPR0a: "ponyville",
NPR0b: "deutschlandradio",
NPR0c: "somafmSuburbsOfGoa",
NPR0d: "somafmSonicUniverse",
NPR0e: "somafmChrismasLounge",
otherwise: "unknown" otherwise: "unknown"
}) })
}, },
@ -110,6 +115,10 @@ export const topics: Topics = {
somafmLush: "NPR08", somafmLush: "NPR08",
somafmBeatblender: "NPR09", somafmBeatblender: "NPR09",
ponyville: "NPR0a", ponyville: "NPR0a",
deutschlandradio: "NPR0b",
somafmSuburbsOfGoa: "NPR0c",
somafmSonicUniverse: "NPR0d",
somafmChrismasLounge: "NPR0e",
otherwise: "NPR00" otherwise: "NPR00"
}) })
}, },
@ -124,12 +133,12 @@ export const controls: Controls = {
iconColor: ({onkyoConnection, onkyoPower}) => iconColor: ({onkyoConnection, onkyoPower}) =>
(onkyoConnection !== "connected" ? hex("#888888") : (onkyoConnection !== "connected" ? hex("#888888") :
(onkyoPower === "on" ? hex("#00FF00") : hex("#000000"))), (onkyoPower === "on" ? hex("#00FF00") : hex("#000000"))),
icon: mdi("audio-video"), icon: svg(icons.mdiAudioVideo),
ui: [ ui: [
{ {
type: "toggle", type: "toggle",
text: "Power", text: "Power",
icon: mdi("power"), icon: svg(icons.mdiPower),
topic: "onkyoPower", topic: "onkyoPower",
enableCondition: (state) => state.onkyoConnection === "connected" enableCondition: (state) => state.onkyoConnection === "connected"
}, },
@ -143,14 +152,14 @@ export const controls: Controls = {
topic: "onkyoVolume", topic: "onkyoVolume",
min: 0, min: 0,
max: 50, max: 50,
icon: mdi("volume-high"), icon: svg(icons.mdiVolumeHigh),
enableCondition: (state) => state.onkyoConnection === "connected" enableCondition: (state) => state.onkyoConnection === "connected"
}, },
{ {
type: "toggle", type: "toggle",
text: "Mute", text: "Mute",
topic: "onkyoMute", topic: "onkyoMute",
icon: mdi("volume-off"), icon: svg(icons.mdiVolumeOff),
enableCondition: (state) => state.onkyoConnection === "connected" enableCondition: (state) => state.onkyoConnection === "connected"
}, },
{ {
@ -168,7 +177,7 @@ export const controls: Controls = {
pult: "Pult", pult: "Pult",
front: "Front HDMI" front: "Front HDMI"
}, },
icon: mdi("usb"), icon: svg(icons.mdiUsb),
enableCondition: (state) => state.onkyoConnection === "connected" enableCondition: (state) => state.onkyoConnection === "connected"
}, },
{ {
@ -186,9 +195,13 @@ export const controls: Controls = {
somafmLush: "Lush (SomaFM)", somafmLush: "Lush (SomaFM)",
somafmBeatblender: "Beat Blender (Soma FM)", somafmBeatblender: "Beat Blender (Soma FM)",
ponyville: "Ponyville FM", ponyville: "Ponyville FM",
deutschlandradio: "Deutschlandradio",
somafmSuburbsOfGoa: "Suburbs of Goa (SomaFM)",
somafmSonicUniverse: "Sonic Universe (SomaFM)",
somafmChrismasLounge: "Christmas Lounge (SomaFM)",
unknown: "Unknown" unknown: "Unknown"
}, },
icon: mdi("radio"), icon: svg(icons.mdiRadio),
enableCondition: (state) => state.onkyoConnection === "connected" enableCondition: (state) => state.onkyoConnection === "connected"
&& state.onkyoInputs === "netzwerk" && state.onkyoInputs === "netzwerk"
}, },
@ -200,7 +213,7 @@ export const controls: Controls = {
type: "link", type: "link",
link: "http://mpd.rzl/mpd/player/index.php", link: "http://mpd.rzl/mpd/player/index.php",
text: "Open MPD Interface", text: "Open MPD Interface",
icon: mdi("open-in-new") icon: svg(icons.mdiOpenInNew)
} }
] ]
} }

View file

@ -1,11 +1,12 @@
// @flow // @flow
import type { ControlUI } from "config/flowtypes"; import type { ControlUI, Topics } from "config/flowtypes";
import { mdi } from "config/icon"; import { svg } from "config/icon";
import { hex } from "config/colors"; import { hex, type Color } from "config/colors";
import * as types from "config/types"; import * as types from "config/types";
import * as icons from "@mdi/js";
export const tasmota = { export const tasmota = {
topics: (id: string, name: string) => ({ topics: (id: string, name: string): Topics => ({
[name]: { [name]: {
state: { state: {
name: `stat/sonoff${id}/POWER`, name: `stat/sonoff${id}/POWER`,
@ -26,20 +27,20 @@ export const tasmota = {
defaultValue: "off" defaultValue: "off"
} }
}), }),
iconColor: (name: string, onColor: Color = hex("#00FF00")) => iconColor: (name: string, onCol: Color = hex("#00FF00")): (State => Color) =>
(state: State) => { (state: State): Color => {
if (state[`${name}_online`] === "off") { if (state[`${name}_online`] === "off") {
return hex("#888888"); return hex("#888888");
} else if (state[name] === "on") { } else if (state[name] === "on") {
return onColor; return onCol;
} }
return hex("#000000"); return hex("#000000");
} }
}; };
export const floalt = { export const floalt = {
color: (lightId: string) => `floalt_${lightId}_color`, color: (lightId: string): string => `floalt_${lightId}_color`,
brightness: (lightId: string) => `floalt_${lightId}_brightness`, brightness: (lightId: string): string => `floalt_${lightId}_brightness`,
topics: (lightId: string) => ({ topics: (lightId: string): Topics => ({
[`floalt_${lightId}_color`]: { [`floalt_${lightId}_color`]: {
state: { state: {
name: `/service/openhab/out/tradfri_0220_gwb8d7af2b448f_${lightId}` + name: `/service/openhab/out/tradfri_0220_gwb8d7af2b448f_${lightId}` +
@ -70,9 +71,9 @@ export const floalt = {
}; };
const tradfriRemote = { const tradfriRemote = {
level: (remoteId: string) => `tradfri_remote_${remoteId}_level`, level: (remoteId: string): string => `tradfri_remote_${remoteId}_level`,
low: (remoteId: string) => `tradfri_remote_${remoteId}_low`, low: (remoteId: string): string => `tradfri_remote_${remoteId}_low`,
topics: (remoteId: string) => ({ topics: (remoteId: string): Topics => ({
[`tradfri_remote_${remoteId}_level`]: { [`tradfri_remote_${remoteId}_level`]: {
state: { state: {
name: `/service/openhab/out/tradfri_0830_gwb8d7af2b448f_${remoteId}` + name: `/service/openhab/out/tradfri_0830_gwb8d7af2b448f_${remoteId}` +
@ -106,36 +107,36 @@ const esperStatistics = (name: string,
{ {
type: "text", type: "text",
text: "Device Variant", text: "Device Variant",
icon: mdi("chart-donut"), icon: svg(icons.mdiChartDonut),
topic: `esper_${name}_device` topic: `esper_${name}_device`
}, },
{ {
type: "text", type: "text",
text: "Version", text: "Version",
icon: mdi("source-branch"), icon: svg(icons.mdiSourceBranch),
topic: `esper_${name}_version` topic: `esper_${name}_version`
}, },
{ {
type: "text", type: "text",
text: "IP", text: "IP",
icon: mdi("access-point-network"), icon: svg(icons.mdiAccessPointNetwork),
topic: `esper_${name}_ip` topic: `esper_${name}_ip`
}, },
{ {
type: "text", type: "text",
text: "RSSI", text: "RSSI",
icon: mdi("wifi"), icon: svg(icons.mdiWifi),
topic: `esper_${name}_rssi` topic: `esper_${name}_rssi`
}, },
{ {
type: "text", type: "text",
text: "Running since…", text: "Running since…",
icon: mdi("av-timer"), icon: svg(icons.mdiAvTimer),
topic: `esper_${name}_uptime` topic: `esper_${name}_uptime`
} }
]) ])
); );
const esperTopics = (chipId: string, name: string) => ({ const esperTopics = (chipId: string, name: string): Topics => ({
[`esper_${name}_version`]: { [`esper_${name}_version`]: {
state: { state: {
name: `/service/esper/${chipId}/info`, name: `/service/esper/${chipId}/info`,

File diff suppressed because it is too large Load diff

View file

@ -2,7 +2,6 @@
<html> <html>
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.2.0/dist/leaflet.css" integrity="sha512-M2wvCLH6DSRazYeZRIm1JnYyh22purTM+FDB5CsyxtQJYeKq83arPe5wgbNmcFXGqiSH2XR8dT/fJISVA1r/zQ==" crossorigin=""/>
<title><%= htmlWebpackPlugin.options.title %></title> <title><%= htmlWebpackPlugin.options.title %></title>
</head> </head>
<body> <body>

View file

@ -1,10 +1,10 @@
{ {
"name": "mqtt-control-map", "name": "mqtt-control-map",
"version": "1.0.0", "version": "1.0.0",
"author": "uwap <me+mqttmap.package.json@uwap.name>", "author": "uwap <me@uwap.name>",
"description": "control devices via mqtt on a beautiful map of your space", "description": "Control Devices via mqtt, visualized on a Map",
"scripts": { "scripts": {
"build": "webpack --bail --config webpack.config.js -p --env", "build": "webpack --bail --config webpack.config.js --mode production --env",
"dev": "webpack --bail --config webpack.config.js --mode development --env", "dev": "webpack --bail --config webpack.config.js --mode development --env",
"watch": "webpack-dev-server --open --config webpack.config.js --mode development --env", "watch": "webpack-dev-server --open --config webpack.config.js --mode development --env",
"travis": "./travis.sh", "travis": "./travis.sh",
@ -12,45 +12,52 @@
"precommit": "yarn lint" "precommit": "yarn lint"
}, },
"dependencies": { "dependencies": {
"@material-ui/core": "^3.0.1", "@emotion/react": "^11.10.5",
"@material-ui/lab": "^3.0.0-alpha.16", "@emotion/styled": "^11.10.5",
"@mdi/font": "^3.8.95", "@fontsource/roboto": "^4.5.8",
"@mdi/react": "^1.4.0",
"@mui/material": "^5.10.15",
"@mui/styles": "^5.10.15",
"leaflet": "^1.5.1", "leaflet": "^1.5.1",
"lodash-es": "^4.17.15", "mqtt": "^4.2.1",
"mqtt": "^3.0.0", "react": "^18.2.0",
"react": "^16.8.6", "react-dom": "^18.2.0",
"react-dom": "^16.8.6", "react-leaflet": "^4.1.0"
"react-leaflet": "^2.4.0",
"redux": "^4.0.4"
}, },
"devDependencies": { "devDependencies": {
"@babel/cli": "^7.5.5", "@babel/cli": "^7.5.5",
"@babel/core": "^7.5.5", "@babel/core": "^7.5.5",
"@babel/plugin-proposal-class-properties": "^7.5.5", "@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/plugin-proposal-object-rest-spread": "^7.5.5", "@babel/plugin-proposal-object-rest-spread": "^7.5.5",
"@babel/polyfill": "^7.4.4",
"@babel/preset-env": "^7.5.5", "@babel/preset-env": "^7.5.5",
"@babel/preset-flow": "^7.0.0-rc.1", "@babel/preset-flow": "^7.0.0-rc.1",
"@babel/preset-react": "^7.0.0-rc.1", "@babel/preset-react": "^7.0.0-rc.1",
"@mdi/js": "^7.0.96",
"babel-eslint": "^10.0.2", "babel-eslint": "^10.0.2",
"babel-loader": "^8.0.6", "babel-loader": "^9.1.0",
"clean-webpack-plugin": "^2.0.0", "buffer": "^6.0.3",
"css-loader": "^3.0.0", "clean-webpack-plugin": "^4.0.0",
"eslint": "^6.1.0", "core-js": "^3.6.0",
"eslint-plugin-flowtype": "^4.0.0", "css-loader": "^6.7.2",
"eslint": "^8.28.0",
"eslint-plugin-flowtype": "^8.0.3",
"eslint-plugin-fp": "^2.3.0", "eslint-plugin-fp": "^2.3.0",
"eslint-plugin-react": "^7.14.3", "eslint-plugin-react": "^7.14.3",
"file-loader": "^4.0.0", "eslint-plugin-react-hooks": "^4.1.2",
"file-loader": "^6.1.0",
"flow": "^0.2.3", "flow": "^0.2.3",
"flow-bin": "^0.110.1", "flow-bin": "^0.193.0",
"flow-typed": "^2.3.0", "flow-typed": "^3.2.1",
"html-webpack-plugin": "^3.1.0", "html-webpack-plugin": "^5.5.0",
"husky": "^3.0.0", "husky": "^8.0.2",
"style-loader": "^0.23.0", "lodash-es": "^4.17.15",
"webpack": "^4.39.1", "process": "^0.11.10",
"webpack-cli": "^3.3.6", "style-loader": "^3.3.1",
"webpack-dev-server": "^3.7.2", "url": "^0.11.0",
"webpack-shell-plugin": "^0.5.0" "webpack": "^5.75.0",
"webpack-cli": "^5.0.0",
"webpack-dev-server": "^4.11.1",
"webpack-shell-plugin-next": "^2.3.1"
}, },
"license": "MIT" "license": "MIT"
} }

View file

@ -9,13 +9,10 @@ import throttle from "lodash/throttle";
import type { Config, Control, Topics } from "config/flowtypes"; import type { Config, Control, Topics } from "config/flowtypes";
import MuiThemeProvider from "@material-ui/core/styles/MuiThemeProvider"; import { withStyles } from "@mui/styles";
import createMuiTheme from "@material-ui/core/styles/createMuiTheme"; import Snackbar from "@mui/material/Snackbar";
import withStyles from "@material-ui/core/styles/withStyles"; import IconButton from "@mui/material/IconButton";
import * as Colors from "@material-ui/core/colors"; import Typography from "@mui/material/Typography";
import Snackbar from "@material-ui/core/Snackbar";
import IconButton from "@material-ui/core/IconButton";
import Typography from "@material-ui/core/Typography";
import SideBar from "components/SideBar"; import SideBar from "components/SideBar";
import ControlMap from "components/ControlMap"; import ControlMap from "components/ControlMap";
@ -39,6 +36,14 @@ export type AppState = {
error: ?string error: ?string
}; };
/*
*const App = (props: AppProps) => {
* const topics = Array.isArray(props.config.topics) ?
* Object.assign({}, ...props.config.topics) : props.config.topics;
* const [mqttConnected, setMqttConnected] = useState(false);
*};
*/
class App extends React.PureComponent<AppProps & Classes, AppState> { class App extends React.PureComponent<AppProps & Classes, AppState> {
controlMap: React.Node controlMap: React.Node
@ -55,7 +60,8 @@ class App extends React.PureComponent<AppProps & Classes, AppState> {
onDisconnect: () => this.setState({ mqttConnected: false }), onDisconnect: () => this.setState({ mqttConnected: false }),
subscribe: map( subscribe: map(
filter(keys(this.topics), (x) => this.topics[x].state != null), filter(keys(this.topics), (x) => this.topics[x].state != null),
(x) => this.topics[x].state.name) (x) => (this.topics[x].state != null ? this.topics[x].state.name : "")
)
}), }),
mqttConnected: false, mqttConnected: false,
search: "", search: "",
@ -94,14 +100,6 @@ class App extends React.PureComponent<AppProps & Classes, AppState> {
}; };
} }
static theme(config: Config) {
return createMuiTheme({
palette: {
primary: Colors[config.space.color]
}
});
}
receiveMessage(rawTopic: string, message: Buffer) { receiveMessage(rawTopic: string, message: Buffer) {
try { try {
const topics = filter( const topics = filter(
@ -115,8 +113,8 @@ class App extends React.PureComponent<AppProps & Classes, AppState> {
for (let i in topics) { for (let i in topics) {
const topic = topics[i]; const topic = topics[i];
const stateTopic = this.topics[topic].state; const stateTopic = this.topics[topic].state;
const parseVal = stateTopic ? stateTopic.type : null; const typeConversion = stateTopic?.type?.from ?? stateTopic?.type;
const val = parseVal == null ? message.toString() : parseVal(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}))});
@ -136,16 +134,16 @@ class App extends React.PureComponent<AppProps & Classes, AppState> {
this.setState({drawerOpened: false}); this.setState({drawerOpened: false});
} }
changeState = (topic: string, value: string) => { changeState = (topic: string, val: string) => {
try { try {
if (this.topics[topic].command == null) { const commandTopic = this.topics[topic].command;
if (commandTopic == null) {
return; return;
} }
const rawTopic = this.topics[topic].command.name; const rawTopic = commandTopic.name;
const transformValue = this.topics[topic].command.type; const typeConversion = commandTopic?.type?.to ?? commandTopic.type;
const val = const value = (typeConversion ?? Buffer.from)(val);
transformValue == null ? value : transformValue(Buffer.from(value)); this.state.mqttSend(rawTopic, value);
this.state.mqttSend(rawTopic, Buffer.from(val));
} catch (err) { } catch (err) {
this.setState({ error: err.toString() }); this.setState({ error: err.toString() });
} }
@ -170,7 +168,7 @@ class App extends React.PureComponent<AppProps & Classes, AppState> {
control={this.state.selectedControl} control={this.state.selectedControl}
onCloseRequest={this.closeDrawer} onCloseRequest={this.closeDrawer}
icon={this.state.selectedControl == null ? null : icon={this.state.selectedControl == null ? null :
this.state.selectedControl.icon(this.state.mqttState)} this.state.selectedControl.icon.render(this.state.mqttState)}
> >
{this.state.selectedControl == null {this.state.selectedControl == null
|| <UiItemList controls={this.state.selectedControl.ui} />} || <UiItemList controls={this.state.selectedControl.ui} />}
@ -204,11 +202,6 @@ class App extends React.PureComponent<AppProps & Classes, AppState> {
} }
} }
export default (props: AppProps) => {
const StyledApp = withStyles(App.styles)(App);
return ( export default withStyles(App.styles)(App);
<MuiThemeProvider theme={App.theme(props.config)}>
<StyledApp {...props} />
</MuiThemeProvider>
);
};

View file

@ -1,12 +1,15 @@
// @flow // @flow
import React from "react"; import React from "react";
import { Map, ImageOverlay, Marker, LayersControl } from "react-leaflet"; import { MapContainer, ImageOverlay, Marker, LayersControl } from "react-leaflet";
import { CRS, point, divIcon } from "leaflet"; import { CRS, point, divIcon } from "leaflet";
import map from "lodash/map"; import map from "lodash/map";
import filter from "lodash/filter"; import filter from "lodash/filter";
import reduce from "lodash/reduce"; import reduce from "lodash/reduce";
import MqttContext from "mqtt/context"; import MqttContext from "mqtt/context";
import type { Controls, Control, UIControl, ControlUI } from "config/flowtypes"; import type {
Controls, Control, UIControl, ControlUI, Layer
} from "config/flowtypes";
import { renderToString } from "react-dom/server";
export type Point = [number, number]; export type Point = [number, number];
@ -28,21 +31,11 @@ const center = (props: ControlMapProps): Point =>
props.height / 2 props.height / 2
]); ]);
const iconColor = (control: Control, state: State): string => {
if (control.iconColor != null) {
return control.iconColor(state);
}
return "#000";
};
const createLeafletIcon = (control: Control, state: State) => { const createLeafletIcon = (control: Control, state: State) => {
const icon = control.icon(state);
const iconClass = `${icon} mdi-36px`;
return divIcon({ return divIcon({
iconSize: point(36, 36), iconSize: point(36, 36),
iconAnchor: point(18, 18), iconAnchor: point(18, 18),
html: `<i class="${iconClass}" html: renderToString(control.icon.render(state))
style="line-height: 1; color: ${iconColor(control, state)}"></i>`
}); });
}; };
@ -52,7 +45,9 @@ const renderMarker = (props: ControlMapProps) =>
{({ state }) => ( {({ state }) => (
<Marker position={convertPoint(control.position)} <Marker position={convertPoint(control.position)}
icon={createLeafletIcon(control, state)} icon={createLeafletIcon(control, state)}
onClick={() => props.onChangeControl(control)} eventHandlers={{
click: () => props.onChangeControl(control)
}}
> >
</Marker> </Marker>
)} )}
@ -125,13 +120,13 @@ const renderLayers = (props: ControlMapProps) => (
); );
const ControlMap = (props: ControlMapProps) => ( const ControlMap = (props: ControlMapProps) => (
<Map center={center(props)} <MapContainer center={center(props)}
zoom={props.zoom} zoom={props.zoom}
crs={CRS.Simple} crs={CRS.Simple}
leaflet={{}}> leaflet={{}}>
{renderMarkers(props)} {renderMarkers(props)}
{renderLayers(props)} {renderLayers(props)}
</Map> </MapContainer>
); );
export default ControlMap; export default ControlMap;

View file

@ -1,62 +1,63 @@
// @flow // @flow
import * as React from "react"; import * as React from "react";
import withStyles from "@material-ui/core/styles/withStyles"; import { makeStyles } from "@mui/styles";
import Drawer from "@material-ui/core/Drawer"; import Drawer from "@mui/material/Drawer";
import Typography from "@material-ui/core/Typography"; import Typography from "@mui/material/Typography";
import IconButton from "@material-ui/core/IconButton"; import IconButton from "@mui/material/IconButton";
import AppBar from "@material-ui/core/AppBar"; import AppBar from "@mui/material/AppBar";
import Toolbar from "@material-ui/core/Toolbar"; import Toolbar from "@mui/material/Toolbar";
import List from "@material-ui/core/List"; import List from "@mui/material/List";
import { renderRawIcon } from "config/icon"; import ReactIcon from "@mdi/react";
import { mdiClose } from "@mdi/js";
import type { RawIcon } from "config/icon";
import type { Control } from "config/flowtypes"; import type { Control } from "config/flowtypes";
export type SideBarProps = { export type SideBarProps = {
control: ?Control, control: ?Control,
open: boolean, open: boolean,
onCloseRequest: () => void, onCloseRequest: () => void,
icon?: ?RawIcon, icon?: ?React.Node,
children?: React.Node children?: React.Node
}; };
type Props = SideBarProps & Classes; const useStyles = makeStyles((theme) => ({
const SideBar = (props: Props) => (
<Drawer open={props.open}
anchor="right"
onClose={props.onCloseRequest}
classes={{paper: props.classes.drawerPaper}}
variant="persistent"
>
<AppBar position="static">
<Toolbar>
<span>
{props.icon == null || renderRawIcon(props.icon, "mdi-36px")}
</span>
<Typography variant="title" className={props.classes.title}>
{props.control == null ? "" : props.control.name}
</Typography>
<IconButton onClick={props.onCloseRequest}>
<i className="mdi mdi-close"></i>
</IconButton>
</Toolbar>
</AppBar>
<List id="drawer_uiComponents">
<React.Fragment>{props.children}</React.Fragment>
</List>
</Drawer>
);
const styles = (theme) => ({
drawerPaper: { drawerPaper: {
width: 340 width: 340
}, },
title: { title: {
flex: 1, flex: 1,
marginLeft: theme.spacing.unit marginLeft: theme.spacing(1)
} }
}); }));
export default withStyles(styles)(SideBar); const SideBar = (props: SideBarProps) => {
const classes = useStyles();
return (
<Drawer open={props.open}
anchor="right"
onClose={props.onCloseRequest}
classes={{paper: classes.drawerPaper}}
variant="persistent"
>
<AppBar position="static">
<Toolbar>
<span>
{props.icon == null || props.icon}
</span>
<Typography variant="subtitle1" className={classes.title}>
{props.control == null ? "" : props.control.name}
</Typography>
<IconButton onClick={props.onCloseRequest}>
<ReactIcon path={mdiClose} size={1.5} />
</IconButton>
</Toolbar>
</AppBar>
<List id="drawer_uiComponents">
<React.Fragment>{props.children}</React.Fragment>
</List>
</Drawer>
);
};
export default SideBar;

View file

@ -1,14 +1,16 @@
// @flow // @flow
import React from "react"; import React from "react";
import AppBar from "@material-ui/core/AppBar"; import AppBar from "@mui/material/AppBar";
import Toolbar from "@material-ui/core/Toolbar"; import Toolbar from "@mui/material/Toolbar";
import CircularProgress from "@material-ui/core/CircularProgress"; import CircularProgress from "@mui/material/CircularProgress";
import InputBase from "@material-ui/core/InputBase"; import InputBase from "@mui/material/InputBase";
import { fade } from "@material-ui/core/styles/colorManipulator"; import { styled } from "@mui/styles";
import { withStyles } from "@material-ui/core/styles"; import { alpha } from "@mui/material/styles";
import Tooltip from "@material-ui/core/Tooltip"; import Tooltip from "@mui/material/Tooltip";
import IconButton from "@material-ui/core/IconButton"; import IconButton from "@mui/material/IconButton";
import ReactIcon from "@mdi/react";
import { mdiMap, mdiGithub, mdiMagnify } from "@mdi/js";
export type TopBarProps = { export type TopBarProps = {
connected: boolean, connected: boolean,
@ -21,89 +23,74 @@ export type SearchBarProps = {
const renderConnectionIndicator = (connected: boolean) => { const renderConnectionIndicator = (connected: boolean) => {
if (connected) { if (connected) {
return (<i style={{fontSize: 32}} className="mdi mdi-map"></i>); return (<ReactIcon path={mdiMap} size={2} />);
} }
return ( return (
<CircularProgress size={32} style={{color: "rgba(0, 0, 0, 0.54)"}} /> <CircularProgress size={32} style={{color: "rgba(0, 0, 0, 0.54)"}} />
); );
}; };
const searchStyles = (theme) => ({ const Search = styled('div')(({ theme }) => ({
search: { position: 'relative',
position: "relative", borderRadius: theme.shape.borderRadius,
borderRadius: theme.shape.borderRadius, backgroundColor: alpha(theme.palette.common.white, 0.15),
backgroundColor: fade(theme.palette.common.white, 0.15), '&:hover': {
"&:hover": { backgroundColor: alpha(theme.palette.common.white, 0.25),
backgroundColor: fade(theme.palette.common.white, 0.25) },
marginRight: theme.spacing(2),
marginLeft: 0,
width: '100%',
[theme.breakpoints.up('sm')]: {
marginLeft: theme.spacing(3),
width: 'auto',
},
}));
const SearchIconWrapper = styled('div')(({ theme }) => ({
padding: theme.spacing(0, 2),
height: '100%',
position: 'absolute',
pointerEvents: 'none',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}));
const StyledInputBase = styled(InputBase)(({ theme }) => ({
color: 'inherit',
'& .MuiInputBase-input': {
padding: theme.spacing(1, 1, 1, 0),
// vertical padding + font size from searchIcon
paddingLeft: `calc(1em + ${theme.spacing(4)})`,
transition: theme.transitions.create('width'),
width: '100%',
[theme.breakpoints.up('md')]: {
width: '20ch',
}, },
marginRight: theme.spacing.unit * 2,
marginLeft: 0,
width: "100%",
[theme.breakpoints.up("sm")]: {
marginLeft: theme.spacing.unit * 3,
width: "auto"
}
}, },
searchIcon: { }));
width: theme.spacing.unit * 6,
height: "100%",
position: "absolute",
pointerEvents: "none",
display: "flex",
alignItems: "center",
justifyContent: "center",
fontSize: "24px"
},
inputRoot: {
color: "inherit",
width: "100%"
},
inputInput: {
paddingTop: theme.spacing.unit,
paddingRight: theme.spacing.unit,
paddingBottom: theme.spacing.unit,
paddingLeft: theme.spacing.unit * 6,
transition: theme.transitions.create("width"),
width: "100%",
[theme.breakpoints.up("md")]: {
width: 200
}
}
});
const RawSearch = (props: SearchBarProps & Classes) => (
<div className={props.classes.search}>
<i className={`mdi mdi-magnify ${props.classes.searchIcon}`}></i>
<InputBase placeholder="Search…" type="search"
onChange={(e) => props.onSearch(e.target.value)}
classes={{
root: props.classes.inputRoot,
input: props.classes.inputInput
}} />
</div>
);
const Search = withStyles(searchStyles)(RawSearch);
const openOnGithub = () => window.open( const openOnGithub = () => window.open(
"https://github.com/uwap/mqtt-control-map", "_blank"); "https://github.com/uwap/mqtt-control-map", "_blank");
const sendFeedback = () => window.open("mailto:mail+feedback@uwap.name");
const TopBar = (props: TopBarProps) => ( const TopBar = (props: TopBarProps) => (
<AppBar position="static"> <AppBar position="static" color="primary">
<Toolbar> <Toolbar>
{renderConnectionIndicator(props.connected)} {renderConnectionIndicator(props.connected)}
<Search onSearch={props.onSearch} /> <Search>
<SearchIconWrapper>
<ReactIcon path={mdiMagnify} size={1} />
</SearchIconWrapper>
<StyledInputBase
placeholder="Search…"
inputProps={{ 'aria-label': 'search' }}
onChange={(e) => props.onSearch(e.target.value)}
/>
</Search>
<span style={{flex: 1}}></span> <span style={{flex: 1}}></span>
<Tooltip title="Github"> <Tooltip title="View on Github">
<IconButton onClick={openOnGithub} style={{ fontSize: "28px" }}> <IconButton onClick={openOnGithub}>
<i className="mdi mdi-github-circle"></i> <ReactIcon path={mdiGithub} size={1.5} />
</IconButton>
</Tooltip>
<Tooltip title="Send me feedback">
<IconButton onClick={sendFeedback} style={{ fontSize: "28px" }}>
<i className="mdi mdi-email-plus"></i>
</IconButton> </IconButton>
</Tooltip> </Tooltip>
</Toolbar> </Toolbar>

View file

@ -1,6 +1,6 @@
// @flow // @flow
import * as React from "react"; import * as React from "react";
import ListItem from "@material-ui/core/ListItem"; import ListItem from "@mui/material/ListItem";
import type { ControlUI } from "config/flowtypes"; import type { ControlUI } from "config/flowtypes";

View file

@ -6,11 +6,11 @@ import { isDisabled, getValue } from "./utils";
import type { UIDropDown } from "config/flowtypes"; import type { UIDropDown } from "config/flowtypes";
import Select from "@material-ui/core/Select"; import Select from "@mui/material/Select";
import FormControl from "@material-ui/core/FormControl"; import FormControl from "@mui/material/FormControl";
import InputLabel from "@material-ui/core/InputLabel"; import InputLabel from "@mui/material/InputLabel";
import MenuItem from "@material-ui/core/MenuItem"; import MenuItem from "@mui/material/MenuItem";
import Input from "@material-ui/core/Input"; import Input from "@mui/material/Input";
const componentId = (item: UIDropDown) => `dropdown-${item.topic}`; const componentId = (item: UIDropDown) => `dropdown-${item.topic}`;

View file

@ -2,11 +2,10 @@
import React from "react"; import React from "react";
import createComponent from "./base"; import createComponent from "./base";
import { isEnabled, isDisabled } from "./utils"; import { isEnabled, isDisabled } from "./utils";
import { renderRawIcon } from "config/icon";
import type { UILink } from "config/flowtypes"; import type { UILink } from "config/flowtypes";
import Button from "@material-ui/core/Button"; import Button from "@mui/material/Button";
const followLink = (item, state) => () => { const followLink = (item, state) => () => {
if (isEnabled(item, state)) { if (isEnabled(item, state)) {
@ -19,7 +18,7 @@ const Icon = ({item, state}) => {
if (item.icon == null) { if (item.icon == null) {
return false; return false;
} }
return renderRawIcon(item.icon(state), "mdi-24px"); return item.icon.render(state);
}; };
const BaseComponent = (_h, item: UILink, state, _changeState) => ( const BaseComponent = (_h, item: UILink, state, _changeState) => (

View file

@ -5,7 +5,7 @@ import { getValue } from "./utils";
import type { UIProgress } from "config/flowtypes"; import type { UIProgress } from "config/flowtypes";
import LinearProgress from "@material-ui/core/LinearProgress"; import LinearProgress from "@mui/material/LinearProgress";
const progressVal = (item, state) => { const progressVal = (item, state) => {
const min = item.min || 0; const min = item.min || 0;

View file

@ -4,7 +4,7 @@ import createComponent from "./base";
import type { UISection } from "config/flowtypes"; import type { UISection } from "config/flowtypes";
import ListSubheader from "@material-ui/core/ListSubheader"; import ListSubheader from "@mui/material/ListSubheader";
const BaseComponent = (_b, item: UISection, _state, _changeState) => ( const BaseComponent = (_b, item: UISection, _state, _changeState) => (
<ListSubheader>{item.text}</ListSubheader> <ListSubheader>{item.text}</ListSubheader>

View file

@ -5,7 +5,7 @@ import { isDisabled, getValue } from "./utils";
import type { UISlider } from "config/flowtypes"; import type { UISlider } from "config/flowtypes";
import SliderComponent from "@material-ui/lab/Slider"; import SliderComponent from "@mui/material/Slider";
const changeSliderValue = (item: UISlider, changeState) => (_e, v) => const changeSliderValue = (item: UISlider, changeState) => (_e, v) =>
changeState(item, v.toString()); changeState(item, v.toString());
@ -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>
); );
@ -36,5 +38,3 @@ export default createComponent({
}, },
baseComponent: BaseComponent baseComponent: BaseComponent
}); });

View file

@ -5,7 +5,7 @@ import { getValue } from "./utils";
import type { UIText } from "config/flowtypes"; import type { UIText } from "config/flowtypes";
import ListItemText from "@material-ui/core/ListItemText"; import ListItemText from "@mui/material/ListItemText";
const BaseComponent = ({Icon}, item: UIText, state, _changeState) => ( const BaseComponent = ({Icon}, item: UIText, state, _changeState) => (
<React.Fragment> <React.Fragment>

View file

@ -5,7 +5,7 @@ import { isDisabled, isEnabled, getValue } from "./utils";
import type { UIToggle } from "config/flowtypes"; import type { UIToggle } from "config/flowtypes";
import Switch from "@material-ui/core/Switch"; import Switch from "@mui/material/Switch";
const isToggled = (item: UIToggle, state: State) => { const isToggled = (item: UIToggle, state: State) => {
const isChecked = item.toggled || const isChecked = item.toggled ||

View file

@ -2,18 +2,17 @@
import * as React from "react"; import * as React from "react";
import MqttContext from "mqtt/context"; import MqttContext from "mqtt/context";
import ListItemSecondaryAction from "@material-ui/core/ListItemSecondaryAction"; import ListItemSecondaryAction from "@mui/material/ListItemSecondaryAction";
import ListItemText from "@material-ui/core/ListItemText"; import ListItemText from "@mui/material/ListItemText";
import ListItemIcon from "@material-ui/core/ListItemIcon"; import ListItemIcon from "@mui/material/ListItemIcon";
import throttle from "lodash/throttle"; import throttle from "lodash/throttle";
import { renderRawIcon } from "config/icon";
import type { Icon } from "config/icon"; import type { Icon } from "config/icon";
export type Helpers = { export type Helpers = {
Icon: (props: Object) => React.Node, Icon: (props: { item: { +icon?: Icon }, state: State }) => React.Node,
Label: (props: Object) => React.Node, Label: (props: {}) => React.Node,
Action: (props: Object) => React.Node Action: (props: {}) => React.Node
}; };
export type BaseComponent<T> = ( export type BaseComponent<T> = (
@ -41,15 +40,15 @@ type SuperT = $ReadOnly<{ text: string }>;
const IconHelper = ({item, state}: { item: { +icon?: Icon }, state: State }) => const IconHelper = ({item, state}: { item: { +icon?: Icon }, state: State }) =>
( <ListItemIcon> ( <ListItemIcon>
{item.icon == null || renderRawIcon(item.icon(state), "mdi-24px")} {item.icon == null || item.icon.size(1).render(state)}
</ListItemIcon> </ListItemIcon>
); );
const createHelpers = <T: SuperT> (item: T) => const createHelpers = <T: SuperT> (item: T) =>
({ ({
Icon: IconHelper, Icon: IconHelper,
Label: (props) => ( Label: () => (
<ListItemText primary={item.text} {...props} /> <ListItemText primary={item.text} />
), ),
Action: (props) => ( Action: (props) => (
<ListItemSecondaryAction {...props} /> <ListItemSecondaryAction {...props} />

View file

@ -6,10 +6,11 @@ import Link from "./Link";
import Slider from "./Slider"; import Slider from "./Slider";
import Text from "./Text"; import Text from "./Text";
import Progress from "./Progress"; import Progress from "./Progress";
import * as React from "react";
import type { ControlUI } from "config/flowtypes"; import type { ControlUI } from "config/flowtypes";
const Control = ({item}: {item: ControlUI}) => { const Control = ({item}: {item: ControlUI}): React.Node => {
switch (item.type) { switch (item.type) {
case "toggle": { case "toggle": {
return Toggle.component(item); return Toggle.component(item);

View file

@ -1,17 +1,22 @@
// @flow // @flow
import type { Color } from "config/colors";
import type { Icon } from "config/icon"; import type { Icon } from "config/icon";
export type TopicType = (msg: Buffer) => string; export type TopicType = {
from: (msg: Buffer) => string,
to: (newstate: string) => Buffer
};
export type StateCommand = { export type StateTopicType = TopicType | ((msg: Buffer) => string);
export type CommandTopicType = TopicType | ((newstate: string) => Buffer);
export type StateCommand<T> = {
name: string, name: string,
type: TopicType type: T
} }
export type Topic = { export type Topic = {
state?: StateCommand, state?: StateCommand<StateTopicType>,
command?: StateCommand, command?: StateCommand<CommandTopicType>,
defaultValue: string defaultValue: string
}; };
export type Topics = Map<string, Topic>; export type Topics = Map<string, Topic>;
@ -53,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<{|
@ -100,7 +106,6 @@ export type Control = {
name: string, name: string,
position: [number, number], position: [number, number],
icon: Icon, icon: Icon,
iconColor?: (state: State) => Color,
ui: Array<ControlUI> ui: Array<ControlUI>
}; };
export type Controls = Map<string, Control>; export type Controls = Map<string, Control>;
@ -116,6 +121,17 @@ export type Space = {
mqtt: string mqtt: string
}; };
export type Layer = {
image: string,
name: string,
baseLayer?: boolean,
defaultVisibility: "visible" | "hidden",
opacity?: number,
bounds: {
topLeft: Point,
bottomRight: Point
}
};
export type Config = { export type Config = {
space: Space, space: Space,
topics: Topics | Array<Topics>, topics: Topics | Array<Topics>,

View file

@ -1,55 +1,88 @@
// @flow // @flow
import * as React from "react"; import React from "react";
import ReactContext from "mqtt/context"; import ReactIcon from "@mdi/react";
import { type Color } from "./colors";
import * as mdiIcons from "@mdi/js";
export opaque type RawIcon: string = string; type IconPropHelper = {
size?: number,
export type Icon = (State) => RawIcon; rotate?: number,
horizontal?: boolean,
export const rawMdi = (name: string): RawIcon => { vertical?: boolean,
return `mdi ${name.split(" ").map((icon) => "mdi-".concat(icon)).join(" ")}`; color?: Color
}; };
export const mdi = (icon: string) => () => rawMdi(icon); export type Icon = {
render: (s: State) => React.Node,
size: (n: number) => Icon,
rotate: (n: number) => Icon,
flip: () => Icon,
flipV: () => Icon,
color: (c: Color | (State) => Color) => Icon,
applyProps: (props: IconPropHelper) => Icon
};
export const mdiBattery = (topic: string) => (state: State) => { const iconChainUtils = <T> (cb: (x: T, p?: IconPropHelper) => Icon,
p1: T, p?: IconPropHelper) => ({
size: (n: number) => cb(p1, {...p, size: n}),
rotate: (n: number) => cb(p1, {...p, rotate: n}),
flip: () => cb(p1, {...p, horizontal: !p?.horizontal ?? true}),
flipV: () => cb(p1, {...p, vertical: !p?.vertical ?? true}),
color: (c: Color | (State) => Color) => cb(p1, {...p, color: c}),
applyProps: (props: IconPropHelper) => cb(p1, {...p, ...props})
}
);
export const svg = (data: string, props?: IconPropHelper): Icon => {
const propColor = ((c: ?Color | (State) => Color) => (state: State) => {
if (typeof c === "function") {
return c(state);
}
return c;
})(props?.color);
return {
render: (state) => (
<ReactIcon path={data} size={props?.size ?? 1.5}
rotate={props?.rotate ?? 0}
horizontal={props?.horizontal ?? false}
vertical={props?.vertical ?? false}
color={propColor(state)}
/>
),
...iconChainUtils(svg, data, props)
};
};
export const withState = (f: (s: State) => Icon,
props?: IconPropHelper): Icon => ({
render: (state) => f(state).applyProps(props).render(state),
...iconChainUtils(withState, f, props)
}
);
export const mdiBattery = (topic: string): Icon => withState((state) => {
const rawval = state[topic]; const rawval = state[topic];
const val = parseInt(rawval, 10); const val = parseInt(rawval, 10);
if (isNaN(val)) { if (isNaN(val)) {
return rawMdi("battery-unknown"); return svg(mdiIcons.mdiBatteryUnknown);
} else if (val > 95) { } else if (val > 95) {
return rawMdi("battery"); return svg(mdiIcons.mdiBattery);
} else if (val > 85) { } else if (val > 85) {
return rawMdi("battery-90"); return svg(mdiIcons.mdiBattery90);
} else if (val > 75) { } else if (val > 75) {
return rawMdi("battery-80"); return svg(mdiIcons.mdiBattery80);
} else if (val > 65) { } else if (val > 65) {
return rawMdi("battery-70"); return svg(mdiIcons.mdiBattery70);
} else if (val > 55) { } else if (val > 55) {
return rawMdi("battery-60"); return svg(mdiIcons.mdiBattery60);
} else if (val > 45) { } else if (val > 45) {
return rawMdi("battery-50"); return svg(mdiIcons.mdiBattery50);
} else if (val > 35) { } else if (val > 35) {
return rawMdi("battery-40"); return svg(mdiIcons.mdiBattery40);
} else if (val > 25) { } else if (val > 25) {
return rawMdi("battery-30"); return svg(mdiIcons.mdiBattery30);
} else if (val > 15) { } else if (val > 15) {
return rawMdi("battery-20"); return svg(mdiIcons.mdiBattery20);
} else {
return rawMdi("battery-10");
} }
}; return svg(mdiIcons.mdiBattery10);
});
export const renderRawIcon =
(icon: RawIcon, extraClass?: string): React.Node => {
return <i className={`${extraClass || ""} ${icon}`}></i>;
};
export const renderIcon =
(icon: Icon, extraClass?: string): React.Node => {
return (
<ReactContext.Consumer>
{({state}) => renderRawIcon(icon(state), extraClass)}
</ReactContext.Consumer>
);
};

View file

@ -1,13 +1,22 @@
// @flow // @flow
import type { TopicType } from "config/flowtypes"; import type { TopicType } from "config/flowtypes";
import at from "lodash/at"; import at from "lodash/at";
import set from "lodash/set";
export const string: TopicType = (msg: Buffer) => msg.toString(); export const string: TopicType = {
from: (msg: Buffer) => msg.toString(),
to: (msg: string) => Buffer.from(msg)
};
export const json = (path: string, innerType?: TopicType): TopicType => { export const json = (path: string, innerType?: TopicType): TopicType => {
const parseAgain = innerType == null ? (x) => x.toString() : innerType; const parseAgain = innerType?.from ?? ((x) => x.toString());
return (msg) => parseAgain(Buffer.from( const parseFirst = innerType?.to ?? ((x) => Buffer.from(x));
at(JSON.parse(msg.toString()), path)[0].toString())); return {
from: (msg) => parseAgain(Buffer.from(
at(JSON.parse(msg.toString()), path)[0].toString())),
to: (msg) => Buffer.from(
JSON.stringify(set({}, path, parseFirst(msg).toString())))
};
}; };
export type TypeOptionParam = { otherwise?: string, [string]: string }; export type TypeOptionParam = { otherwise?: string, [string]: string };
@ -16,13 +25,17 @@ export const option = (values: TypeOptionParam): TopicType => {
if (values.otherwise != null) { if (values.otherwise != null) {
return values.otherwise; return values.otherwise;
} else { } else {
throw new Error( return x;
`Value ${x.toString()} cannot by mapped by the option parameters given`
);
} }
}; };
const mapVal = (x) => (values[x] != null ? values[x] : defaultValue(x)); const mapVal = (x) => (values[x] != null ? values[x] : defaultValue(x));
return (x) => mapVal(x.toString()); return {
from: (x) => mapVal(x.toString()),
to: (x) => Buffer.from(mapVal(x))
};
}; };
export const jsonArray = (msg: Buffer) => JSON.parse(msg.toString()).join(", "); export const jsonArray = {
from: (msg: Buffer) => JSON.parse(msg.toString()).join(", "),
to: (msg: string) => Buffer.from(`[${msg}]`)
};

View file

@ -49,7 +49,7 @@ export default function connectMqtt(
} }
}); });
return (topic: string, message: Buffer) => { return (topic: string, message: Buffer) => {
client.publish(topic, message, null, (error) => { client.publish(topic, message, {}, (error) => {
if (error == null && settings.onMessageSent != null) { if (error == null && settings.onMessageSent != null) {
settings.onMessageSent(topic, message); settings.onMessageSent(topic, message);
} }

View file

@ -1,10 +1,20 @@
// @flow // @flow
import "core-js/stable";
import "regenerator-runtime/runtime";
import "../node_modules/leaflet/dist/leaflet.css";
import '@fontsource/roboto/300.css';
import '@fontsource/roboto/400.css';
import '@fontsource/roboto/500.css';
import '@fontsource/roboto/700.css';
import React from "react"; import React from "react";
import ReactDOM from "react-dom"; import ReactDOM from "react-dom";
import App from "components/App"; import App from "components/App";
import { createTheme } from "@mui/material/styles";
import { ThemeProvider } from "@mui/styles";
import * as Colors from "@mui/material/colors";
import "../node_modules/@mdi/font/css/materialdesignicons.min.css";
import "../css/styles.css"; import "../css/styles.css";
import type { Config } from "config/flowtypes"; import type { Config } from "config/flowtypes";
@ -13,6 +23,21 @@ const config: Config = window.config;
document.title = `${config.space.name} Map`; document.title = `${config.space.name} Map`;
const theme = createTheme({
palette: {
primary: {
main: Colors[config.space.color][500]
},
secondary: {
main: Colors.orange[500]
}
}
});
// $FlowFixMe // $FlowFixMe
const contentElement: Element = document.getElementById("content"); const contentElement: Element = document.getElementById("content");
ReactDOM.render(<App config={config} />, contentElement); ReactDOM.render((
<ThemeProvider theme={theme}>
<App config={config} />
</ThemeProvider>
), contentElement);

View file

@ -3,10 +3,10 @@ import React from "react";
export type MqttContextValue = { export type MqttContextValue = {
state: State, state: State,
changeState: (topic: string, value: string) => void changeState: (topic: string, value: string) => State
}; };
export default React.createContext({ export default React.createContext({
state: {}, state: {},
changeState: (_topic, _val) => {} changeState: (_topic, _val) => ({})
}); });

View file

@ -10,15 +10,3 @@ declare type Classes = {
declare type State = Map<string,string>; declare type State = Map<string,string>;
declare type Point = [number, number]; declare type Point = [number, number];
declare type Layer = {
image: string,
name: string,
baseLayer?: boolean,
defaultVisibility: "visible" | "hidden",
opacity?: number,
bounds: {
topLeft: Point,
bottomRight: Point
}
};

View file

@ -1,30 +1,32 @@
const path = require('path'); const path = require('path');
const webpack = require('webpack'); const webpack = require('webpack');
const WebpackShellPlugin = require('webpack-shell-plugin'); const WebpackShellPlugin = require('webpack-shell-plugin-next');
const HtmlWebpackPlugin = require('html-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin'); const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const preBuildScripts = process.env.NO_FLOW == undefined ? const preBuildScripts = process.env.NO_FLOW == undefined ?
process.env.FLOW_PATH != undefined ? [process.env.FLOW_PATH] : ['flow'] process.env.FLOW_PATH != undefined ? [process.env.FLOW_PATH] : ['flow']
: []; : [];
const configPath = env => { const configPath = env => {
if (env === true) { const filtered = Object.keys(env).filter((e) => !e.startsWith("WEBPACK"));
if (filtered.length < 1) {
throw "No config file was provided."; throw "No config file was provided.";
} }
return path.resolve(__dirname, `config/${env}`); return path.resolve(__dirname, `config/${filtered[0]}`);
}; };
module.exports = env => ({ module.exports = env => ({
entry: { entry: {
main: ["@babel/polyfill", configPath(env), main: [configPath(env),
path.resolve(__dirname, 'src/index.jsx')] path.resolve(__dirname, 'src/index.jsx')]
}, },
resolve: { resolve: {
modules: [path.resolve(__dirname, "src"), "node_modules"], modules: [path.resolve(__dirname, "src"), "node_modules"],
extensions: ['.js', '.jsx'], extensions: ['.js', '.jsx'],
alias: { alias: {
'lodash': 'lodash-es' 'lodash': 'lodash-es',
} "leaflet": "leaflet/dist/leaflet-src.esm.js"
},
}, },
output: { output: {
path: path.resolve(__dirname, 'dist'), path: path.resolve(__dirname, 'dist'),
@ -34,16 +36,26 @@ module.exports = env => ({
rules: [ rules: [
// TODO: CSS follow imports and minify + sourcemap on production // TODO: CSS follow imports and minify + sourcemap on production
{ test: /\.css$/, use: [ 'style-loader', 'css-loader' ] }, { test: /\.css$/, use: [ 'style-loader', 'css-loader' ] },
{ test: /\.(woff2?|eot|ttf|svg)$/, loader: "file-loader" }, { test: /\.(woff2?|eot|ttf|svg|png)$/, use: [ { loader: "file-loader", options: { esModule: false } } ] },
{ test: /\.js(x)?$/, loader: "babel-loader?cacheDirectory=true" } { test: /\.js(x)?$/, use: ["babel-loader?cacheDirectory=true"] }
] ]
}, },
plugins: [ plugins: [
new CleanWebpackPlugin(), new CleanWebpackPlugin(),
new WebpackShellPlugin({onBuildStart:preBuildScripts}), new WebpackShellPlugin({
onBuildStart: {
scripts: preBuildScripts,
blocking: true,
parallel: false
}
}),
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
title: 'Space Map', title: 'Space Map',
template: 'index.ejs' template: 'index.ejs'
}), }),
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
process: 'process/browser',
}),
] ]
}); });

9734
yarn.lock

File diff suppressed because it is too large Load diff