@victronenergy/mfd-modules 10.4.2 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/src/Modules/AcLoads/AcLoads.provider.d.ts.map +1 -1
- package/dist/src/Modules/AcLoads/AcLoads.provider.js +19 -19
- package/dist/src/Modules/AcLoads/AcLoads.provider.js.map +1 -1
- package/dist/src/Modules/AcMode/AcMode.provider.d.ts.map +1 -1
- package/dist/src/Modules/AcMode/AcMode.provider.js +19 -31
- package/dist/src/Modules/AcMode/AcMode.provider.js.map +1 -1
- package/dist/src/Modules/ActiveSource/ActiveInValues.provider.js +17 -17
- package/dist/src/Modules/ActiveSource/ActiveInValues.provider.js.map +1 -1
- package/dist/src/Modules/ActiveSource/ActiveSource.provider.js +11 -11
- package/dist/src/Modules/ActiveSource/ActiveSource.provider.js.map +1 -1
- package/dist/src/Modules/Alternators/Alternator.provider.d.ts.map +1 -1
- package/dist/src/Modules/Alternators/Alternator.provider.js +7 -8
- package/dist/src/Modules/Alternators/Alternator.provider.js.map +1 -1
- package/dist/src/Modules/Alternators/Alternators.provider.d.ts.map +1 -1
- package/dist/src/Modules/Alternators/Alternators.provider.js +16 -14
- package/dist/src/Modules/Alternators/Alternators.provider.js.map +1 -1
- package/dist/src/Modules/Alternators/Alternators.store.d.ts.map +1 -1
- package/dist/src/Modules/Alternators/Alternators.store.js +7 -10
- package/dist/src/Modules/Alternators/Alternators.store.js.map +1 -1
- package/dist/src/Modules/App/App.provider.js +47 -47
- package/dist/src/Modules/App/App.provider.js.map +1 -1
- package/dist/src/Modules/App/App.store.d.ts +2 -2
- package/dist/src/Modules/App/App.store.d.ts.map +1 -1
- package/dist/src/Modules/App/App.store.js +67 -110
- package/dist/src/Modules/App/App.store.js.map +1 -1
- package/dist/src/Modules/Battery/Batteries.provider.d.ts.map +1 -1
- package/dist/src/Modules/Battery/Batteries.provider.js +16 -14
- package/dist/src/Modules/Battery/Batteries.provider.js.map +1 -1
- package/dist/src/Modules/Battery/Batteries.store.d.ts.map +1 -1
- package/dist/src/Modules/Battery/Batteries.store.js +7 -10
- package/dist/src/Modules/Battery/Batteries.store.js.map +1 -1
- package/dist/src/Modules/Battery/SystemBatteries.provider.js +5 -5
- package/dist/src/Modules/Battery/SystemBatteries.provider.js.map +1 -1
- package/dist/src/Modules/Chargers/Charger.provider.js +23 -33
- package/dist/src/Modules/Chargers/Charger.provider.js.map +1 -1
- package/dist/src/Modules/Chargers/Chargers.provider.d.ts.map +1 -1
- package/dist/src/Modules/Chargers/Chargers.provider.js +16 -15
- package/dist/src/Modules/Chargers/Chargers.provider.js.map +1 -1
- package/dist/src/Modules/Chargers/Chargers.store.d.ts.map +1 -1
- package/dist/src/Modules/Chargers/Chargers.store.js +7 -10
- package/dist/src/Modules/Chargers/Chargers.store.js.map +1 -1
- package/dist/src/Modules/DcLoads/DcLoads.provider.d.ts.map +1 -1
- package/dist/src/Modules/DcLoads/DcLoads.provider.js +9 -20
- package/dist/src/Modules/DcLoads/DcLoads.provider.js.map +1 -1
- package/dist/src/Modules/Generators/ConnectedGenset.provider.d.ts.map +1 -1
- package/dist/src/Modules/Generators/ConnectedGenset.provider.js +36 -47
- package/dist/src/Modules/Generators/ConnectedGenset.provider.js.map +1 -1
- package/dist/src/Modules/Generators/ConnectedGensets.provider.d.ts.map +1 -1
- package/dist/src/Modules/Generators/ConnectedGensets.provider.js +16 -14
- package/dist/src/Modules/Generators/ConnectedGensets.provider.js.map +1 -1
- package/dist/src/Modules/Generators/ConnectedGensets.store.d.ts.map +1 -1
- package/dist/src/Modules/Generators/ConnectedGensets.store.js +8 -11
- package/dist/src/Modules/Generators/ConnectedGensets.store.js.map +1 -1
- package/dist/src/Modules/Generators/GeneratorConnectedGenset.provider.js +17 -27
- package/dist/src/Modules/Generators/GeneratorConnectedGenset.provider.js.map +1 -1
- package/dist/src/Modules/Generators/GeneratorRelay.provider.d.ts +2 -2
- package/dist/src/Modules/Generators/GeneratorRelay.provider.d.ts.map +1 -1
- package/dist/src/Modules/Generators/GeneratorRelay.provider.js +24 -34
- package/dist/src/Modules/Generators/GeneratorRelay.provider.js.map +1 -1
- package/dist/src/Modules/Header/Header.provider.js +4 -4
- package/dist/src/Modules/Header/Header.provider.js.map +1 -1
- package/dist/src/Modules/InverterCharger/InputLimit.provider.js +6 -17
- package/dist/src/Modules/InverterCharger/InputLimit.provider.js.map +1 -1
- package/dist/src/Modules/InverterCharger/InputLimitSelector.provider.d.ts.map +1 -1
- package/dist/src/Modules/InverterCharger/InputLimitSelector.provider.js +12 -26
- package/dist/src/Modules/InverterCharger/InputLimitSelector.provider.js.map +1 -1
- package/dist/src/Modules/InverterCharger/InverterCharger.provider.d.ts.map +1 -1
- package/dist/src/Modules/InverterCharger/InverterCharger.provider.js +16 -27
- package/dist/src/Modules/InverterCharger/InverterCharger.provider.js.map +1 -1
- package/dist/src/Modules/Inverters/Inverter.provider.d.ts.map +1 -1
- package/dist/src/Modules/Inverters/Inverter.provider.js +19 -30
- package/dist/src/Modules/Inverters/Inverter.provider.js.map +1 -1
- package/dist/src/Modules/Inverters/Inverters.provider.d.ts.map +1 -1
- package/dist/src/Modules/Inverters/Inverters.provider.js +14 -13
- package/dist/src/Modules/Inverters/Inverters.provider.js.map +1 -1
- package/dist/src/Modules/Inverters/Inverters.store.d.ts.map +1 -1
- package/dist/src/Modules/Inverters/Inverters.store.js +7 -10
- package/dist/src/Modules/Inverters/Inverters.store.js.map +1 -1
- package/dist/src/Modules/Inverters/index.js.map +1 -1
- package/dist/src/Modules/Language/Language.provider.d.ts +1 -1
- package/dist/src/Modules/Language/Language.provider.d.ts.map +1 -1
- package/dist/src/Modules/Language/Language.provider.js +21 -56
- package/dist/src/Modules/Language/Language.provider.js.map +1 -1
- package/dist/src/Modules/Mqtt/Mqtt.constants.js +1 -1
- package/dist/src/Modules/Mqtt/Mqtt.constants.js.map +1 -1
- package/dist/src/Modules/Mqtt/Mqtt.provider.d.ts +2 -2
- package/dist/src/Modules/Mqtt/Mqtt.provider.d.ts.map +1 -1
- package/dist/src/Modules/Mqtt/Mqtt.provider.js +4 -4
- package/dist/src/Modules/Mqtt/Mqtt.provider.js.map +1 -1
- package/dist/src/Modules/Mqtt/Mqtt.store.d.ts +3 -3
- package/dist/src/Modules/Mqtt/Mqtt.store.d.ts.map +1 -1
- package/dist/src/Modules/Mqtt/Mqtt.store.js +169 -193
- package/dist/src/Modules/Mqtt/Mqtt.store.js.map +1 -1
- package/dist/src/Modules/Mqtt/Mqtt.types.d.ts +1 -1
- package/dist/src/Modules/Mqtt/Mqtt.types.d.ts.map +1 -1
- package/dist/src/Modules/Mqtt/Mqtt.types.js +0 -1
- package/dist/src/Modules/Mqtt/Mqtt.types.js.map +1 -1
- package/dist/src/Modules/PvCharger/PvCharger.provider.js +8 -8
- package/dist/src/Modules/PvCharger/PvCharger.provider.js.map +1 -1
- package/dist/src/Modules/ShorePowerInput/ShorePowerInput.provider.d.ts +4 -1
- package/dist/src/Modules/ShorePowerInput/ShorePowerInput.provider.d.ts.map +1 -1
- package/dist/src/Modules/ShorePowerInput/ShorePowerInput.provider.js +24 -35
- package/dist/src/Modules/ShorePowerInput/ShorePowerInput.provider.js.map +1 -1
- package/dist/src/Modules/ShorePowerInput/index.d.ts +0 -1
- package/dist/src/Modules/ShorePowerInput/index.d.ts.map +1 -1
- package/dist/src/Modules/ShorePowerInput/index.js +0 -1
- package/dist/src/Modules/ShorePowerInput/index.js.map +1 -1
- package/dist/src/Modules/SwitchingPane/GenericInput.provider.d.ts +27 -0
- package/dist/src/Modules/SwitchingPane/GenericInput.provider.d.ts.map +1 -0
- package/dist/src/Modules/SwitchingPane/GenericInput.provider.js +32 -0
- package/dist/src/Modules/SwitchingPane/GenericInput.provider.js.map +1 -0
- package/dist/src/Modules/{SwitchableOutputs → SwitchingPane}/SwitchableOutput.provider.d.ts +25 -9
- package/dist/src/Modules/SwitchingPane/SwitchableOutput.provider.d.ts.map +1 -0
- package/dist/src/Modules/SwitchingPane/SwitchableOutput.provider.js +58 -0
- package/dist/src/Modules/SwitchingPane/SwitchableOutput.provider.js.map +1 -0
- package/dist/src/Modules/SwitchingPane/SwitchingDevice.provider.d.ts.map +1 -0
- package/dist/src/Modules/SwitchingPane/SwitchingDevice.provider.js +48 -0
- package/dist/src/Modules/SwitchingPane/SwitchingDevice.provider.js.map +1 -0
- package/dist/src/Modules/SwitchingPane/SwitchingDevices.store.d.ts.map +1 -0
- package/dist/src/Modules/{SwitchableOutputs → SwitchingPane}/SwitchingDevices.store.js +7 -10
- package/dist/src/Modules/SwitchingPane/SwitchingDevices.store.js.map +1 -0
- package/dist/src/Modules/SwitchingPane/SwitchingPane.provider.d.ts +2 -0
- package/dist/src/Modules/SwitchingPane/SwitchingPane.provider.d.ts.map +1 -0
- package/dist/src/Modules/SwitchingPane/SwitchingPane.provider.js +256 -0
- package/dist/src/Modules/SwitchingPane/SwitchingPane.provider.js.map +1 -0
- package/dist/src/Modules/SwitchingPane/SwitchingPane.store.d.ts +50 -0
- package/dist/src/Modules/SwitchingPane/SwitchingPane.store.d.ts.map +1 -0
- package/dist/src/Modules/{SwitchableOutputs/SwitchableOutputs.store.js → SwitchingPane/SwitchingPane.store.js} +67 -18
- package/dist/src/Modules/SwitchingPane/SwitchingPane.store.js.map +1 -0
- package/dist/src/Modules/SwitchingPane/index.d.ts +7 -0
- package/dist/src/Modules/SwitchingPane/index.d.ts.map +1 -0
- package/dist/src/Modules/SwitchingPane/index.js +7 -0
- package/dist/src/Modules/SwitchingPane/index.js.map +1 -0
- package/dist/src/Modules/SystemState/SystemState.provider.js +5 -5
- package/dist/src/Modules/SystemState/SystemState.provider.js.map +1 -1
- package/dist/src/Modules/Tanks/Tank.provider.d.ts.map +1 -1
- package/dist/src/Modules/Tanks/Tank.provider.js +11 -11
- package/dist/src/Modules/Tanks/Tank.provider.js.map +1 -1
- package/dist/src/Modules/Tanks/Tanks.provider.d.ts.map +1 -1
- package/dist/src/Modules/Tanks/Tanks.provider.js +19 -18
- package/dist/src/Modules/Tanks/Tanks.provider.js.map +1 -1
- package/dist/src/Modules/Tanks/Tanks.store.d.ts.map +1 -1
- package/dist/src/Modules/Tanks/Tanks.store.js +7 -10
- package/dist/src/Modules/Tanks/Tanks.store.js.map +1 -1
- package/dist/src/Modules/Temperatures/Temperature.provider.d.ts.map +1 -1
- package/dist/src/Modules/Temperatures/Temperature.provider.js +29 -29
- package/dist/src/Modules/Temperatures/Temperature.provider.js.map +1 -1
- package/dist/src/Modules/Temperatures/Temperatures.provider.d.ts.map +1 -1
- package/dist/src/Modules/Temperatures/Temperatures.provider.js +18 -17
- package/dist/src/Modules/Temperatures/Temperatures.provider.js.map +1 -1
- package/dist/src/Modules/Temperatures/Temperatures.store.d.ts.map +1 -1
- package/dist/src/Modules/Temperatures/Temperatures.store.js +7 -10
- package/dist/src/Modules/Temperatures/Temperatures.store.js.map +1 -1
- package/dist/src/Modules/Temperatures/index.d.ts +3 -3
- package/dist/src/Modules/Temperatures/index.js +3 -3
- package/dist/src/Modules/Temperatures/index.js.map +1 -1
- package/dist/src/Modules/Theme/Theme.provider.js +6 -6
- package/dist/src/Modules/Theme/Theme.provider.js.map +1 -1
- package/dist/src/Modules/Theme/Theme.store.d.ts.map +1 -1
- package/dist/src/Modules/Theme/Theme.store.js +35 -38
- package/dist/src/Modules/Theme/Theme.store.js.map +1 -1
- package/dist/src/Modules/Vebus/Vebus.provider.d.ts.map +1 -1
- package/dist/src/Modules/Vebus/Vebus.provider.js +39 -48
- package/dist/src/Modules/Vebus/Vebus.provider.js.map +1 -1
- package/dist/src/Modules/Vebus/Vebus.store.d.ts.map +1 -1
- package/dist/src/Modules/Vebus/Vebus.store.js +11 -14
- package/dist/src/Modules/Vebus/Vebus.store.js.map +1 -1
- package/dist/src/Modules/Vrm/Vrm.store.d.ts.map +1 -1
- package/dist/src/Modules/Vrm/Vrm.store.js +85 -154
- package/dist/src/Modules/Vrm/Vrm.store.js.map +1 -1
- package/dist/src/Modules/Vrm/Vrm.types.js +0 -1
- package/dist/src/Modules/WindGenerators/WindGenerator.provider.d.ts.map +1 -1
- package/dist/src/Modules/WindGenerators/WindGenerator.provider.js +6 -7
- package/dist/src/Modules/WindGenerators/WindGenerator.provider.js.map +1 -1
- package/dist/src/Modules/WindGenerators/WindGenerators.provider.d.ts.map +1 -1
- package/dist/src/Modules/WindGenerators/WindGenerators.provider.js +21 -19
- package/dist/src/Modules/WindGenerators/WindGenerators.provider.js.map +1 -1
- package/dist/src/Modules/WindGenerators/WindGenerators.store.d.ts.map +1 -1
- package/dist/src/Modules/WindGenerators/WindGenerators.store.js +7 -10
- package/dist/src/Modules/WindGenerators/WindGenerators.store.js.map +1 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/utils/constants.d.ts +53 -3
- package/dist/src/utils/constants.d.ts.map +1 -1
- package/dist/src/utils/constants.js +82 -30
- package/dist/src/utils/constants.js.map +1 -1
- package/dist/src/utils/hsvw.d.ts.map +1 -1
- package/dist/src/utils/hsvw.js +24 -25
- package/dist/src/utils/hsvw.js.map +1 -1
- package/dist/src/utils/logger.d.ts +5 -8
- package/dist/src/utils/logger.d.ts.map +1 -1
- package/dist/src/utils/logger.js +11 -23
- package/dist/src/utils/logger.js.map +1 -1
- package/dist/src/utils/storage.d.ts.map +1 -1
- package/dist/src/utils/storage.js +7 -6
- package/dist/src/utils/storage.js.map +1 -1
- package/dist/src/utils/util.d.ts +6 -15
- package/dist/src/utils/util.d.ts.map +1 -1
- package/dist/src/utils/util.js +8 -100
- package/dist/src/utils/util.js.map +1 -1
- package/package.json +26 -15
- package/dist/eslint.config.d.mts +0 -13
- package/dist/eslint.config.d.mts.map +0 -1
- package/dist/eslint.config.mjs +0 -28
- package/dist/eslint.config.mjs.map +0 -1
- package/dist/src/Modules/ShorePowerInput/ShorePowerInput.store.d.ts +0 -11
- package/dist/src/Modules/ShorePowerInput/ShorePowerInput.store.d.ts.map +0 -1
- package/dist/src/Modules/ShorePowerInput/ShorePowerInput.store.js +0 -37
- package/dist/src/Modules/ShorePowerInput/ShorePowerInput.store.js.map +0 -1
- package/dist/src/Modules/SwitchableOutputs/SwitchableOutput.provider.d.ts.map +0 -1
- package/dist/src/Modules/SwitchableOutputs/SwitchableOutput.provider.js +0 -67
- package/dist/src/Modules/SwitchableOutputs/SwitchableOutput.provider.js.map +0 -1
- package/dist/src/Modules/SwitchableOutputs/SwitchableOutputs.provider.d.ts +0 -2
- package/dist/src/Modules/SwitchableOutputs/SwitchableOutputs.provider.d.ts.map +0 -1
- package/dist/src/Modules/SwitchableOutputs/SwitchableOutputs.provider.js +0 -168
- package/dist/src/Modules/SwitchableOutputs/SwitchableOutputs.provider.js.map +0 -1
- package/dist/src/Modules/SwitchableOutputs/SwitchableOutputs.store.d.ts +0 -38
- package/dist/src/Modules/SwitchableOutputs/SwitchableOutputs.store.d.ts.map +0 -1
- package/dist/src/Modules/SwitchableOutputs/SwitchableOutputs.store.js.map +0 -1
- package/dist/src/Modules/SwitchableOutputs/SwitchingDevice.provider.d.ts.map +0 -1
- package/dist/src/Modules/SwitchableOutputs/SwitchingDevice.provider.js +0 -50
- package/dist/src/Modules/SwitchableOutputs/SwitchingDevice.provider.js.map +0 -1
- package/dist/src/Modules/SwitchableOutputs/SwitchingDevices.store.d.ts.map +0 -1
- package/dist/src/Modules/SwitchableOutputs/SwitchingDevices.store.js.map +0 -1
- package/dist/src/Modules/SwitchableOutputs/index.d.ts +0 -6
- package/dist/src/Modules/SwitchableOutputs/index.d.ts.map +0 -1
- package/dist/src/Modules/SwitchableOutputs/index.js +0 -6
- package/dist/src/Modules/SwitchableOutputs/index.js.map +0 -1
- /package/dist/src/Modules/{SwitchableOutputs → SwitchingPane}/SwitchingDevice.provider.d.ts +0 -0
- /package/dist/src/Modules/{SwitchableOutputs → SwitchingPane}/SwitchingDevices.store.d.ts +0 -0
|
@@ -1 +1 @@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AuDD,UAAU,MAAc;YACtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACtB,CAAC;;;;;;eAED,UAAS,KAA8B;YACrC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QACpB,CAAC;;IA6LH,gBAAC;AAAD,CAAC,AAzaD,IAyaC;;AAED;;;;;;;;;;GAUG;AACH,SAAS,SAAS,CAAC,IAAY,EAAE,CAAS,EAAE,QAAgB;IAC1D,OAAO,IAAI,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;AAC3C,CAAC;AAED,SAAS,eAAe;IACtB,IAAM,MAAM,GAAG,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,IAAI,SAAS,EAAE,CAAA;IACvC,4CAA4C;IAC5C,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO,MAAM,CAAA;IAChD,sCAAsC;IACtC,IAAI,CAAC,KAAK;QAAE,KAAK,GAAG,MAAM,CAAA;IAE1B,OAAO,MAAM,CAAA;AACf,CAAC;AAED,MAAM,UAAU,OAAO;IACrB,OAAO,OAAO,CAAC,cAAM,OAAA,eAAe,EAAE,EAAjB,CAAiB,EAAE,EAAE,CAAC,CAAA;AAC7C,CAAC","sourcesContent":["import { comparer, makeAutoObservable, runInAction } from \"mobx\"\nimport { computedFn } from \"mobx-utils\"\nimport * as mqtt from \"mqtt\"\nimport { IClientPublishOptions, MqttClient } from \"mqtt\"\nimport { MqttMessage, MqttMessages, PortalId, STATUS, Topics } from \"../Mqtt\"\nimport Logger from \"../../utils/logger\"\nimport { getMessageJson } from \"../../utils/util\"\nimport { useMemo } from \"react\"\nimport { assign } from \"lodash-es\"\n\nlet store: MqttStore\n\nexport class MqttStore {\n client?: MqttClient | null\n error?: object | null | boolean\n status: string = STATUS.CONNECTING\n messages: MqttMessages = {}\n messageQueue: MqttMessages = {}\n topicsSubscribed: Set<string> = new Set<string>()\n portalId: PortalId\n uniqueId: string = Math.random().toString(16).substr(2, 8)\n keepAliveHandlerRef: any\n queueWorker: any\n meanQueueWorkerPassDuration: number = 0\n urgentTopicPrefixes: string[] = []\n\n /**\n * Returns the current cached message for a given MQTT topic.\n *\n * React Components using this method will re-render when their specific\n * topic's message changes.\n *\n * Using comparer.identity will trigger the re-renders any time\n * a message arrives for the given topic. We rely on the fact\n * that MQTT will only re-send a message when the value changes,\n * or on a full keep alive.\n *\n * Note: Receiving the same message for a given topic will cause re-renders,\n * as we do not check structural identity of the message.\n *\n * @param topic - The MQTT topic to retrieve the message for\n * @returns The message object for the topic, or undefined if topic is not provided or not found\n */\n messageFromTopic = computedFn(\n (topic?: string) => {\n // Logger.log(`DEBUG: messageFromTopic: ${JSON.stringify(topic)}`)\n // trace()\n return topic ? this.messages[topic] : undefined\n },\n { name: \"Mqtt.store.messageFromTopic\", equals: comparer.identity }\n )\n\n /**\n * Returns the current cached messages for a given set of MQTT topics.\n *\n * This is a memoized computed function - each set of topics has its own cached value.\n *\n * React Components using this method will re-render when\n * any of the messages for specified topics change.\n *\n * Using comparer.identity will trigger the re-renders any time\n * a message arrives for any of the specified topics. We rely on the fact\n * that MQTT will only re-send a message when the value changes,\n * or on a full keep alive.\n\n * Note: Receiving the same message for a given topic will cause re-renders,\n * as we do not check structural identity of the message.\n *\n * @param topics - The MQTT topics to retrieve the messages for\n * @returns The messages objects for the given topics, or empty dictionary if topics not found\n */\n messagesByTopics = computedFn(\n (topics?: Topics) => {\n // Logger.log(`DEBUG: messagesByTopics: ${JSON.stringify(topics)}`)\n // trace()\n if (!topics) {\n return {}\n }\n\n const result: { [key: string]: MqttMessage | MqttMessage[] } = {}\n\n Object.entries(topics).forEach(([label, topic]) => {\n if (Array.isArray(topic)) {\n result[label] = topic.map((t) => this.messageFromTopic(t))\n } else if (topic === undefined) {\n result[label] = undefined\n } else {\n result[label] = this.messageFromTopic(topic)\n }\n })\n\n return result\n },\n { name: \"Mqtt.store.messagesByTopics\", equals: comparer.identity }\n )\n\n /**\n * Returns the current cached messages for MQTT topics specified via regex.\n *\n * React Components using this method will re-render when\n * values of any of the matched topics change. The components also re-render\n * when new MQTT topics are received and match needs to be checked.\n *\n * Using comparer.identity will trigger the re-renders any time\n * a message arrives for any of the matched topics. We rely on the fact\n * that MQTT will only re-send a message when the value changes,\n * or on a full keep alive.\n *\n * Note: Receiving the same message for a given topic will cause re-renders,\n * as we do not check structural identity of the message.\n *\n * @param wildcard - The MQTT wildcard to retrieve the message for\n * @returns The messages objects for the given topics, or empty dictionary if topics not found\n */\n messagesByWildcard = computedFn(\n (wildcard?: string) => {\n // Logger.log(`DEBUG: messagesByWildcard: ${JSON.stringify(wildcard)}`)\n // trace()\n if (wildcard === undefined || wildcard === \"\" || wildcard === null) return {}\n\n const topicRegex = new RegExp(wildcard.replace(/\\+/g, \"\\\\w*\")) // + in mqtt is anything -> .*\n\n return Object.fromEntries(\n Object.keys(this.messages)\n .filter((topic) => topic.match(topicRegex))\n .map((topic) => [topic, this.messages[topic]])\n // Filter out empty results\n .filter(\n ([_, message]) =>\n message !== undefined &&\n message !== null &&\n (!Array.isArray(message) ||\n (message.length !== 0 && !message.every((v) => v === undefined || v === null)))\n )\n )\n },\n { name: \"Mqtt.store.messagesByWildcard\", equals: comparer.identity }\n )\n\n constructor() {\n makeAutoObservable(this, {\n messageQueue: false,\n urgentTopicPrefixes: false,\n setupKeepaliveTimer: false,\n clearKeepaliveTimer: false,\n sendFullKeepalive: false,\n sendSuppressedKeepalive: false,\n setupQueueWorker: false,\n removeQueueWorker: false,\n scheduleNextQueueWorkerPass: false,\n subscribeToTopic: false,\n subscribeToAllTopics: false,\n clearSubscribedTopics: false,\n })\n }\n\n get isConnected() {\n return this.status === STATUS.CONNECTED\n }\n\n subscribeToTopic = (topic?: string) => {\n if (!topic) return\n if (topic.includes(\"undefined\")) return\n\n if (!this.topicsSubscribed.has(topic)) {\n Logger.log(`Subscribing to ${topic}`)\n this.client?.subscribe(topic, (err, granted) => {\n if (err) {\n Logger.error(err)\n return\n }\n\n granted !== undefined && granted[0]\n ? Logger.log(`Subscribed to ${granted[0].topic} with Qos ${granted[0].qos}`)\n : Logger.log(`Subscribed to ${topic} with Qos unknown`)\n })\n\n this.topicsSubscribed.add(topic)\n }\n }\n\n clearSubscribedTopics() {\n this.topicsSubscribed.clear()\n this.urgentTopicPrefixes = []\n runInAction(() => {\n this.portalId = undefined\n })\n }\n\n addMessage = (topic: string, message: { value: string | null }) => {\n // Logger.log(`DEBUG: addMessage: topic: ${topic}, urgentPrefixes: ${JSON.stringify(this.urgentTopicPrefixes)}`)\n if (this.urgentTopicPrefixes.some((prefix) => topic.startsWith(prefix))) {\n // NOTE: If topic starts with one of the urgent prefixes, deliver it immediately\n this.messages[topic] = message.value ?? undefined\n } else {\n // NOTE: Otherwise store message to the queue, and move messages from the queue\n // NOTE: to the React components that are MobX observers periodically and in batches\n this.messageQueue[topic] = message.value ?? undefined\n }\n }\n\n addMessagesFromQueue = () => {\n if (Object.values(this.messageQueue).length > 0) {\n // Logger.log(`DEBUG: addMessagesFromQueue: in queue: ${JSON.stringify(Object.values(this.messageQueue).length)}`)\n assign(this.messages, this.messageQueue)\n // Logger.log(`DEBUG: addMessagesFromQueue: to process: ${JSON.stringify(Object.values(this.messages).length)}`)\n this.messageQueue = {}\n }\n }\n\n scheduleNextQueueWorkerPass = (timeout: number) => {\n this.queueWorker = setTimeout(() => {\n const started = performance.now()\n this.addMessagesFromQueue()\n const ended = performance.now()\n this.meanQueueWorkerPassDuration = addToMean(this.meanQueueWorkerPassDuration, 10, ended - started)\n // Schedule next update after 1 - 3 seconds\n // depending on how fast we were able to process the incoming messages\n const newTimeout = Math.max(1000, Math.min(this.meanQueueWorkerPassDuration * 50, 3000))\n this.scheduleNextQueueWorkerPass(newTimeout)\n }, timeout)\n }\n\n setupQueueWorker = () => {\n this.removeQueueWorker()\n\n this.meanQueueWorkerPassDuration = 20 // ms\n this.scheduleNextQueueWorkerPass(1000) // ms\n }\n\n removeQueueWorker = () => {\n if (this.queueWorker) {\n clearInterval(this.queueWorker)\n }\n this.queueWorker = undefined\n }\n\n setPortalId = (portalId: string) => {\n this.portalId = portalId\n this.urgentTopicPrefixes = [`N/${portalId}/switch/`, `N/${portalId}/system/0/SwitchableOutput`]\n }\n\n setStatus(status: string) {\n this.status = status\n }\n\n setError(error: object | null | boolean) {\n this.error = error\n }\n\n boot = (\n protocol: string,\n host: string = \"localhost\",\n port: number | null,\n path: string = \"websocket-mqtt\",\n remote: boolean = false,\n portalId?: string\n ) => {\n Logger.log(\"MQTT booting\")\n\n let client = this.client\n\n if (client) {\n client.end(true)\n this.client = undefined\n this.portalId = undefined\n this.topicsSubscribed = new Set<string>()\n this.urgentTopicPrefixes = []\n }\n\n let url\n if (remote) {\n if (!host) {\n return\n }\n // remote connection to VRM broker always uses MQTTS over 443\n url = `mqtts://${host}:443`\n } else {\n // local connection derives websocket protocol from web app protocol\n const wsproto = protocol === \"https:\" ? \"wss:\" : \"ws:\"\n if (port) {\n url = `${wsproto}//${host}:${port}/${path}`\n } else {\n url = `${wsproto}//${host}/${path}`\n }\n }\n\n Logger.log(`MQTT connecting to ${url}`)\n client = mqtt.connect(url, { resubscribe: false })\n\n this.client = client\n this.portalId = portalId\n\n client.on(\"error\", (error) => {\n Logger.log(\"MQTT error\")\n runInAction(() => {\n this.setError(error)\n this.setStatus(STATUS.DISCONNECTED)\n })\n this.removeQueueWorker()\n this.clearKeepaliveTimer()\n this.clearSubscribedTopics()\n })\n\n client.on(\"offline\", () => {\n Logger.log(\"MQTT offline\")\n runInAction(() => {\n this.setError(true)\n this.setStatus(STATUS.OFFLINE)\n })\n this.removeQueueWorker()\n this.clearKeepaliveTimer()\n this.clearSubscribedTopics()\n })\n\n client.on(\"connect\", () => {\n Logger.log(\"MQTT connected\")\n runInAction(() => {\n this.setError(null)\n this.setStatus(STATUS.CONNECTED)\n // Never use wildcard when connecting remotely\n this.subscribeToTopic(`N/${remote ? portalId : \"+\"}/system/0/Serial`)\n this.setupKeepaliveTimer()\n })\n })\n\n client.on(\"message\", (topic, message) => {\n // Logger.log(`DEBUG: Message received: ${topic} - ${message.toString()}`)\n\n if (topic.endsWith(\"/system/0/Serial\") && !this.portalId) {\n const portalId = getMessageJson(message).value\n\n if (this.portalId !== portalId && portalId !== undefined) {\n this.setPortalId(portalId)\n }\n\n runInAction(() => this.subscribeToAllTopics())\n }\n if (topic.endsWith(\"full_publish_completed\")) {\n const uniqueId = getMessageJson(message)[\"full-publish-completed-echo\"] || \"\"\n Logger.log(\n `Received full_publish_completed for ${this.portalId} with full-publish-completed-echo: '${uniqueId}'`\n )\n if (uniqueId === this.uniqueId) {\n this.addMessagesFromQueue()\n this.setupQueueWorker()\n }\n }\n\n if (message.toString() !== \"\") {\n this.addMessage(topic, getMessageJson(message))\n }\n })\n\n Logger.log(\"MQTT booted\")\n }\n\n subscribeToAllTopics = () => {\n const topics = [\n `N/${this.portalId}/settings/#`,\n `N/${this.portalId}/system/#`,\n `N/${this.portalId}/vebus/#`,\n `N/${this.portalId}/alternator/#`,\n `N/${this.portalId}/battery/#`,\n `N/${this.portalId}/charger/#`,\n `N/${this.portalId}/dcsource/#`,\n `N/${this.portalId}/generator/#`,\n `N/${this.portalId}/genset/#`,\n `N/${this.portalId}/dcgenset/#`,\n `N/${this.portalId}/inverter/#`,\n `N/${this.portalId}/tank/#`,\n `N/${this.portalId}/temperature/#`,\n `N/${this.portalId}/switch/#`,\n `N/${this.portalId}/full_publish_completed`,\n ]\n\n this.client?.subscribe(topics, (err) => {\n if (err) {\n Logger.error(err)\n return\n }\n\n // When we received all topics we send a full keepalive.\n this.sendFullKeepalive()\n })\n }\n\n sendSuppressedKeepalive = () => {\n if (this.portalId) {\n const options = JSON.stringify({ \"keepalive-options\": [\"suppress-republish\"] })\n const topic = `R/${this.portalId}/keepalive`\n\n Logger.log(`Sending keepalive for ${this.portalId} with ${options}`)\n this.client?.publish(topic, options)\n }\n }\n\n sendFullKeepalive = () => {\n if (this.portalId) {\n const topic = `R/${this.portalId}/keepalive`\n\n Logger.log(`Sending first keepalive for ${this.portalId} with full-publish-completed-echo: '${this.uniqueId}'`)\n this.client &&\n this.client?.publish(\n topic,\n `{ \"keepalive-options\" : [ {\"full-publish-completed-echo\": \"${this.uniqueId}\" } ] }`\n )\n }\n }\n\n setupKeepaliveTimer = () => {\n this.clearKeepaliveTimer()\n\n this.keepAliveHandlerRef = setInterval(this.sendSuppressedKeepalive, 30000)\n\n this.sendFullKeepalive()\n }\n\n clearKeepaliveTimer = () => {\n const ref = this.keepAliveHandlerRef\n if (ref) {\n clearInterval(ref)\n }\n this.keepAliveHandlerRef = undefined\n }\n\n publish = (topic: string, data: string | number | { raw: string }, options?: IClientPublishOptions) => {\n if (this.status !== STATUS.CONNECTED || !this.client) {\n Logger.log(\"Could not publish value, not connected to MQTT broker\")\n }\n const message =\n typeof data === \"object\" && data !== null && \"raw\" in data ? data.raw : JSON.stringify({ value: data })\n\n Logger.log(`Publishing to ${topic}: ${message}`)\n\n this.client?.publish(topic, message, options ?? {})\n }\n}\n\n/**\n * Compute mean by providing existing mean, number of samples, and new sample.\n *\n * @param {number} mean current mean\n * @param {number} n number of sampled values\n * @param {number} newValue the sample\n * @returns {number} the new mean\n *\n * @example\n * addToMean(14, 5, 53); // => 20.5\n */\nfunction addToMean(mean: number, n: number, newValue: number): number {\n return mean + (newValue - mean) / (n + 1)\n}\n\nfunction initializeStore() {\n const _store = store ?? new MqttStore()\n // For SSG and SSR always create a new store\n if (typeof window === \"undefined\") return _store\n // Create the store once in the client\n if (!store) store = _store\n\n return _store\n}\n\nexport function useMqtt() {\n return useMemo(() => initializeStore(), [])\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Mqtt.store.js","sourceRoot":"/","sources":["src/Modules/Mqtt/Mqtt.store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,MAAM,CAAA;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CA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AG,MAAM,CAAA;IACtB,CAAC;IAED,QAAQ,CAAC,KAA8B;QACrC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;CA0LF;AAED;;;;;;;;;;GAUG;AACH,SAAS,SAAS,CAAC,IAAY,EAAE,CAAS,EAAE,QAAgB;IAC1D,OAAO,IAAI,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;AAC3C,CAAC;AAED,SAAS,eAAe;IACtB,MAAM,MAAM,GAAG,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,IAAI,SAAS,EAAE,CAAA;IACvC,4CAA4C;IAC5C,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO,MAAM,CAAA;IAChD,sCAAsC;IACtC,IAAI,CAAC,KAAK;QAAE,KAAK,GAAG,MAAM,CAAA;IAE1B,OAAO,MAAM,CAAA;AACf,CAAC;AAED,MAAM,UAAU,OAAO;IACrB,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC,eAAe,EAAE,EAAE,EAAE,CAAC,CAAA;AAC7C,CAAC","sourcesContent":["import { comparer, makeAutoObservable, runInAction } from \"mobx\"\nimport { computedFn } from \"mobx-utils\"\nimport * as mqtt from \"mqtt\"\nimport { IClientPublishOptions, MqttClient } from \"mqtt\"\nimport { MqttMessage, MqttMessages, PortalId, STATUS, Topics } from \"../Mqtt\"\nimport Logger from \"../../utils/logger\"\nimport { getMessageJson } from \"../../utils/util\"\nimport { useMemo } from \"react\"\nimport { assign } from \"lodash-es\"\n\nlet store: MqttStore\n\nexport class MqttStore {\n client?: MqttClient | null\n error?: object | null | boolean\n status: string = STATUS.CONNECTING\n messages: MqttMessages = {}\n messageQueue: MqttMessages = {}\n topicsSubscribed: Set<string> = new Set<string>()\n portalId: PortalId\n uniqueId: string = Math.random().toString(16).substr(2, 8)\n keepAliveHandlerRef: ReturnType<typeof setInterval> | undefined\n queueWorker: ReturnType<typeof setTimeout> | undefined\n meanQueueWorkerPassDuration: number = 0\n urgentTopicPrefixes: string[] = []\n\n /**\n * Returns the current cached message for a given MQTT topic.\n *\n * React Components using this method will re-render when their specific\n * topic's message changes.\n *\n * Using comparer.identity will trigger the re-renders any time\n * a message arrives for the given topic. We rely on the fact\n * that MQTT will only re-send a message when the value changes,\n * or on a full keep alive.\n *\n * Note: Receiving the same message for a given topic will cause re-renders,\n * as we do not check structural identity of the message.\n *\n * @param topic - The MQTT topic to retrieve the message for\n * @returns The message object for the topic, or undefined if topic is not provided or not found\n */\n messageFromTopic = computedFn(\n (topic?: string) => {\n // Logger.log(`DEBUG: messageFromTopic: ${JSON.stringify(topic)}`)\n // trace()\n return topic ? this.messages[topic] : undefined\n },\n { name: \"Mqtt.store.messageFromTopic\", equals: comparer.identity }\n )\n\n /**\n * Returns the current cached messages for a given set of MQTT topics.\n *\n * This is a memoized computed function - each set of topics has its own cached value.\n *\n * React Components using this method will re-render when\n * any of the messages for specified topics change.\n *\n * Using comparer.identity will trigger the re-renders any time\n * a message arrives for any of the specified topics. We rely on the fact\n * that MQTT will only re-send a message when the value changes,\n * or on a full keep alive.\n\n * Note: Receiving the same message for a given topic will cause re-renders,\n * as we do not check structural identity of the message.\n *\n * @param topics - The MQTT topics to retrieve the messages for\n * @returns The messages objects for the given topics, or empty dictionary if topics not found\n */\n messagesByTopics = computedFn(\n (topics?: Topics) => {\n // Logger.log(`DEBUG: messagesByTopics: ${JSON.stringify(topics)}`)\n // trace()\n if (!topics) {\n return {}\n }\n\n const result: { [key: string]: MqttMessage | MqttMessage[] } = {}\n\n Object.entries(topics).forEach(([label, topic]) => {\n if (Array.isArray(topic)) {\n result[label] = topic.map((t) => this.messageFromTopic(t))\n } else if (topic === undefined) {\n result[label] = undefined\n } else {\n result[label] = this.messageFromTopic(topic)\n }\n })\n\n return result\n },\n { name: \"Mqtt.store.messagesByTopics\", equals: comparer.identity }\n )\n\n /**\n * Returns the current cached messages for MQTT topics specified via regex.\n *\n * React Components using this method will re-render when\n * values of any of the matched topics change. The components also re-render\n * when new MQTT topics are received and match needs to be checked.\n *\n * Using comparer.identity will trigger the re-renders any time\n * a message arrives for any of the matched topics. We rely on the fact\n * that MQTT will only re-send a message when the value changes,\n * or on a full keep alive.\n *\n * Note: Receiving the same message for a given topic will cause re-renders,\n * as we do not check structural identity of the message.\n *\n * @param wildcard - The MQTT wildcard to retrieve the message for\n * @returns The messages objects for the given topics, or empty dictionary if topics not found\n */\n messagesByWildcard = computedFn(\n (wildcard?: string) => {\n // Logger.log(`DEBUG: messagesByWildcard: ${JSON.stringify(wildcard)}`)\n // trace()\n if (wildcard === undefined || wildcard === \"\" || wildcard === null) return {}\n\n const topicRegex = new RegExp(wildcard.replace(/\\+/g, \"\\\\w*\")) // + in mqtt is anything -> .*\n\n return Object.fromEntries(\n Object.keys(this.messages)\n .filter((topic) => topic.match(topicRegex))\n .map((topic) => [topic, this.messages[topic]])\n // Filter out empty results\n .filter(\n ([_key, message]) =>\n message !== undefined &&\n message !== null &&\n (!Array.isArray(message) ||\n (message.length !== 0 && !message.every((v) => v === undefined || v === null)))\n )\n )\n },\n { name: \"Mqtt.store.messagesByWildcard\", equals: comparer.identity }\n )\n\n constructor() {\n makeAutoObservable(this, {\n messageQueue: false,\n urgentTopicPrefixes: false,\n setupKeepaliveTimer: false,\n clearKeepaliveTimer: false,\n sendFullKeepalive: false,\n sendSuppressedKeepalive: false,\n setupQueueWorker: false,\n removeQueueWorker: false,\n scheduleNextQueueWorkerPass: false,\n subscribeToTopic: false,\n subscribeToAllTopics: false,\n clearSubscribedTopics: false,\n })\n }\n\n get isConnected() {\n return this.status === STATUS.CONNECTED\n }\n\n subscribeToTopic = (topic?: string) => {\n if (!topic) return\n if (topic.includes(\"undefined\")) return\n\n if (!this.topicsSubscribed.has(topic)) {\n Logger.log(`Subscribing to ${topic}`)\n this.client?.subscribe(topic, (err, granted) => {\n if (err) {\n Logger.error(err)\n return\n }\n\n if (granted !== undefined && granted[0]) {\n Logger.log(`Subscribed to ${granted[0].topic} with Qos ${granted[0].qos}`)\n } else {\n Logger.log(`Subscribed to ${topic} with Qos unknown`)\n }\n })\n\n this.topicsSubscribed.add(topic)\n }\n }\n\n clearSubscribedTopics() {\n this.topicsSubscribed.clear()\n this.urgentTopicPrefixes = []\n runInAction(() => {\n this.portalId = undefined\n })\n }\n\n addMessage = (topic: string, message: { value: string | undefined }) => {\n // Logger.log(`DEBUG: addMessage: topic: ${topic}, urgentPrefixes: ${JSON.stringify(this.urgentTopicPrefixes)}`)\n if (this.urgentTopicPrefixes.some((prefix) => topic.startsWith(prefix))) {\n // NOTE: If topic starts with one of the urgent prefixes, deliver it immediately\n this.messages[topic] = message.value\n } else {\n // NOTE: Otherwise store message to the queue, and move messages from the queue\n // NOTE: to the React components that are MobX observers periodically and in batches\n this.messageQueue[topic] = message.value\n }\n }\n\n addMessagesFromQueue = () => {\n if (Object.values(this.messageQueue).length > 0) {\n // Logger.log(`DEBUG: addMessagesFromQueue: in queue: ${JSON.stringify(Object.values(this.messageQueue).length)}`)\n assign(this.messages, this.messageQueue)\n // Logger.log(`DEBUG: addMessagesFromQueue: to process: ${JSON.stringify(Object.values(this.messages).length)}`)\n this.messageQueue = {}\n }\n }\n\n scheduleNextQueueWorkerPass = (timeout: number) => {\n this.queueWorker = setTimeout(() => {\n const started = performance.now()\n this.addMessagesFromQueue()\n const ended = performance.now()\n this.meanQueueWorkerPassDuration = addToMean(this.meanQueueWorkerPassDuration, 10, ended - started)\n // Schedule next update after 1 - 3 seconds\n // depending on how fast we were able to process the incoming messages\n const newTimeout = Math.max(1000, Math.min(this.meanQueueWorkerPassDuration * 50, 3000))\n this.scheduleNextQueueWorkerPass(newTimeout)\n }, timeout)\n }\n\n setupQueueWorker = () => {\n this.removeQueueWorker()\n\n this.meanQueueWorkerPassDuration = 20 // ms\n this.scheduleNextQueueWorkerPass(1000) // ms\n }\n\n removeQueueWorker = () => {\n if (this.queueWorker) {\n clearTimeout(this.queueWorker)\n }\n this.queueWorker = undefined\n }\n\n setPortalId = (portalId: string) => {\n this.portalId = portalId\n this.urgentTopicPrefixes = [\n `N/${portalId}/switch/`,\n `N/${portalId}/system/0/SwitchableOutput`,\n `N/${portalId}/system/0/GenericInput`,\n ]\n }\n\n setStatus(status: string) {\n this.status = status\n }\n\n setError(error: object | null | boolean) {\n this.error = error\n }\n\n boot = (\n protocol: string,\n host: string = \"localhost\",\n port: number | null,\n path: string = \"websocket-mqtt\",\n remote: boolean = false,\n portalId?: string\n ) => {\n Logger.log(\"MQTT booting\")\n\n let client = this.client\n\n if (client) {\n client.end(true)\n this.client = undefined\n this.portalId = undefined\n this.topicsSubscribed = new Set<string>()\n this.urgentTopicPrefixes = []\n }\n\n let url\n if (remote) {\n if (!host) {\n return\n }\n // remote connection to VRM broker always uses MQTTS over 443\n url = `mqtts://${host}:443`\n } else {\n // local connection derives websocket protocol from web app protocol\n const wsproto = protocol === \"https:\" ? \"wss:\" : \"ws:\"\n if (port) {\n url = `${wsproto}//${host}:${port}/${path}`\n } else {\n url = `${wsproto}//${host}/${path}`\n }\n }\n\n Logger.log(`MQTT connecting to ${url}`)\n client = mqtt.connect(url, { resubscribe: false })\n\n this.client = client\n this.portalId = portalId\n\n client.on(\"error\", (error) => {\n Logger.log(\"MQTT error\")\n runInAction(() => {\n this.setError(error)\n this.setStatus(STATUS.DISCONNECTED)\n })\n this.removeQueueWorker()\n this.clearKeepaliveTimer()\n this.clearSubscribedTopics()\n })\n\n client.on(\"offline\", () => {\n Logger.log(\"MQTT offline\")\n runInAction(() => {\n this.setError(true)\n this.setStatus(STATUS.OFFLINE)\n })\n this.removeQueueWorker()\n this.clearKeepaliveTimer()\n this.clearSubscribedTopics()\n })\n\n client.on(\"connect\", () => {\n Logger.log(\"MQTT connected\")\n runInAction(() => {\n this.setError(null)\n this.setStatus(STATUS.CONNECTED)\n // Never use wildcard when connecting remotely\n this.subscribeToTopic(`N/${remote ? portalId : \"+\"}/system/0/Serial`)\n this.setupKeepaliveTimer()\n })\n })\n\n client.on(\"message\", (topic, message) => {\n // Logger.log(`DEBUG: Message received: ${topic} - ${message.toString()}`)\n\n if (topic.endsWith(\"/system/0/Serial\") && !this.portalId) {\n const portalId = getMessageJson(message).value\n\n if (this.portalId !== portalId && portalId !== undefined) {\n this.setPortalId(portalId)\n }\n\n runInAction(() => this.subscribeToAllTopics())\n }\n if (topic.endsWith(\"full_publish_completed\")) {\n const uniqueId = getMessageJson(message)[\"full-publish-completed-echo\"] || \"\"\n Logger.log(\n `Received full_publish_completed for ${this.portalId} with full-publish-completed-echo: '${uniqueId}'`\n )\n if (uniqueId === this.uniqueId) {\n this.addMessagesFromQueue()\n this.setupQueueWorker()\n }\n }\n\n if (message.toString() !== \"\") {\n this.addMessage(topic, getMessageJson(message))\n }\n })\n\n Logger.log(\"MQTT booted\")\n }\n\n subscribeToAllTopics = () => {\n const topics = [\n `N/${this.portalId}/settings/#`,\n `N/${this.portalId}/system/#`,\n `N/${this.portalId}/vebus/#`,\n `N/${this.portalId}/alternator/#`,\n `N/${this.portalId}/battery/#`,\n `N/${this.portalId}/charger/#`,\n `N/${this.portalId}/dcsource/#`,\n `N/${this.portalId}/generator/#`,\n `N/${this.portalId}/genset/#`,\n `N/${this.portalId}/dcgenset/#`,\n `N/${this.portalId}/inverter/#`,\n `N/${this.portalId}/tank/#`,\n `N/${this.portalId}/temperature/#`,\n `N/${this.portalId}/switch/#`,\n `N/${this.portalId}/full_publish_completed`,\n ]\n\n this.client?.subscribe(topics, (err) => {\n if (err) {\n Logger.error(err)\n return\n }\n\n // When we received all topics we send a full keepalive.\n this.sendFullKeepalive()\n })\n }\n\n sendSuppressedKeepalive = () => {\n if (this.portalId) {\n const options = JSON.stringify({ \"keepalive-options\": [\"suppress-republish\"] })\n const topic = `R/${this.portalId}/keepalive`\n\n Logger.log(`Sending keepalive for ${this.portalId} with ${options}`)\n this.client?.publish(topic, options)\n }\n }\n\n sendFullKeepalive = () => {\n if (this.portalId) {\n const topic = `R/${this.portalId}/keepalive`\n\n Logger.log(`Sending first keepalive for ${this.portalId} with full-publish-completed-echo: '${this.uniqueId}'`)\n this.client?.publish(topic, `{ \"keepalive-options\" : [ {\"full-publish-completed-echo\": \"${this.uniqueId}\" } ] }`)\n }\n }\n\n setupKeepaliveTimer = () => {\n this.clearKeepaliveTimer()\n\n this.keepAliveHandlerRef = setInterval(this.sendSuppressedKeepalive, 30000)\n\n this.sendFullKeepalive()\n }\n\n clearKeepaliveTimer = () => {\n const ref = this.keepAliveHandlerRef\n if (ref) {\n clearInterval(ref)\n }\n this.keepAliveHandlerRef = undefined\n }\n\n publish = (topic: string, data: string | number | { raw: string }, options?: IClientPublishOptions) => {\n if (this.status !== STATUS.CONNECTED || !this.client) {\n Logger.log(\"Could not publish value, not connected to MQTT broker\")\n return\n }\n const message =\n typeof data === \"object\" && data !== null && \"raw\" in data ? data.raw : JSON.stringify({ value: data })\n\n Logger.log(`Publishing to ${topic}: ${message}`)\n\n this.client?.publish(topic, message, options ?? {})\n }\n}\n\n/**\n * Compute mean by providing existing mean, number of samples, and new sample.\n *\n * @param {number} mean current mean\n * @param {number} n number of sampled values\n * @param {number} newValue the sample\n * @returns {number} the new mean\n *\n * @example\n * addToMean(14, 5, 53); // => 20.5\n */\nfunction addToMean(mean: number, n: number, newValue: number): number {\n return mean + (newValue - mean) / (n + 1)\n}\n\nfunction initializeStore() {\n const _store = store ?? new MqttStore()\n // For SSG and SSR always create a new store\n if (typeof window === \"undefined\") return _store\n // Create the store once in the client\n if (!store) store = _store\n\n return _store\n}\n\nexport function useMqtt() {\n return useMemo(() => initializeStore(), [])\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Mqtt.types.d.ts","sourceRoot":"/","sources":["src/Modules/Mqtt/Mqtt.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,
|
|
1
|
+
{"version":3,"file":"Mqtt.types.d.ts","sourceRoot":"/","sources":["src/Modules/Mqtt/Mqtt.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,SAAS,CAAA;AAC5C,MAAM,MAAM,YAAY,GAAG;IAAE,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,CAAA;CAAE,CAAA;AAC3D,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;AAChD,MAAM,MAAM,MAAM,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAA;CAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Mqtt.types.js","sourceRoot":"/","sources":["src/Modules/Mqtt/Mqtt.types.ts"],"names":[],"mappings":"","sourcesContent":["export type MqttMessage = string |
|
|
1
|
+
{"version":3,"file":"Mqtt.types.js","sourceRoot":"/","sources":["src/Modules/Mqtt/Mqtt.types.ts"],"names":[],"mappings":"","sourcesContent":["export type MqttMessage = string | undefined\nexport type MqttMessages = { [topic: string]: MqttMessage }\nexport type PortalId = string | null | undefined\nexport type Topics = { [key: string]: string | string[] | undefined }\n"]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { useMqtt, useTopicsState } from "../Mqtt";
|
|
2
2
|
import { useMemo } from "react";
|
|
3
3
|
export function usePvCharger() {
|
|
4
|
-
|
|
5
|
-
power:
|
|
6
|
-
current:
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return { power
|
|
4
|
+
const getTopics = (portalId) => ({
|
|
5
|
+
power: `N/${portalId}/system/0/Dc/Pv/Power`,
|
|
6
|
+
current: `N/${portalId}/system/0/Dc/Pv/Current`,
|
|
7
|
+
});
|
|
8
|
+
const { portalId } = useMqtt();
|
|
9
|
+
const topics = useMemo(() => getTopics(portalId), [portalId]);
|
|
10
|
+
const { power, current } = useTopicsState(topics);
|
|
11
|
+
return { power, current };
|
|
12
12
|
}
|
|
13
13
|
//# sourceMappingURL=PvCharger.provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PvCharger.provider.js","sourceRoot":"/","sources":["src/Modules/PvCharger/PvCharger.provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAY/B,MAAM,UAAU,YAAY;IAC1B,
|
|
1
|
+
{"version":3,"file":"PvCharger.provider.js","sourceRoot":"/","sources":["src/Modules/PvCharger/PvCharger.provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAY/B,MAAM,UAAU,YAAY;IAC1B,MAAM,SAAS,GAAG,CAAC,QAAkB,EAAE,EAAE,CAAC,CAAC;QACzC,KAAK,EAAE,KAAK,QAAQ,uBAAuB;QAC3C,OAAO,EAAE,KAAK,QAAQ,yBAAyB;KAChD,CAAC,CAAA;IAEF,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,EAAE,CAAA;IAC9B,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAA;IAE7D,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,cAAc,CAAiB,MAAM,CAAC,CAAA;IAEjE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAA;AAC3B,CAAC","sourcesContent":["import { PortalId, Topics, useMqtt, useTopicsState } from \"../Mqtt\"\nimport { useMemo } from \"react\"\n\nexport interface PvChargerState {\n current: number\n power: number\n}\n\nexport interface PvChargerTopics extends Topics {\n current?: string\n power?: string\n}\n\nexport function usePvCharger(): PvChargerState {\n const getTopics = (portalId: PortalId) => ({\n power: `N/${portalId}/system/0/Dc/Pv/Power`,\n current: `N/${portalId}/system/0/Dc/Pv/Current`,\n })\n\n const { portalId } = useMqtt()\n const topics = useMemo(() => getTopics(portalId), [portalId])\n\n const { power, current } = useTopicsState<PvChargerState>(topics)\n\n return { power, current }\n}\n"]}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
export type ShorePowerInputId = number | null | undefined;
|
|
2
|
+
export interface ShorePowerInputState {
|
|
3
|
+
inputId: ShorePowerInputId;
|
|
4
|
+
}
|
|
2
5
|
export declare function useShorePowerInput(): ShorePowerInputState;
|
|
3
6
|
//# sourceMappingURL=ShorePowerInput.provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShorePowerInput.provider.d.ts","sourceRoot":"/","sources":["src/Modules/ShorePowerInput/ShorePowerInput.provider.ts"],"names":[],"mappings":"AAGA,
|
|
1
|
+
{"version":3,"file":"ShorePowerInput.provider.d.ts","sourceRoot":"/","sources":["src/Modules/ShorePowerInput/ShorePowerInput.provider.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;AAEzD,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,iBAAiB,CAAA;CAC3B;AAuBD,wBAAgB,kBAAkB,IAAI,oBAAoB,CAczD"}
|
|
@@ -1,39 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useMqtt } from "../Mqtt";
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { useMqtt, useTopicsState } from "../Mqtt";
|
|
3
3
|
import { AC_SOURCE_TYPE } from "../../utils/constants";
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
function deriveInputId(acInput1, acInput2) {
|
|
5
|
+
if (acInput1 && (Number(acInput1) === AC_SOURCE_TYPE.SHORE || Number(acInput1) === AC_SOURCE_TYPE.GRID)) {
|
|
6
|
+
return 1;
|
|
7
|
+
}
|
|
8
|
+
if (acInput2 && (Number(acInput2) === AC_SOURCE_TYPE.SHORE || Number(acInput2) === AC_SOURCE_TYPE.GRID)) {
|
|
9
|
+
return 2;
|
|
10
|
+
}
|
|
11
|
+
if (acInput1 && Number(acInput1) !== AC_SOURCE_TYPE.NOT_IN_USE) {
|
|
12
|
+
return 1;
|
|
13
|
+
}
|
|
14
|
+
if (acInput2 && Number(acInput2) !== AC_SOURCE_TYPE.NOT_IN_USE) {
|
|
15
|
+
return 2;
|
|
16
|
+
}
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
6
19
|
export function useShorePowerInput() {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
var shorePowerInputStore = useShorePowerInputStore();
|
|
15
|
-
var topics = useMemo(function () { return getTopics(mqtt.portalId); }, [mqtt.portalId]);
|
|
16
|
-
useEffect(function () {
|
|
17
|
-
var dispose = reaction(function () { return mqtt.messagesByTopics(topics); }, function (messages) {
|
|
18
|
-
var acInput1 = messages.acInput1, acInput2 = messages.acInput2;
|
|
19
|
-
var inputId = undefined;
|
|
20
|
-
// prioritize shore and grid inputs first
|
|
21
|
-
if (acInput1 && Number(acInput1) === AC_SOURCE_TYPE.SHORE || Number(acInput1) === AC_SOURCE_TYPE.GRID) {
|
|
22
|
-
inputId = 1;
|
|
23
|
-
}
|
|
24
|
-
else if (acInput2 && (Number(acInput2) === AC_SOURCE_TYPE.SHORE || Number(acInput2) === AC_SOURCE_TYPE.GRID)) {
|
|
25
|
-
inputId = 2;
|
|
26
|
-
}
|
|
27
|
-
else if (acInput1 && Number(acInput1) !== AC_SOURCE_TYPE.NOT_IN_USE) {
|
|
28
|
-
inputId = 1;
|
|
29
|
-
}
|
|
30
|
-
else if (acInput2 && Number(acInput2) !== AC_SOURCE_TYPE.NOT_IN_USE) {
|
|
31
|
-
inputId = 2;
|
|
32
|
-
}
|
|
33
|
-
shorePowerInputStore.setInputId(inputId);
|
|
34
|
-
}, { fireImmediately: true });
|
|
35
|
-
return function () { return dispose(); };
|
|
36
|
-
});
|
|
37
|
-
return { inputId: shorePowerInputStore.inputId };
|
|
20
|
+
const mqtt = useMqtt();
|
|
21
|
+
const topics = useMemo(() => ({
|
|
22
|
+
acInput1: `N/${mqtt.portalId}/settings/0/Settings/SystemSetup/AcInput1`,
|
|
23
|
+
acInput2: `N/${mqtt.portalId}/settings/0/Settings/SystemSetup/AcInput2`,
|
|
24
|
+
}), [mqtt.portalId]);
|
|
25
|
+
const { acInput1, acInput2 } = useTopicsState(topics);
|
|
26
|
+
return { inputId: deriveInputId(acInput1, acInput2) };
|
|
38
27
|
}
|
|
39
28
|
//# sourceMappingURL=ShorePowerInput.provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShorePowerInput.provider.js","sourceRoot":"/","sources":["src/Modules/ShorePowerInput/ShorePowerInput.provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"ShorePowerInput.provider.js","sourceRoot":"/","sources":["src/Modules/ShorePowerInput/ShorePowerInput.provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EAAU,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAYtD,SAAS,aAAa,CAAC,QAAiB,EAAE,QAAiB;IACzD,IAAI,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,cAAc,CAAC,KAAK,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;QACxG,OAAO,CAAC,CAAA;IACV,CAAC;IACD,IAAI,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,cAAc,CAAC,KAAK,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;QACxG,OAAO,CAAC,CAAA;IACV,CAAC;IACD,IAAI,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,cAAc,CAAC,UAAU,EAAE,CAAC;QAC/D,OAAO,CAAC,CAAA;IACV,CAAC;IACD,IAAI,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,cAAc,CAAC,UAAU,EAAE,CAAC;QAC/D,OAAO,CAAC,CAAA;IACV,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AAED,MAAM,UAAU,kBAAkB;IAChC,MAAM,IAAI,GAAG,OAAO,EAAE,CAAA;IAEtB,MAAM,MAAM,GAAG,OAAO,CACpB,GAA0B,EAAE,CAAC,CAAC;QAC5B,QAAQ,EAAE,KAAK,IAAI,CAAC,QAAQ,2CAA2C;QACvE,QAAQ,EAAE,KAAK,IAAI,CAAC,QAAQ,2CAA2C;KACxE,CAAC,EACF,CAAC,IAAI,CAAC,QAAQ,CAAC,CAChB,CAAA;IAED,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,cAAc,CAA2C,MAAM,CAAC,CAAA;IAE/F,OAAO,EAAE,OAAO,EAAE,aAAa,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAA;AACvD,CAAC","sourcesContent":["import { useMemo } from \"react\"\nimport { Topics, useMqtt, useTopicsState } from \"../Mqtt\"\nimport { AC_SOURCE_TYPE } from \"../../utils/constants\"\nexport type ShorePowerInputId = number | null | undefined\n\nexport interface ShorePowerInputState {\n inputId: ShorePowerInputId\n}\n\ninterface ShorePowerInputTopics extends Topics {\n acInput1?: string\n acInput2?: string\n}\n\nfunction deriveInputId(acInput1: unknown, acInput2: unknown): ShorePowerInputId {\n if (acInput1 && (Number(acInput1) === AC_SOURCE_TYPE.SHORE || Number(acInput1) === AC_SOURCE_TYPE.GRID)) {\n return 1\n }\n if (acInput2 && (Number(acInput2) === AC_SOURCE_TYPE.SHORE || Number(acInput2) === AC_SOURCE_TYPE.GRID)) {\n return 2\n }\n if (acInput1 && Number(acInput1) !== AC_SOURCE_TYPE.NOT_IN_USE) {\n return 1\n }\n if (acInput2 && Number(acInput2) !== AC_SOURCE_TYPE.NOT_IN_USE) {\n return 2\n }\n return undefined\n}\n\nexport function useShorePowerInput(): ShorePowerInputState {\n const mqtt = useMqtt()\n\n const topics = useMemo(\n (): ShorePowerInputTopics => ({\n acInput1: `N/${mqtt.portalId}/settings/0/Settings/SystemSetup/AcInput1`,\n acInput2: `N/${mqtt.portalId}/settings/0/Settings/SystemSetup/AcInput2`,\n }),\n [mqtt.portalId]\n )\n\n const { acInput1, acInput2 } = useTopicsState<{ acInput1: unknown; acInput2: unknown }>(topics)\n\n return { inputId: deriveInputId(acInput1, acInput2) }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["src/Modules/ShorePowerInput/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["src/Modules/ShorePowerInput/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["src/Modules/ShorePowerInput/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["src/Modules/ShorePowerInput/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAA","sourcesContent":["export * from \"./ShorePowerInput.provider\"\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { PortalId } from "../Mqtt";
|
|
2
|
+
import { SwitchingDeviceInstanceId } from "./SwitchingDevice.provider";
|
|
3
|
+
import { GenericInputState, SwitchableOutputTree } from "./SwitchableOutput.provider";
|
|
4
|
+
import { GenericInputValidTypesBitmask } from "../../utils/constants";
|
|
5
|
+
export type GenericInputId = string;
|
|
6
|
+
export declare const getGenericInputStateTopics: (portalId: PortalId, tree: SwitchableOutputTree, deviceId: SwitchingDeviceInstanceId, inputId: GenericInputId) => {
|
|
7
|
+
type: string;
|
|
8
|
+
validTypes: string;
|
|
9
|
+
status: string;
|
|
10
|
+
name: string;
|
|
11
|
+
customName: string;
|
|
12
|
+
group: string;
|
|
13
|
+
showUIControl: string;
|
|
14
|
+
value: string;
|
|
15
|
+
event: string;
|
|
16
|
+
unit: string;
|
|
17
|
+
labels: string;
|
|
18
|
+
primaryLabel: string;
|
|
19
|
+
rangeMin: string;
|
|
20
|
+
rangeMax: string;
|
|
21
|
+
decimals: string;
|
|
22
|
+
invert: string;
|
|
23
|
+
digitalInputMode: string;
|
|
24
|
+
};
|
|
25
|
+
export declare function genericInputSupportsType(validType: GenericInputValidTypesBitmask, type: number): boolean;
|
|
26
|
+
export declare function useGenericInput(tree: SwitchableOutputTree, deviceId: SwitchingDeviceInstanceId, inputId: GenericInputId): GenericInputState;
|
|
27
|
+
//# sourceMappingURL=GenericInput.provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GenericInput.provider.d.ts","sourceRoot":"/","sources":["src/Modules/SwitchingPane/GenericInput.provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAA2B,MAAM,SAAS,CAAA;AAE3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAA;AACtE,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AACrF,OAAO,EAAE,6BAA6B,EAAyB,MAAM,uBAAuB,CAAA;AAE5F,MAAM,MAAM,cAAc,GAAG,MAAM,CAAA;AAEnC,eAAO,MAAM,0BAA0B,GACrC,UAAU,QAAQ,EAClB,MAAM,oBAAoB,EAC1B,UAAU,yBAAyB,EACnC,SAAS,cAAc;;;;;;;;;;;;;;;;;;CAmBvB,CAAA;AAEF,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,6BAA6B,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAExG;AAED,wBAAgB,eAAe,CAC7B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,yBAAyB,EACnC,OAAO,EAAE,cAAc,GACtB,iBAAiB,CAenB"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useMqtt, useTopicsState } from "../Mqtt";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { remapGenericInputType } from "../../utils/constants";
|
|
4
|
+
export const getGenericInputStateTopics = (portalId, tree, deviceId, inputId) => ({
|
|
5
|
+
type: `N/${portalId}/${tree}/${deviceId}/GenericInput/${inputId}/Settings/Type`,
|
|
6
|
+
validTypes: `N/${portalId}/${tree}/${deviceId}/GenericInput/${inputId}/Settings/ValidTypes`,
|
|
7
|
+
status: `N/${portalId}/${tree}/${deviceId}/GenericInput/${inputId}/Status`,
|
|
8
|
+
name: `N/${portalId}/${tree}/${deviceId}/GenericInput/${inputId}/Name`,
|
|
9
|
+
customName: `N/${portalId}/${tree}/${deviceId}/GenericInput/${inputId}/Settings/CustomName`,
|
|
10
|
+
group: `N/${portalId}/${tree}/${deviceId}/GenericInput/${inputId}/Settings/Group`,
|
|
11
|
+
showUIControl: `N/${portalId}/${tree}/${deviceId}/GenericInput/${inputId}/Settings/ShowUIInput`,
|
|
12
|
+
value: `N/${portalId}/${tree}/${deviceId}/GenericInput/${inputId}/Value`,
|
|
13
|
+
event: `N/${portalId}/${tree}/${deviceId}/GenericInput/${inputId}/Event`,
|
|
14
|
+
unit: `N/${portalId}/${tree}/${deviceId}/GenericInput/${inputId}/Settings/Unit`,
|
|
15
|
+
labels: `N/${portalId}/${tree}/${deviceId}/GenericInput/${inputId}/Settings/Labels`,
|
|
16
|
+
primaryLabel: `N/${portalId}/${tree}/${deviceId}/GenericInput/${inputId}/Settings/PrimaryLabel`,
|
|
17
|
+
rangeMin: `N/${portalId}/${tree}/${deviceId}/GenericInput/${inputId}/Settings/RangeMin`,
|
|
18
|
+
rangeMax: `N/${portalId}/${tree}/${deviceId}/GenericInput/${inputId}/Settings/RangeMax`,
|
|
19
|
+
decimals: `N/${portalId}/${tree}/${deviceId}/GenericInput/${inputId}/Settings/Decimals`,
|
|
20
|
+
invert: `N/${portalId}/${tree}/${deviceId}/GenericInput/${inputId}/Settings/Invert`,
|
|
21
|
+
digitalInputMode: `N/${portalId}/${tree}/${deviceId}/GenericInput/${inputId}/Settings/DigitalInputMode`,
|
|
22
|
+
});
|
|
23
|
+
export function genericInputSupportsType(validType, type) {
|
|
24
|
+
return (validType & (1 << type)) !== 0;
|
|
25
|
+
}
|
|
26
|
+
export function useGenericInput(tree, deviceId, inputId) {
|
|
27
|
+
const mqtt = useMqtt();
|
|
28
|
+
const topics = useMemo(() => getGenericInputStateTopics(mqtt.portalId, tree, deviceId, inputId), [mqtt.portalId, tree, deviceId, inputId]);
|
|
29
|
+
const state = useTopicsState(topics);
|
|
30
|
+
return Object.assign(Object.assign({}, state), { kind: "genericInput", tree: tree, type: remapGenericInputType(state.type) });
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=GenericInput.provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GenericInput.provider.js","sourceRoot":"/","sources":["src/Modules/SwitchingPane/GenericInput.provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAG/B,OAAO,EAAiC,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAI5F,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACxC,QAAkB,EAClB,IAA0B,EAC1B,QAAmC,EACnC,OAAuB,EACvB,EAAE,CAAC,CAAC;IACJ,IAAI,EAAE,KAAK,QAAQ,IAAI,IAAI,IAAI,QAAQ,iBAAiB,OAAO,gBAAgB;IAC/E,UAAU,EAA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AAQ,iBAAiB,OAAO,4BAA4B;CACxG,CAAC,CAAA;AAEF,MAAM,UAAU,wBAAwB,CAAC,SAAwC,EAAE,IAAY;IAC7F,OAAO,CAAC,SAAS,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,KAAK,CAAC,CAAA;AACxC,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,IAA0B,EAC1B,QAAmC,EACnC,OAAuB;IAEvB,MAAM,IAAI,GAAG,OAAO,EAAE,CAAA;IACtB,MAAM,MAAM,GAAG,OAAO,CACpB,GAAG,EAAE,CAAC,0BAA0B,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,EACxE,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,CACzC,CAAA;IAED,MAAM,KAAK,GAAG,cAAc,CAAoB,MAAM,CAAC,CAAA;IAEvD,uCACK,KAAK,KACR,IAAI,EAAE,cAAc,EACpB,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,qBAAqB,CAAC,KAAK,CAAC,IAAc,CAAC,IAClD;AACH,CAAC","sourcesContent":["import { PortalId, useMqtt, useTopicsState } from \"../Mqtt\"\nimport { useMemo } from \"react\"\nimport { SwitchingDeviceInstanceId } from \"./SwitchingDevice.provider\"\nimport { GenericInputState, SwitchableOutputTree } from \"./SwitchableOutput.provider\"\nimport { GenericInputValidTypesBitmask, remapGenericInputType } from \"../../utils/constants\"\n\nexport type GenericInputId = string\n\nexport const getGenericInputStateTopics = (\n portalId: PortalId,\n tree: SwitchableOutputTree,\n deviceId: SwitchingDeviceInstanceId,\n inputId: GenericInputId\n) => ({\n type: `N/${portalId}/${tree}/${deviceId}/GenericInput/${inputId}/Settings/Type`,\n validTypes: `N/${portalId}/${tree}/${deviceId}/GenericInput/${inputId}/Settings/ValidTypes`,\n status: `N/${portalId}/${tree}/${deviceId}/GenericInput/${inputId}/Status`,\n name: `N/${portalId}/${tree}/${deviceId}/GenericInput/${inputId}/Name`,\n customName: `N/${portalId}/${tree}/${deviceId}/GenericInput/${inputId}/Settings/CustomName`,\n group: `N/${portalId}/${tree}/${deviceId}/GenericInput/${inputId}/Settings/Group`,\n showUIControl: `N/${portalId}/${tree}/${deviceId}/GenericInput/${inputId}/Settings/ShowUIInput`,\n value: `N/${portalId}/${tree}/${deviceId}/GenericInput/${inputId}/Value`,\n event: `N/${portalId}/${tree}/${deviceId}/GenericInput/${inputId}/Event`,\n unit: `N/${portalId}/${tree}/${deviceId}/GenericInput/${inputId}/Settings/Unit`,\n labels: `N/${portalId}/${tree}/${deviceId}/GenericInput/${inputId}/Settings/Labels`,\n primaryLabel: `N/${portalId}/${tree}/${deviceId}/GenericInput/${inputId}/Settings/PrimaryLabel`,\n rangeMin: `N/${portalId}/${tree}/${deviceId}/GenericInput/${inputId}/Settings/RangeMin`,\n rangeMax: `N/${portalId}/${tree}/${deviceId}/GenericInput/${inputId}/Settings/RangeMax`,\n decimals: `N/${portalId}/${tree}/${deviceId}/GenericInput/${inputId}/Settings/Decimals`,\n invert: `N/${portalId}/${tree}/${deviceId}/GenericInput/${inputId}/Settings/Invert`,\n digitalInputMode: `N/${portalId}/${tree}/${deviceId}/GenericInput/${inputId}/Settings/DigitalInputMode`,\n})\n\nexport function genericInputSupportsType(validType: GenericInputValidTypesBitmask, type: number): boolean {\n return (validType & (1 << type)) !== 0\n}\n\nexport function useGenericInput(\n tree: SwitchableOutputTree,\n deviceId: SwitchingDeviceInstanceId,\n inputId: GenericInputId\n): GenericInputState {\n const mqtt = useMqtt()\n const topics = useMemo(\n () => getGenericInputStateTopics(mqtt.portalId, tree, deviceId, inputId),\n [mqtt.portalId, tree, deviceId, inputId]\n )\n\n const state = useTopicsState<GenericInputState>(topics)\n\n return {\n ...state,\n kind: \"genericInput\",\n tree: tree,\n type: remapGenericInputType(state.type as number),\n }\n}\n"]}
|
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
import { PortalId, Topics } from "../Mqtt";
|
|
2
2
|
import { SwitchingDeviceInstanceId } from "./SwitchingDevice.provider";
|
|
3
|
-
import { SwitchableOutputStatus, SwitchableOutputType, SwitchableOutputValidTypesBitmask, SwitchableOutputVisibility } from "../../utils/constants";
|
|
3
|
+
import { GenericInputStatus, GenericInputType, GenericInputValidTypesBitmask, SwitchableOutputStatus, SwitchableOutputType, SwitchableOutputValidTypesBitmask, SwitchableOutputVisibility } from "../../utils/constants";
|
|
4
4
|
import { HSVWColorArray } from "../../utils/hsvw";
|
|
5
5
|
export declare const SWITCHABLE_OUTPUT_TREES: readonly ["system", "switch"];
|
|
6
6
|
export type SwitchableOutputTree = (typeof SWITCHABLE_OUTPUT_TREES)[number];
|
|
7
7
|
export type SwitchableOutputId = string;
|
|
8
8
|
export type SwitchableOutputUnit = string | "/Speed" | "/Temperature" | "/Volume";
|
|
9
|
-
export interface
|
|
9
|
+
export interface SwitchingPaneItemBase {
|
|
10
10
|
tree: SwitchableOutputTree;
|
|
11
11
|
deviceId: SwitchingDeviceInstanceId;
|
|
12
12
|
outputId: SwitchableOutputId;
|
|
13
|
-
type: SwitchableOutputType;
|
|
14
|
-
validTypes: SwitchableOutputValidTypesBitmask;
|
|
15
|
-
status: SwitchableOutputStatus;
|
|
16
13
|
name: string;
|
|
17
14
|
customName: string;
|
|
18
15
|
group: string;
|
|
19
16
|
parentDeviceName: string;
|
|
20
17
|
showUIControl: SwitchableOutputVisibility;
|
|
18
|
+
validTypes: SwitchableOutputValidTypesBitmask | GenericInputValidTypesBitmask;
|
|
19
|
+
unit: SwitchableOutputUnit;
|
|
20
|
+
decimals?: number;
|
|
21
|
+
labels: string;
|
|
22
|
+
}
|
|
23
|
+
export interface SwitchableOutputState extends SwitchingPaneItemBase {
|
|
24
|
+
kind: "switchableOutput";
|
|
25
|
+
type: SwitchableOutputType;
|
|
26
|
+
status: SwitchableOutputStatus;
|
|
21
27
|
auto: 0 | 1;
|
|
22
28
|
state: 0 | 1;
|
|
23
29
|
dimming?: number;
|
|
@@ -25,11 +31,21 @@ export interface SwitchableOutputState {
|
|
|
25
31
|
dimmingMax?: number;
|
|
26
32
|
stepSize?: number;
|
|
27
33
|
measurement?: number;
|
|
28
|
-
unit: SwitchableOutputUnit;
|
|
29
|
-
decimals?: number;
|
|
30
|
-
labels: string;
|
|
31
34
|
lightControls: HSVWColorArray;
|
|
32
35
|
}
|
|
36
|
+
export interface GenericInputState extends SwitchingPaneItemBase {
|
|
37
|
+
kind: "genericInput";
|
|
38
|
+
type: GenericInputType;
|
|
39
|
+
status: GenericInputStatus;
|
|
40
|
+
value?: number | null;
|
|
41
|
+
event?: number;
|
|
42
|
+
primaryLabel?: string;
|
|
43
|
+
rangeMin?: number;
|
|
44
|
+
rangeMax?: number;
|
|
45
|
+
invert?: 0 | 1;
|
|
46
|
+
digitalInputMode?: number;
|
|
47
|
+
}
|
|
48
|
+
export type SwitchingPaneItem = SwitchableOutputState | GenericInputState;
|
|
33
49
|
export interface SwitchableOutputProvider extends SwitchableOutputState {
|
|
34
50
|
updateType: (type: SwitchableOutputType) => void;
|
|
35
51
|
updateAuto: (auto: 0 | 1) => void;
|
|
@@ -56,7 +72,7 @@ export interface SwitchableOutputTopics extends Topics {
|
|
|
56
72
|
unit?: string;
|
|
57
73
|
labels?: string[];
|
|
58
74
|
}
|
|
59
|
-
export declare const
|
|
75
|
+
export declare const getSwitchingPaneItemNameForDisplay: (state: SwitchingPaneItem, switchingDeviceName: string) => string;
|
|
60
76
|
export declare const getSwitchableOutputStateTopics: (portalId: PortalId, tree: SwitchableOutputTree, deviceId: SwitchingDeviceInstanceId, outputId: SwitchableOutputId) => {
|
|
61
77
|
type: string;
|
|
62
78
|
validTypes: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SwitchableOutput.provider.d.ts","sourceRoot":"/","sources":["src/Modules/SwitchingPane/SwitchableOutput.provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAA2B,MA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;IACnB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;CAClB;AAED,eAAO,MAAM,kCAAkC,GAAI,OAAO,iBAAiB,EAAE,qBAAqB,MAAM,WAOvG,CAAA;AAED,eAAO,MAAM,8BAA8B,GACzC,UAAU,QAAQ,EAClB,MAAM,oBAAoB,EAC1B,UAAU,yBAAyB,EACnC,UAAU,kBAAkB;;;;;;;;;;;;;;;;;;;CAoB5B,CAAA;AAEF,eAAO,MAAM,8BAA8B,GACzC,UAAU,QAAQ,EAClB,MAAM,oBAAoB,EAC1B,UAAU,yBAAyB,EACnC,UAAU,kBAAkB;;;;;;CAO5B,CAAA;AAEF,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,yBAAyB,EACnC,QAAQ,EAAE,kBAAkB,GAC3B,wBAAwB,CA2B1B"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { useMqtt, useTopicsState } from "../Mqtt";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { hsvwArrayToJSON } from "../../utils/hsvw";
|
|
4
|
+
export const SWITCHABLE_OUTPUT_TREES = ["system", "switch"];
|
|
5
|
+
export function switchableOutputSupportsType(validType, type) {
|
|
6
|
+
return (validType & (1 << type)) !== 0;
|
|
7
|
+
}
|
|
8
|
+
export const getSwitchingPaneItemNameForDisplay = (state, switchingDeviceName) => {
|
|
9
|
+
// when custom name defined, or group not overriden
|
|
10
|
+
if (state.customName || state.group === "") {
|
|
11
|
+
return state.customName || state.name;
|
|
12
|
+
}
|
|
13
|
+
// otherwise prepend switching device name
|
|
14
|
+
return `${switchingDeviceName} | ${state.name}`;
|
|
15
|
+
};
|
|
16
|
+
export const getSwitchableOutputStateTopics = (portalId, tree, deviceId, outputId) => ({
|
|
17
|
+
type: `N/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/Settings/Type`,
|
|
18
|
+
validTypes: `N/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/Settings/ValidTypes`,
|
|
19
|
+
status: `N/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/Status`,
|
|
20
|
+
name: `N/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/Name`,
|
|
21
|
+
customName: `N/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/Settings/CustomName`,
|
|
22
|
+
group: `N/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/Settings/Group`,
|
|
23
|
+
showUIControl: `N/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/Settings/ShowUIControl`,
|
|
24
|
+
auto: `N/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/Auto`,
|
|
25
|
+
state: `N/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/State`,
|
|
26
|
+
dimming: `N/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/Dimming`,
|
|
27
|
+
dimmingMin: `N/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/Settings/DimmingMin`,
|
|
28
|
+
dimmingMax: `N/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/Settings/DimmingMax`,
|
|
29
|
+
stepSize: `N/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/Settings/StepSize`,
|
|
30
|
+
measurement: `N/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/Measurement`,
|
|
31
|
+
unit: `N/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/Settings/Unit`,
|
|
32
|
+
decimals: `N/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/Settings/Decimals`,
|
|
33
|
+
labels: `N/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/Settings/Labels`,
|
|
34
|
+
lightControls: `N/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/LightControls`,
|
|
35
|
+
});
|
|
36
|
+
export const getSwitchableOutputWriteTopics = (portalId, tree, deviceId, outputId) => ({
|
|
37
|
+
type: `W/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/Settings/Type`,
|
|
38
|
+
auto: `W/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/Auto`,
|
|
39
|
+
state: `W/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/State`,
|
|
40
|
+
dimming: `W/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/Dimming`,
|
|
41
|
+
lightControls: `W/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/LightControls`,
|
|
42
|
+
});
|
|
43
|
+
export function useSwitchableOutput(tree, deviceId, outputId) {
|
|
44
|
+
const mqtt = useMqtt();
|
|
45
|
+
const topics = useMemo(() => getSwitchableOutputStateTopics(mqtt.portalId, tree, deviceId, outputId), [mqtt.portalId, tree, deviceId, outputId]);
|
|
46
|
+
const writeTopics = useMemo(() => getSwitchableOutputWriteTopics(mqtt.portalId, tree, deviceId, outputId), [mqtt.portalId, tree, deviceId, outputId]);
|
|
47
|
+
const updateType = (type) => mqtt.publish(writeTopics.type, type);
|
|
48
|
+
const updateAuto = (auto) => mqtt.publish(writeTopics.auto, auto);
|
|
49
|
+
const updateState = (state) => mqtt.publish(writeTopics.state, state);
|
|
50
|
+
const updateDimming = (dimming) => mqtt.publish(writeTopics.dimming, dimming);
|
|
51
|
+
const updateLightControls = (hsvwa) => mqtt.publish(writeTopics.lightControls, { raw: hsvwArrayToJSON(hsvwa) });
|
|
52
|
+
return Object.assign(Object.assign({}, useTopicsState(topics)), { tree: tree, updateType,
|
|
53
|
+
updateAuto,
|
|
54
|
+
updateState,
|
|
55
|
+
updateDimming,
|
|
56
|
+
updateLightControls });
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=SwitchableOutput.provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SwitchableOutput.provider.js","sourceRoot":"/","sources":["src/Modules/SwitchingPane/SwitchableOutput.provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAW/B,OAAO,EAAE,eAAe,EAAkB,MAAM,kBAAkB,CAAA;AAElE,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAU,CAAA;AA2DpE,MAAM,UAAU,4BAA4B,CAC1C,SAA4C,EAC5C,IAA0B;IAE1B,OAAO,CAAC,SAAS,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,KAAK,CAAC,CAAA;AACxC,CAAC;AAqBD,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,KAAwB,EAAE,mBAA2B,EAAE,EAAE;IAC1G,mDAAmD;IACnD,IAAI,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,KAAK,KAAK,EAAE,EAAE,CAAC;QAC3C,OAAO,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,IAAI,CAAA;IACvC,CAAC;IACD,0CAA0C;IAC1C,OAAO,GAAG,mBAAmB,MAAM,KAAK,CAAC,IAAI,EAAE,CAAA;AACjD,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAC5C,Q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BAA8B,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAC7E,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAC1C,CAAA;IAED,MAAM,UAAU,GAAG,CAAC,IAA0B,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IACvF,MAAM,UAAU,GAAG,CAAC,IAAW,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IACxE,MAAM,WAAW,GAAG,CAAC,KAAY,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;IAC5E,MAAM,aAAa,GAAG,CAAC,OAAe,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IACrF,MAAM,mBAAmB,GAAG,CAAC,KAAqB,EAAE,EAAE,CACpD,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,aAAa,EAAE,EAAE,GAAG,EAAE,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;IAE1E,uCACK,cAAc,CAAwB,MAAM,CAAC,KAChD,IAAI,EAAE,IAAI,EACV,UAAU;QACV,UAAU;QACV,WAAW;QACX,aAAa;QACb,mBAAmB,IACpB;AACH,CAAC","sourcesContent":["import { PortalId, Topics, useMqtt, useTopicsState } from \"../Mqtt\"\nimport { useMemo } from \"react\"\nimport { SwitchingDeviceInstanceId } from \"./SwitchingDevice.provider\"\nimport {\n GenericInputStatus,\n GenericInputType,\n GenericInputValidTypesBitmask,\n SwitchableOutputStatus,\n SwitchableOutputType,\n SwitchableOutputValidTypesBitmask,\n SwitchableOutputVisibility,\n} from \"../../utils/constants\"\nimport { hsvwArrayToJSON, HSVWColorArray } from \"../../utils/hsvw\"\n\nexport const SWITCHABLE_OUTPUT_TREES = [\"system\", \"switch\"] as const\nexport type SwitchableOutputTree = (typeof SWITCHABLE_OUTPUT_TREES)[number]\nexport type SwitchableOutputId = string\nexport type SwitchableOutputUnit = string | \"/Speed\" | \"/Temperature\" | \"/Volume\"\n\nexport interface SwitchingPaneItemBase {\n tree: SwitchableOutputTree\n deviceId: SwitchingDeviceInstanceId\n outputId: SwitchableOutputId\n name: string\n customName: string\n group: string\n parentDeviceName: string\n showUIControl: SwitchableOutputVisibility\n validTypes: SwitchableOutputValidTypesBitmask | GenericInputValidTypesBitmask\n unit: SwitchableOutputUnit\n decimals?: number\n // NOTE: JSON encoded string array\n labels: string\n}\n\nexport interface SwitchableOutputState extends SwitchingPaneItemBase {\n kind: \"switchableOutput\"\n type: SwitchableOutputType\n status: SwitchableOutputStatus\n auto: 0 | 1\n state: 0 | 1\n dimming?: number\n dimmingMin?: number\n dimmingMax?: number\n // NOTE: stepSize can be of any precision, respect the precision in the UI\n stepSize?: number\n measurement?: number\n lightControls: HSVWColorArray\n}\n\nexport interface GenericInputState extends SwitchingPaneItemBase {\n kind: \"genericInput\"\n type: GenericInputType\n status: GenericInputStatus\n value?: number | null\n event?: number\n primaryLabel?: string\n rangeMin?: number\n rangeMax?: number\n invert?: 0 | 1\n digitalInputMode?: number\n}\n\nexport type SwitchingPaneItem = SwitchableOutputState | GenericInputState\n\nexport interface SwitchableOutputProvider extends SwitchableOutputState {\n updateType: (type: SwitchableOutputType) => void\n updateAuto: (auto: 0 | 1) => void\n updateState: (state: 0 | 1) => void\n updateDimming: (dimming: number) => void\n updateLightControls: (hsvwa: HSVWColorArray) => void\n}\n\nexport function switchableOutputSupportsType(\n validType: SwitchableOutputValidTypesBitmask,\n type: SwitchableOutputType\n): boolean {\n return (validType & (1 << type)) !== 0\n}\n\nexport interface SwitchableOutputTopics extends Topics {\n type?: string\n validTypes?: string\n status?: string\n name?: string\n customName?: string\n group?: string\n showUIControl?: string\n auto?: string\n state?: string\n dimming?: string\n dimmingMin?: string\n dimmingMax?: string\n stepSize?: string\n measurement?: string\n unit?: string\n labels?: string[]\n}\n\nexport const getSwitchingPaneItemNameForDisplay = (state: SwitchingPaneItem, switchingDeviceName: string) => {\n // when custom name defined, or group not overriden\n if (state.customName || state.group === \"\") {\n return state.customName || state.name\n }\n // otherwise prepend switching device name\n return `${switchingDeviceName} | ${state.name}`\n}\n\nexport const getSwitchableOutputStateTopics = (\n portalId: PortalId,\n tree: SwitchableOutputTree,\n deviceId: SwitchingDeviceInstanceId,\n outputId: SwitchableOutputId\n) => ({\n type: `N/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/Settings/Type`,\n validTypes: `N/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/Settings/ValidTypes`,\n status: `N/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/Status`,\n name: `N/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/Name`,\n customName: `N/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/Settings/CustomName`,\n group: `N/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/Settings/Group`,\n showUIControl: `N/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/Settings/ShowUIControl`,\n auto: `N/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/Auto`,\n state: `N/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/State`,\n dimming: `N/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/Dimming`,\n dimmingMin: `N/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/Settings/DimmingMin`,\n dimmingMax: `N/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/Settings/DimmingMax`,\n stepSize: `N/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/Settings/StepSize`,\n measurement: `N/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/Measurement`,\n unit: `N/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/Settings/Unit`,\n decimals: `N/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/Settings/Decimals`,\n labels: `N/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/Settings/Labels`,\n lightControls: `N/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/LightControls`,\n})\n\nexport const getSwitchableOutputWriteTopics = (\n portalId: PortalId,\n tree: SwitchableOutputTree,\n deviceId: SwitchingDeviceInstanceId,\n outputId: SwitchableOutputId\n) => ({\n type: `W/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/Settings/Type`,\n auto: `W/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/Auto`,\n state: `W/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/State`,\n dimming: `W/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/Dimming`,\n lightControls: `W/${portalId}/${tree}/${deviceId}/SwitchableOutput/${outputId}/LightControls`,\n})\n\nexport function useSwitchableOutput(\n tree: SwitchableOutputTree,\n deviceId: SwitchingDeviceInstanceId,\n outputId: SwitchableOutputId\n): SwitchableOutputProvider {\n const mqtt = useMqtt()\n const topics = useMemo(\n () => getSwitchableOutputStateTopics(mqtt.portalId, tree, deviceId, outputId),\n [mqtt.portalId, tree, deviceId, outputId]\n )\n const writeTopics = useMemo(\n () => getSwitchableOutputWriteTopics(mqtt.portalId, tree, deviceId, outputId),\n [mqtt.portalId, tree, deviceId, outputId]\n )\n\n const updateType = (type: SwitchableOutputType) => mqtt.publish(writeTopics.type, type)\n const updateAuto = (auto: 0 | 1) => mqtt.publish(writeTopics.auto, auto)\n const updateState = (state: 0 | 1) => mqtt.publish(writeTopics.state, state)\n const updateDimming = (dimming: number) => mqtt.publish(writeTopics.dimming, dimming)\n const updateLightControls = (hsvwa: HSVWColorArray) =>\n mqtt.publish(writeTopics.lightControls, { raw: hsvwArrayToJSON(hsvwa) })\n\n return {\n ...useTopicsState<SwitchableOutputState>(topics),\n tree: tree,\n updateType,\n updateAuto,\n updateState,\n updateDimming,\n updateLightControls,\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SwitchingDevice.provider.d.ts","sourceRoot":"/","sources":["src/Modules/SwitchingPane/SwitchingDevice.provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAA2B,MAAM,SAAS,CAAA;AAEnE,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAIzF,MAAM,MAAM,yBAAyB,GAAG,MAAM,CAAA;AAE9C,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,iBAAiB,EAAE,qBAAqB,EAAE,CAAA;CAC3C;AAED,MAAM,WAAW,qBAAsB,SAAQ,MAAM;IACnD,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,eAAO,MAAM,6BAA6B,GACxC,UAAU,QAAQ,EAClB,MAAM,oBAAoB,EAC1B,YAAY,yBAAyB;;;;CAKrC,CAAA;AAEF,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,yBAAyB,GAAG,oBAAoB,CAK9F;AAED,wBAAgB,mBAAmB,6DAuClC"}
|