Skip to content

Commit 623bf57

Browse files
authored
Fix Sinope TH1123ZB-G2 group set/get (#5190)
* Fix Sinope TH1123ZB-g2 group set/get This makes g2 thermostat works with groups. * fix lint * Update sinope.js * Forgot to remove this * Update sinope.js * Update sinope.js
1 parent b0f6b41 commit 623bf57

File tree

1 file changed

+29
-22
lines changed

1 file changed

+29
-22
lines changed

devices/sinope.js

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const extend = require('../lib/extend');
88
const e = exposes.presets;
99
const ea = exposes.access;
1010

11+
const manuSinope = {manufacturerCode: 0x119C};
1112
const fzLocal = {
1213
sinope_thermostat: {
1314
cluster: 'hvacThermostat',
@@ -123,35 +124,35 @@ const tzLocal = {
123124
convertSet: async (entity, key, value, meta) => {
124125
const sinopeOccupancy = {0: 'unoccupied', 1: 'occupied'};
125126
const SinopeOccupancy = utils.getKey(sinopeOccupancy, value, value, Number);
126-
await entity.write('hvacThermostat', {SinopeOccupancy}, {manufacturerCode: 0x119C});
127+
await entity.write('hvacThermostat', {SinopeOccupancy}, manuSinope);
127128
return {state: {'thermostat_occupancy': value}};
128129
},
129130
convertGet: async (entity, key, meta) => {
130-
await entity.read('hvacThermostat', ['SinopeOccupancy'], {manufacturerCode: 0x119C});
131+
await entity.read('hvacThermostat', ['SinopeOccupancy'], manuSinope);
131132
},
132133
},
133134
sinope_thermostat_backlight_autodim_param: {
134135
key: ['backlight_auto_dim'],
135136
convertSet: async (entity, key, value, meta) => {
136137
const sinopeBacklightParam = {0: 'on_demand', 1: 'sensing'};
137138
const SinopeBacklight = utils.getKey(sinopeBacklightParam, value, value, Number);
138-
await entity.write('hvacThermostat', {SinopeBacklight}, {manufacturerCode: 0x119C});
139+
await entity.write('hvacThermostat', {SinopeBacklight}, manuSinope);
139140
return {state: {'backlight_auto_dim': value}};
140141
},
141142
convertGet: async (entity, key, meta) => {
142-
await entity.read('hvacThermostat', ['SinopeBacklight'], {manufacturerCode: 0x119C});
143+
await entity.read('hvacThermostat', ['SinopeBacklight'], manuSinope);
143144
},
144145
},
145146
sinope_thermostat_main_cycle_output: {
146147
// TH1400ZB specific
147148
key: ['main_cycle_output'],
148149
convertSet: async (entity, key, value, meta) => {
149150
const lookup = {'15_sec': 15, '5_min': 300, '10_min': 600, '15_min': 900, '20_min': 1200, '30_min': 1800};
150-
await entity.write('hvacThermostat', {SinopeMainCycleOutput: lookup[value]}, {manufacturerCode: 0x119C});
151+
await entity.write('hvacThermostat', {SinopeMainCycleOutput: lookup[value]}, manuSinope);
151152
return {state: {'main_cycle_output': value}};
152153
},
153154
convertGet: async (entity, key, meta) => {
154-
await entity.read('hvacThermostat', ['SinopeMainCycleOutput'], {manufacturerCode: 0x119C});
155+
await entity.read('hvacThermostat', ['SinopeMainCycleOutput'], manuSinope);
155156
},
156157
},
157158
sinope_thermostat_aux_cycle_output: {
@@ -170,22 +171,22 @@ const tzLocal = {
170171
key: ['enable_outdoor_temperature'],
171172
convertSet: async (entity, key, value, meta) => {
172173
if (value.toLowerCase() == 'on') {
173-
await entity.write('manuSpecificSinope', {outdoorTempToDisplayTimeout: 10800});
174+
await entity.write('manuSpecificSinope', {outdoorTempToDisplayTimeout: 10800}, manuSinope);
174175
} else if (value.toLowerCase() == 'off') {
175176
// set timer to 12 sec in order to disable outdoor temperature
176-
await entity.write('manuSpecificSinope', {outdoorTempToDisplayTimeout: 12});
177+
await entity.write('manuSpecificSinope', {outdoorTempToDisplayTimeout: 12}, manuSinope);
177178
}
178179
return {readAfterWriteTime: 250, state: {enable_outdoor_temperature: value}};
179180
},
180181
convertGet: async (entity, key, meta) => {
181-
await entity.read('manuSpecificSinope', ['outdoorTempToDisplayTimeout']);
182+
await entity.read('manuSpecificSinope', ['outdoorTempToDisplayTimeout'], manuSinope);
182183
},
183184
},
184185
sinope_thermostat_outdoor_temperature: {
185186
key: ['thermostat_outdoor_temperature'],
186187
convertSet: async (entity, key, value, meta) => {
187188
if (value > -100 && value < 100) {
188-
await entity.write('manuSpecificSinope', {outdoorTempToDisplay: value * 100});
189+
await entity.write('manuSpecificSinope', {outdoorTempToDisplay: value * 100}, manuSinope);
189190
}
190191
},
191192
},
@@ -197,9 +198,9 @@ const tzLocal = {
197198
const thermostatTimeSec = thermostatDate.getTime() / 1000;
198199
const thermostatTimezoneOffsetSec = thermostatDate.getTimezoneOffset() * 60;
199200
const currentTimeToDisplay = Math.round(thermostatTimeSec - thermostatTimezoneOffsetSec - 946684800);
200-
await entity.write('manuSpecificSinope', {currentTimeToDisplay});
201+
await entity.write('manuSpecificSinope', {currentTimeToDisplay}, manuSinope);
201202
} else if (value !== '') {
202-
await entity.write('manuSpecificSinope', {currentTimeToDisplay: value});
203+
await entity.write('manuSpecificSinope', {currentTimeToDisplay: value}, manuSinope);
203204
}
204205
},
205206
},
@@ -287,12 +288,12 @@ const tzLocal = {
287288
const lookup = {'24h': 0, '12h': 1};
288289
value = value.toLowerCase();
289290
if (lookup.hasOwnProperty(value)) {
290-
await entity.write('manuSpecificSinope', {timeFormatToDisplay: lookup[value]});
291+
await entity.write('manuSpecificSinope', {timeFormatToDisplay: lookup[value]}, manuSinope);
291292
return {readAfterWriteTime: 250, state: {time_format: value}};
292293
}
293294
},
294295
convertGet: async (entity, key, meta) => {
295-
await entity.read('manuSpecificSinope', ['timeFormatToDisplay']);
296+
await entity.read('manuSpecificSinope', ['timeFormatToDisplay'], manuSinope);
296297
},
297298
},
298299
sinope_connected_load: {
@@ -428,6 +429,10 @@ module.exports = [
428429
await reporting.thermostatTemperature(endpoint);
429430
await reporting.thermostatPIHeatingDemand(endpoint);
430431
await reporting.thermostatOccupiedHeatingSetpoint(endpoint);
432+
433+
await reporting.temperature(endpoint, {min: 1, max: 0xFFFF}); // Disable default reporting
434+
await endpoint.configureReporting('msTemperatureMeasurement', [{
435+
attribute: 'tolerance', minimumReportInterval: 1, maximumReportInterval: 0xFFFF, reportableChange: 1}]);
431436
try {
432437
await reporting.thermostatSystemMode(endpoint);
433438
} catch (error) {/* Not all support this */}
@@ -446,8 +451,6 @@ module.exports = [
446451
}
447452
await reporting.rmsCurrent(endpoint, {min: 10, max: 306, change: 100}); // divider 1000: 0.1Arms
448453
await reporting.rmsVoltage(endpoint, {min: 10, max: 307, change: 5}); // divider 10: 0.5Vrms
449-
450-
await reporting.temperature(endpoint, {min: 1, max: 0xFFFF}); // Disable default reporting
451454
},
452455
},
453456
{
@@ -492,6 +495,10 @@ module.exports = [
492495
await reporting.thermostatTemperature(endpoint);
493496
await reporting.thermostatPIHeatingDemand(endpoint);
494497
await reporting.thermostatOccupiedHeatingSetpoint(endpoint);
498+
499+
await reporting.temperature(endpoint, {min: 1, max: 0xFFFF}); // Disable default reporting
500+
await endpoint.configureReporting('msTemperatureMeasurement', [{
501+
attribute: 'tolerance', minimumReportInterval: 1, maximumReportInterval: 0xFFFF, reportableChange: 1}]);
495502
try {
496503
await reporting.thermostatSystemMode(endpoint);
497504
} catch (error) {/* Not all support this */}
@@ -510,8 +517,6 @@ module.exports = [
510517
}
511518
await reporting.rmsCurrent(endpoint, {min: 10, max: 306, change: 100}); // divider 1000: 0.1Arms
512519
await reporting.rmsVoltage(endpoint, {min: 10, max: 307, change: 5}); // divider 10: 0.5Vrms
513-
514-
await reporting.temperature(endpoint, {min: 1, max: 0xFFFF}); // Disable default reporting
515520
},
516521
},
517522
{
@@ -557,22 +562,24 @@ module.exports = [
557562
const thermostatTimeSec = thermostatDate.getTime() / 1000;
558563
const thermostatTimezoneOffsetSec = thermostatDate.getTimezoneOffset() * 60;
559564
const currentTimeToDisplay = Math.round(thermostatTimeSec - thermostatTimezoneOffsetSec - 946684800);
560-
await endpoint.write('manuSpecificSinope', {currentTimeToDisplay}, {manufacturerCode: 0x119C});
561-
await endpoint.write('manuSpecificSinope', {'secondScreenBehavior': 0}, {manufacturerCode: 0x119C}); // Mode auto
565+
await endpoint.write('manuSpecificSinope', {currentTimeToDisplay}, manuSinope);
566+
await endpoint.write('manuSpecificSinope', {'secondScreenBehavior': 0}, manuSinope); // Mode auto
562567

563568
await reporting.thermostatTemperature(endpoint);
564569
await reporting.thermostatPIHeatingDemand(endpoint);
565570
await reporting.thermostatOccupiedHeatingSetpoint(endpoint);
566571
await reporting.thermostatSystemMode(endpoint);
567572

573+
await reporting.temperature(endpoint, {min: 1, max: 0xFFFF}); // Disable default reporting
574+
await endpoint.configureReporting('msTemperatureMeasurement', [{
575+
attribute: 'tolerance', minimumReportInterval: 1, maximumReportInterval: 0xFFFF, reportableChange: 1}]);
576+
568577
await reporting.readMeteringMultiplierDivisor(endpoint);
569578
await reporting.currentSummDelivered(endpoint, {min: 10, max: 303, change: [1, 1]});
570579
await reporting.readEletricalMeasurementMultiplierDivisors(endpoint);
571580
await reporting.activePower(endpoint, {min: 10, max: 305, change: 1}); // divider 1: 1W
572581
await reporting.rmsCurrent(endpoint, {min: 10, max: 306, change: 100}); // divider 1000: 0.1Arms
573582
await reporting.rmsVoltage(endpoint, {min: 10, max: 307, change: 5}); // divider 10: 0.5Vrms
574-
575-
await reporting.temperature(endpoint, {min: 1, max: 0xFFFF}); // Disable default reporting
576583
try {
577584
await reporting.thermostatUnoccupiedHeatingSetpoint(endpoint);
578585
} catch (error) {/* Do nothing */} // Not enought space but shall pass

0 commit comments

Comments
 (0)