diff --git a/config/rzl.js b/config/rzl.js index 3f2706a..f856f21 100644 --- a/config/rzl.js +++ b/config/rzl.js @@ -4,7 +4,8 @@ import * as utils from './utils'; const config : Config = { space: { name: "RZL", - color: "orange" + color: "orange", + mqtt: "ws://map.rzl:1884" }, topics: { led_stahltraeger: { diff --git a/src/index.jsx b/src/index.jsx index 1dd5ab2..8c38ea2 100644 --- a/src/index.jsx +++ b/src/index.jsx @@ -89,4 +89,4 @@ store.subscribe(() => ReactDOM.render(, document store.dispatch({type:null}); -connectMqtt("ws://172.22.36.207:1884", store); +connectMqtt(Config.space.mqtt, store); diff --git a/src/mqtt.js b/src/mqtt.js index 7ab8c1f..3223ae8 100644 --- a/src/mqtt.js +++ b/src/mqtt.js @@ -23,4 +23,13 @@ export default function connectMqtt(url: string, store: Store<*,*>) { } }); }); + client.on("offline", () => { + store.dispatch({ type: null }); + }); + client.on("close", () => { + store.dispatch({ type: null }); + }); + client.on("reconnect", () => { + store.dispatch({ type: null }); + }); } diff --git a/types/types.js b/types/types.js index 5d002bc..3590066 100644 --- a/types/types.js +++ b/types/types.js @@ -27,7 +27,7 @@ declare type ControlUI = { // DROPDOWN optional properties options?: Map, //options for dropDown - renderValue?: (value: string) => string + renderValue?: (value: string) => string, // SLIDER optional properties min?: number,