mirror of
https://github.com/Matysh/houseplan-card
synced 2026-07-31 08:28:31 +00:00
feat v1.15.0: temperature room fill (blue/green/yellow) with editable comfort bounds
- fill_mode 'temp': below comfort → #4fc3f7, inside → #66d17a, above → #ffd45c; bounds default 20-25°C, editable in the space dialog (visible only for this mode), swapped bounds tolerated; rooms without a temperature reading unfilled - areaTemp(): average of the area devices' temperatures - tests: roomFillColor temp bands + bounds, spaceDisplayOf defaults, areaTemp, backend schema (fill_mode temp + temp_min/temp_max); smoke_temp_fill.mjs - TESTING.md updated in the same commit (policy)
This commit is contained in:
+17
-1
@@ -1,6 +1,6 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { buildDevices, lightGroups, primaryEntity, lqiFor, tempFor, areaLights } from '../test-build/devices.js';
|
||||
import { buildDevices, lightGroups, primaryEntity, lqiFor, tempFor, areaLights, areaTemp } from '../test-build/devices.js';
|
||||
import { compileIconRules } from '../test-build/rules.js';
|
||||
|
||||
/** Minimal fake hass around the pieces buildDevices reads. */
|
||||
@@ -170,3 +170,19 @@ test('areaLights: on / off / none tri-state', () => {
|
||||
assert.equal(areaLights(hass, devs, 'kitchen'), 'off');
|
||||
assert.equal(areaLights(hass, devs, 'bath'), 'none');
|
||||
});
|
||||
|
||||
test('areaTemp: averages device temperatures, null when none report', () => {
|
||||
const hass = mkHass({ states: {
|
||||
'sensor.t1': { state: '20.0', attributes: { device_class: 'temperature' } },
|
||||
'sensor.t2': { state: '23.1', attributes: { device_class: 'temperature' } },
|
||||
'sensor.hum': { state: '55', attributes: { device_class: 'humidity' } },
|
||||
}});
|
||||
const devs = [
|
||||
{ area: 'living', entities: ['sensor.t1'] },
|
||||
{ area: 'living', entities: ['sensor.t2'] },
|
||||
{ area: 'bath', entities: ['sensor.hum'] },
|
||||
];
|
||||
assert.equal(areaTemp(hass, devs, 'living'), 21.6); // (20+23.1)/2=21.55 → 21.6
|
||||
assert.equal(areaTemp(hass, devs, 'bath'), null);
|
||||
assert.equal(areaTemp(hass, devs, 'garage'), null);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user