941abd98d5
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>
34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
'use strict';
|
|
const { getInputType } = require('../src/input-types');
|
|
|
|
describe('getInputType', () => {
|
|
test('known types return correct descriptor', () => {
|
|
const ph = getInputType(6);
|
|
expect(ph.haComponent).toBe('sensor');
|
|
expect(ph.unit).toBe('pH');
|
|
expect(ph.pollBucket).toBe('fast');
|
|
expect(ph.expression).toBeTruthy();
|
|
|
|
const moisture = getInputType(12);
|
|
expect(moisture.haComponent).toBe('sensor');
|
|
expect(moisture.deviceClass).toBe('humidity');
|
|
expect(moisture.pollBucket).toBe('normal');
|
|
|
|
const rain = getInputType(2);
|
|
expect(rain.haComponent).toBe('binary_sensor');
|
|
expect(rain.pollBucket).toBe('slow');
|
|
});
|
|
|
|
test('unknown type returns fallback sensor with _unknown flag', () => {
|
|
const unknown = getInputType(999);
|
|
expect(unknown.haComponent).toBe('sensor');
|
|
expect(unknown._unknown).toBe(true);
|
|
expect(unknown.expression).toBeNull();
|
|
});
|
|
|
|
test('binary_sensor types have no unit', () => {
|
|
expect(getInputType(21).unit).toBeNull();
|
|
expect(getInputType(149).unit).toBeNull();
|
|
});
|
|
});
|