Skip to content

Commit

Permalink
fix: Elko Super Thermostat: configurable reporting of local temperatu…
Browse files Browse the repository at this point in the history
…re based on sensor choice (#8313)

* Report local temperature by sensor choice

* Configurable local temperature reporting based on sensor choice

* chore: prettier

* bind genIdentify

* Use meta instead of globalStore

* Divide floortemperature fetched from state by 100

* Base result from elkoThermostat on thermostat as a foundation
  • Loading branch information
torandreroland authored Nov 20, 2024
1 parent 5fbee66 commit 9c0d004
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 9 deletions.
60 changes: 53 additions & 7 deletions src/converters/fromZigbee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1921,35 +1921,81 @@ const converters1 = {
elko_thermostat: {
cluster: 'hvacThermostat',
type: ['attributeReport', 'readResponse'],
options: [exposes.options.local_temperature_based_on_sensor()],
convert: (model, msg, publish, options, meta) => {
const result: KeyValueAny = {};
const result = converters1.thermostat.convert(model, msg, publish, options, meta) as KeyValue;
const data = msg.data;

if (data.localTemp !== undefined) {
const value = precisionRound(msg.data['localTemp'], 2) / 100;
const valuesFloorSensor = ['floor', 'supervisor_floor'];
const sensorType = meta.state.sensor as string;
const floorTemperature = meta.state.floor_temp as number;
if (valuesFloorSensor.includes(sensorType) && options.local_temperature_based_on_sensor) {
result[postfixWithEndpointName('local_temperature', msg, model, meta)] = floorTemperature / 100;
} else {
if (value >= -273.15) {
result[postfixWithEndpointName('local_temperature', msg, model, meta)] = value;
}
}
}
if (data.elkoDisplayText !== undefined) {
// Display text
result.display_text = data['elkoDisplayText'];
}

if (data.elkoSensor !== undefined) {
// Sensor
const sensorModeLookup = {
0: 'air',
1: 'floor',
3: 'supervisor_floor',
};
const value = utils.getFromLookup(data['elkoSensor'], sensorModeLookup);
result.sensor = value;
}
if (data.elkoPowerStatus !== undefined) {
// Power status
result.system_mode = data['elkoPowerStatus'] ? 'heat' : 'off';
}

if (data.elkoExternalTemp !== undefined) {
// External temp (floor)
result.floor_temp = utils.precisionRound(data['elkoExternalTemp'], 2) / 100;
}

if (data.elkoRelayState !== undefined) {
// Relay state
result.running_state = data['elkoRelayState'] ? 'heat' : 'idle';
}

if (data.elkoCalibration !== undefined) {
// Calibration
result.local_temperature_calibration = precisionRound(data['elkoCalibration'], 2) / 10;
}

if (data.elkoLoad !== undefined) {
// Load
result.load = data['elkoLoad'];
}
if (data.elkoRegulatorMode !== undefined) {
// Regulator mode
result.regulator_mode = data['elkoRegulatorMode'] ? 'regulator' : 'thermostat';
}
if (data.elkoMeanPower !== undefined) {
// Mean power
result.mean_power = data['elkoMeanPower'];
}
if (data.elkoNightSwitching !== undefined) {
// Night switching
result.night_switching = data['elkoNightSwitching'] ? 'on' : 'off';
}
if (data.elkoFrostGuard !== undefined) {
// Frost guard
result.frost_guard = data['elkoFrostGuard'] ? 'on' : 'off';
}
if (data.elkoChildLock !== undefined) {
// Child lock
result.child_lock = data['elkoChildLock'] ? 'lock' : 'unlock';
}
if (data.elkoMaxFloorTemp !== undefined) {
// Max floor temp
result.max_floor_temp = data['elkoMaxFloorTemp'];
}
return result;
},
} satisfies Fz.Converter,
Expand Down
4 changes: 2 additions & 2 deletions src/devices/elko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const definitions: DefinitionWithExtend[] = [
model: '4523430',
vendor: 'ELKO',
description: 'ESH Plus Super TR RF PH',
fromZigbee: [fz.elko_thermostat, fz.thermostat],
fromZigbee: [fz.elko_thermostat],
toZigbee: [
tz.thermostat_occupied_heating_setpoint,
tz.elko_display_text,
Expand Down Expand Up @@ -165,7 +165,7 @@ const definitions: DefinitionWithExtend[] = [
],
configure: async (device, coordinatorEndpoint) => {
const endpoint = device.getEndpoint(1);
await reporting.bind(endpoint, coordinatorEndpoint, ['hvacThermostat', 'genBasic', 'genIdentify']);
await reporting.bind(endpoint, coordinatorEndpoint, ['hvacThermostat', 'genIdentify']);

// standard ZCL attributes
await reporting.thermostatTemperature(endpoint);
Expand Down
4 changes: 4 additions & 0 deletions src/lib/exposes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,10 @@ export const options = {
new Binary(`cover_position_tilt_disable_report`, access.SET, true, false).withDescription(
`Do not publish set cover target position as a normal 'position' value (default false).`,
),
local_temperature_based_on_sensor: () =>
new Binary(`local_temperature_based_on_sensor`, access.SET, true, false)
.withLabel('Local temperature sensor reporting')
.withDescription(`Base local temperature on sensor choice (default false).`),
};

export const presets = {
Expand Down

0 comments on commit 9c0d004

Please sign in to comment.