Abstract MQTT from communication and make mqtt optional (#4462)

* Add option for mqtt config

* Setup communication layer

* Have a dispatcher which is responsible for handling and sending messages

* Move mqtt to communication

* Separate ws communications module

* Make ws client conform to communicator

* Cleanup imports

* Migrate to new dispatcher

* Clean up

* Need to set topic prefix

* Remove references to mqtt in dispatcher

* Don't start mqtt until dispatcher is subscribed

* Cleanup

* Shorten package

* Formatting

* Remove unused

* Cleanup

* Rename mqtt to ws on web

* Fix ws mypy

* Fix mypy

* Reformat

* Cleanup if/else chain

* Catch bad set commands
This commit is contained in:
Nicolas Mowen
2022-11-23 19:03:20 -07:00
committed by GitHub
parent 370276a7b6
commit 6c0978498d
23 changed files with 594 additions and 560 deletions

View File

@@ -3,7 +3,7 @@ import { set as setData } from 'idb-keyval';
import { DarkModeProvider, useDarkMode, usePersistence } from '..';
import { fireEvent, render, screen } from 'testing-library';
import { useCallback } from 'preact/hooks';
import * as Mqtt from '../../api/mqtt';
import * as WS from '../../api/ws';
function DarkModeChecker() {
const { currentMode } = useDarkMode();
@@ -12,7 +12,7 @@ function DarkModeChecker() {
describe('DarkMode', () => {
beforeEach(() => {
vi.spyOn(Mqtt, 'MqttProvider').mockImplementation(({ children }) => children);
vi.spyOn(WS, 'WsProvider').mockImplementation(({ children }) => children);
});
test('uses media by default', async () => {