From de54b0633e073f19eff9cf1fe3915db965fc58c2 Mon Sep 17 00:00:00 2001 From: Heikki Partanen Date: Sun, 25 Jan 2026 17:02:57 +0200 Subject: [PATCH 1/2] feat: Futurehome TS0601 expose energy consumption Expose energy consumption metric, ignoring outdated values which seem to happen often at least in a busier network. --- src/devices/futurehome.ts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/devices/futurehome.ts b/src/devices/futurehome.ts index ac8856e894a55..313d176f34c62 100644 --- a/src/devices/futurehome.ts +++ b/src/devices/futurehome.ts @@ -1,11 +1,28 @@ import * as exposes from "../lib/exposes"; import * as m from "../lib/modernExtend"; import * as tuya from "../lib/tuya"; -import type {DefinitionWithExtend} from "../lib/types"; +import type {DefinitionWithExtend, Fz} from "../lib/types"; const e = exposes.presets; const ea = exposes.access; +const localValueConverters = { + energyMonotonic: { + from: (value: number, meta: Fz.Meta) => { + const scaled = tuya.valueConverter.divideBy100.from(value); + const lastValue = meta.device.meta.energy; + + if (typeof lastValue === "number" && scaled < lastValue && scaled !== 0) { + // Erraneous reading that is less than previous readings (and not a reset to 0), ignore it. + return {}; + } + + meta.device.meta.energy = scaled; + return {energy: scaled}; + }, + }, +}; + export const definitions: DefinitionWithExtend[] = [ { fingerprint: tuya.fingerprint("TS0601", ["_TZE204_e5hpkc6d", "_TZE200_4hbx5cvx", "_TZE200_e5hpkc6d"]), @@ -40,6 +57,7 @@ export const definitions: DefinitionWithExtend[] = [ .withValueStep(1), e.child_lock(), e.window_detection(), + e.energy(), e .numeric("hysteresis", ea.STATE_SET) .withUnit("°C") @@ -76,6 +94,8 @@ export const definitions: DefinitionWithExtend[] = [ // connecteTempProgram: 105 [106, "window_detection", tuya.valueConverter.onOff], [107, "max_temperature_protection", tuya.valueConverter.raw], + // Reported as a monotonically increasing counter while heating, using unit 0.01 kWh. + [123, "", localValueConverters.energyMonotonic], ], }, }, From 6bbea8055c521f2254d930e853cca61424c5251f Mon Sep 17 00:00:00 2001 From: Koen Kanters Date: Tue, 27 Jan 2026 20:11:40 +0100 Subject: [PATCH 2/2] u --- src/devices/futurehome.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/devices/futurehome.ts b/src/devices/futurehome.ts index 313d176f34c62..515720b4fe31b 100644 --- a/src/devices/futurehome.ts +++ b/src/devices/futurehome.ts @@ -10,15 +10,14 @@ const localValueConverters = { energyMonotonic: { from: (value: number, meta: Fz.Meta) => { const scaled = tuya.valueConverter.divideBy100.from(value); - const lastValue = meta.device.meta.energy; - - if (typeof lastValue === "number" && scaled < lastValue && scaled !== 0) { + const lastValue = meta.device.meta.energy ?? 0; + if (scaled < lastValue && scaled !== 0) { // Erraneous reading that is less than previous readings (and not a reset to 0), ignore it. - return {}; + return lastValue; } meta.device.meta.energy = scaled; - return {energy: scaled}; + return scaled; }, }, }; @@ -95,7 +94,7 @@ export const definitions: DefinitionWithExtend[] = [ [106, "window_detection", tuya.valueConverter.onOff], [107, "max_temperature_protection", tuya.valueConverter.raw], // Reported as a monotonically increasing counter while heating, using unit 0.01 kWh. - [123, "", localValueConverters.energyMonotonic], + [123, "energy", localValueConverters.energyMonotonic], ], }, },