Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/devices/futurehome.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
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 ?? 0;
if (scaled < lastValue && scaled !== 0) {
// Erraneous reading that is less than previous readings (and not a reset to 0), ignore it.
return lastValue;
}

meta.device.meta.energy = scaled;
return scaled;
},
},
};

export const definitions: DefinitionWithExtend[] = [
{
fingerprint: tuya.fingerprint("TS0601", ["_TZE204_e5hpkc6d", "_TZE200_4hbx5cvx", "_TZE200_e5hpkc6d"]),
Expand Down Expand Up @@ -40,6 +56,7 @@ export const definitions: DefinitionWithExtend[] = [
.withValueStep(1),
e.child_lock(),
e.window_detection(),
e.energy(),
e
.numeric("hysteresis", ea.STATE_SET)
.withUnit("°C")
Expand Down Expand Up @@ -76,6 +93,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, "energy", localValueConverters.energyMonotonic],
],
},
},
Expand Down