feat: initial myprimal MQTT bridge service
Dynamic MySolem/MyIndygo IoT bridge with MQTT, Home Assistant autodiscovery, and Homebridge EasyMQTT compatibility. - Device discovery via MySolem API on startup (all modules/inputs/outputs) - Configurable poll engine (fast/normal/slow buckets, per-input overrides) - MQTT retained state publishing + HA autodiscovery payloads - Unified manual command routing (linesControl vs sendManualModuleCommand) - Runtime config via MQTT $config/set, persisted to config.json - Expression override system (API-provided > hardcoded > passthrough) - Minimal REST API: /health, /state, /control, /rediscover - Docker deployment (Dockerfile + docker-compose.yml) - 38 unit tests Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
'use strict';
|
||||
const { getProtocol, isSensorOnly, isGateway } = require('../src/module-types');
|
||||
|
||||
describe('getProtocol', () => {
|
||||
test('pool controller → linesControl', () => {
|
||||
expect(getProtocol('lr-pc')).toBe('linesControl');
|
||||
expect(getProtocol('lr-niv')).toBe('linesControl');
|
||||
});
|
||||
|
||||
test('irrigation → manualCommand', () => {
|
||||
expect(getProtocol('lr-ag')).toBe('manualCommand');
|
||||
expect(getProtocol('lr-ip-eco')).toBe('manualCommand');
|
||||
});
|
||||
|
||||
test('unknown type → linesControl with console warning', () => {
|
||||
const warn = jest.spyOn(console, 'warn').mockImplementation(() => {});
|
||||
expect(getProtocol('lr-unknown-xyz')).toBe('linesControl');
|
||||
expect(warn).toHaveBeenCalled();
|
||||
warn.mockRestore();
|
||||
});
|
||||
});
|
||||
|
||||
describe('isSensorOnly', () => {
|
||||
test('sensor modules return true', () => {
|
||||
expect(isSensorOnly('lr-ms')).toBe(true);
|
||||
expect(isSensorOnly('lr-pr')).toBe(true);
|
||||
expect(isSensorOnly('pool-level-sensor')).toBe(true);
|
||||
expect(isSensorOnly('lr-mas')).toBe(true);
|
||||
});
|
||||
|
||||
test('actuator modules return false', () => {
|
||||
expect(isSensorOnly('lr-pc')).toBe(false);
|
||||
expect(isSensorOnly('lr-ag')).toBe(false);
|
||||
expect(isSensorOnly('lr-niv')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isGateway', () => {
|
||||
test('gateway types return true', () => {
|
||||
expect(isGateway('lr-mb-10')).toBe(true);
|
||||
expect(isGateway('lr-mb-30')).toBe(true);
|
||||
expect(isGateway('wf-mb')).toBe(true);
|
||||
});
|
||||
|
||||
test('non-gateway types return false', () => {
|
||||
expect(isGateway('lr-pc')).toBe(false);
|
||||
expect(isGateway('lr-ms')).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user