[S60ZBTPF / SONOFF] automatic Device power off when there is no load after some seconds
What happened?
The plug automatically switches off when there is no load after some seconds.
What did you expect to happen?
I expect the plug not to switch off when there is no load. I'm using one plug for the fridge where is not always load.
How to reproduce it (minimal and precise)
switch the plug on. When no more load is pulled (current = 0) the plug switches off.
Zigbee2MQTT version
2.9.2 (2b485a98)
Adapter firmware version
{"maintrel":1,"majorrel":2,"minorrel":7,"product":1,"revision":20250321,"transportrev":2}
Adapter
ZStack3x0
Setup
os: #1 SMP PREEMPT Debian 1:6.12.75-1+rpt1 (2026-03-11) - 6.12.75+rpt-rpi-v8 - arm64
node: v20.19.2
ha: false
Device database.db entry
No response
Debug log
No response
Notes
Device
definition: S60ZBTPF - SONOFF (v0.0.0)
software_build_id: 2.0.2
date_code: 20260204
endpoints:
{"1":{"bindings":[{"cluster":"genOnOff","target":{"endpoint":1,"ieee_address":"0x00124b0025e1582f","type":"endpoint"}},{"cluster":"customClusterEwelink","target":{"endpoint":1,"ieee_address":"0x00124b0025e1582f","type":"endpoint"}},{"cluster":"seMetering","target":{"endpoint":1,"ieee_address":"0x00124b0025e1582f","type":"endpoint"}}],"clusters":{"input":["genBasic","genIdentify","genGroups","genScenes","genOnOff","seMetering","haElectricalMeasurement","haDiagnostic","manuSpecificAmazonWWAH","customClusterEwelink"],"output":["genIdentify","genTime","genOta"]},"configured_reportings":[{"attribute":"energyMonth","cluster":"customClusterEwelink","maximum_report_interval":3600,"minimum_report_interval":60,"reportable_change":50},{"attribute":"energyYesterday","cluster":"customClusterEwelink","maximum_report_interval":3600,"minimum_report_interval":60,"reportable_change":50},{"attribute":"energyToday","cluster":"customClusterEwelink","maximum_report_interval":3600,"minimum_report_interval":60,"reportable_change":50},{"attribute":"currentSummDelivered","cluster":"seMetering","maximum_report_interval":3600,"minimum_report_interval":5,"reportable_change":257},{"attribute":"onOff","cluster":"genOnOff","maximum_report_interval":65000,"minimum_report_interval":0,"reportable_change":1},{"attribute":"acCurrentCurrentValue","cluster":"customClusterEwelink","maximum_report_interval":65000,"minimum_report_interval":10,"reportable_change":2},{"attribute":"acCurrentPowerValue","cluster":"customClusterEwelink","maximum_report_interval":65000,"minimum_report_interval":10,"reportable_change":0}],"scenes":[]},"242":{"bindings":[],"clusters":{"input":[],"output":["greenPower"]},"configured_reportings":[],"scenes":[]}}
Health
time: Sat Apr 04 2026 12:46:05 GMT+0200 (Mitteleuropäische Sommerzeit)
os.load_average: 2.02, 2.26, 1.98
os.memory_percent: 42.6117
process.memory_percent: 1.7258
process.uptime_sec: 10825
{"leave_count":0,"messages":4428,"messages_per_sec":0.4166,"network_address_changes":0}
The state of the plug after automatic power off: { "current": 0, "linkquality": 160, "outlet_control_protect": false, "overload_protection": { "enable_max_voltage": "DISABLE", "enable_min_current": "DISABLE", "enable_min_power": "DISABLE", "enable_min_voltage": "DISABLE", "max_current": 0, "max_power": 0, "max_voltage": 0, "min_current": 0, "min_power": 0, "min_voltage": 0 }, "power": 0, "voltage": 233.25, "state": "OFF", "power_on_behavior": "on", "network_indicator": true, "energy_yesterday": 0, "energy_today": 0, "energy_month": 0, "energy": 0, "update": { "installed_version": 8194, "latest_release_notes": null, "latest_source": null, "latest_version": 8194, "state": "idle" }, "inching_control_set": { "inching_control": "DISABLE", "inching_mode": "ON", "inching_time": 3441.5 }, "action": "off" }
I think I have similar problem. I just turn on the smart plug with no device actually plugged-in, and the smart plug keeps being powered off after 10/15 seconds.
- update added here https://github.com/Koenkk/zigbee-OTA/pull/1104
@cubez2mdeveloper can you take a look?
@Koenkk I think we should retract the image for now..
I think i've found the problem. After pairing the plug inching is displayed inactive on the exposes page even though it is active. So the minimum values are in effect and the plug powers off if there is no load pulled on the plug and the blue led is flashing. After pressing apply for the inching control without any changes the inching seems to be inactive and the plug doesn't power off anymore.
Removed the OTA!
I have the same problem with firmware v1.0.2. Doesn't appears to be a problem of v2.0.2.
Solved with @ktreichel0 strategy. Thanks!
I have the same issue and it's not solving for me with @ktreichel0 fix. Is the old firmware version available as a download?
Hi, i found process how work.
Remove s60 plug from devices in z2mqqtt , before copy name from plug.
After remove wait 30sec about. Now add device.
When device added go to device past device name to found device - check update entity in ha.
After go to in plug device - function (in z2mqtt). Go down , and check all setting outlet control prodect. All setting is in default off. Now click down button apply.and try plug. For me worked.
Problem is z2mqtt show device power setting disabled but real is enabled. I save config what read in default after add( all sett about power is off) and z2mqtt send to device new config and work. Device power off for min current value/min volt value and min power value. When is setting is off for min value work good.
Hi, i found process how work.
Remove s60 plug from devices in z2mqqtt , before copy name from plug.
After remove wait 30sec about. Now add device.
When device added go to device past device name to found device - check update entity in ha.
After go to in plug device - function (in z2mqtt). Go down , and check all setting outlet control prodect. All setting is in default off. Now click down button apply.and try plug. For me worked.
Problem is z2mqtt show device power setting disabled but real is enabled. I save config what read in default after add( all sett about power is off) and z2mqtt send to device new config and work. Device power off for min current value/min volt value and min power value. When is setting is off for min value work good.
This worked for me - thank you @LyxxSK
Not sure why, but only one of my 4 S60's was affected by this.
Hi, i found process how work.
Remove s60 plug from devices in z2mqqtt , before copy name from plug.
After remove wait 30sec about. Now add device.
When device added go to device past device name to found device - check update entity in ha.
After go to in plug device - function (in z2mqtt). Go down , and check all setting outlet control prodect. All setting is in default off. Now click down button apply.and try plug. For me worked.
Problem is z2mqtt show device power setting disabled but real is enabled. I save config what read in default after add( all sett about power is off) and z2mqtt send to device new config and work. Device power off for min current value/min volt value and min power value. When is setting is off for min value work good.
This worked, thank you kindly
Hi,
with 2.9.1 i'm not able to enable the minimum protection values. As soon as i'm enabling one of them and press apply z2m logs an invalid value
SONOFF CUBE @.***> schrieb am Di., 7. Apr. 2026, 11:47:
CubeZ2mDeveloper left a comment (Koenkk/zigbee2mqtt#31604) https://github.com/Koenkk/zigbee2mqtt/issues/31604#issuecomment-4198082418
Hi, we tried to reproduce this on our side, but were not able to observe the same behavior.
As a troubleshooting step, could you please try configuring Overload protection with explicit boundary values first, then save the settings?
For S60ZBTPF, please try:
- Max power: 4000 W
- Enable min power: ON
- Min power: 0.1 W
- Enable max voltage: ON
- Max voltage: 277 V
- Enable min voltage: ON
- Min voltage: 165 V
- Max current: 17 A
- Enable min current: ON
- Min current: 0.1 A
In other words, please enable all enableXXX options, set all Max values to their supported maximums, and set all Min values to their supported minimums, then save once.
After that, if you still want Overload protection disabled, please try turning all enableXXX options OFF and save again.
The idea here is to make sure all protection-related parameters are first written back to the device with valid values, and only then disable them again.
— Reply to this email directly, view it on GitHub https://github.com/Koenkk/zigbee2mqtt/issues/31604#issuecomment-4198082418, or unsubscribe https://github.com/notifications/unsubscribe-auth/A57EUI5JQG3S7XSAUN4LHYT4UTFB3AVCNFSM6AAAAACXMSPK26VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DCOJYGA4DENBRHA . You are receiving this because you were mentioned.Message ID: @.***>
Hi,
with 2.9.1 i'm not able to enable the minimum protection values. As soon as
i'm enabling one of them and press apply z2m logs an invalid value
I had this. Delete the weird values that are there, put in sensible values within the range and then Apply it.
I've entered the 0.1 as minimum value and with this value it logs the invalid value.
derekoharrow @.***> schrieb am Di., 7. Apr. 2026, 12:52:
derekoharrow left a comment (Koenkk/zigbee2mqtt#31604) https://github.com/Koenkk/zigbee2mqtt/issues/31604#issuecomment-4198439101
Hi,
with 2.9.1 i'm not able to enable the minimum protection values. As soon as
i'm enabling one of them and press apply z2m logs an invalid value
I had this. Delete the weird values that are there, put in sensible values within the range and then Apply it.
— Reply to this email directly, view it on GitHub https://github.com/Koenkk/zigbee2mqtt/issues/31604#issuecomment-4198439101, or unsubscribe https://github.com/notifications/unsubscribe-auth/A57EUI5E6WWWB2JKD2UB2Z34UTMYBAVCNFSM6AAAAACXMSPK26VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DCOJYGQZTSMJQGE . You are receiving this because you were mentioned.Message ID: @.***>
I've entered the 0.1 as minimum value and with this value it logs the invalid value.
derekoharrow @.***> schrieb am Di., 7. Apr. 2026, 12:52: …
Hi, please try using version 2.9.2 of Z2M. We have improved the code of overload protection. https://github.com/Koenkk/zigbee-herdsman-converters/pull/11762
I can't try 2.9.2. This version breaks my danvos ally thermostats.
SONOFF CUBE @.***> schrieb am Di., 7. Apr. 2026, 13:07:
CubeZ2mDeveloper left a comment (Koenkk/zigbee2mqtt#31604) https://github.com/Koenkk/zigbee2mqtt/issues/31604#issuecomment-4198513969
I've entered the 0.1 as minimum value and with this value it logs the invalid value.
derekoharrow @.***> schrieb am Di., 7. Apr. 2026, 12:52: … <#m_576508170601006474_>
Hi, please try using version 2.9.2 of Z2M. We have improved the code of overload protection. Koenkk/zigbee-herdsman-converters#11762 https://github.com/Koenkk/zigbee-herdsman-converters/pull/11762
— Reply to this email directly, view it on GitHub https://github.com/Koenkk/zigbee2mqtt/issues/31604#issuecomment-4198513969, or unsubscribe https://github.com/notifications/unsubscribe-auth/A57EUI5J6H34TZGJJJ7ZMM34UTOOXAVCNFSM6AAAAACXMSPK26VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DCOJYGUYTGOJWHE . You are receiving this because you were mentioned.Message ID: @.***>
Hi,
If i think about the minimum overload protection settings then the plug is supposed to turn off if the power pulled is below min power and min power is enabled.
This could be used for an automatic turn off.
Klaus Treichel @.***> schrieb am Di., 7. Apr. 2026, 13:09:
I can't try 2.9.2. This version breaks my danvos ally thermostats.
SONOFF CUBE @.***> schrieb am Di., 7. Apr. 2026, 13:07:
CubeZ2mDeveloper left a comment (Koenkk/zigbee2mqtt#31604) https://github.com/Koenkk/zigbee2mqtt/issues/31604#issuecomment-4198513969
I've entered the 0.1 as minimum value and with this value it logs the invalid value.
derekoharrow @.***> schrieb am Di., 7. Apr. 2026, 12:52: … <#m_7932833761309349041_m_576508170601006474_>
Hi, please try using version 2.9.2 of Z2M. We have improved the code of overload protection. Koenkk/zigbee-herdsman-converters#11762 https://github.com/Koenkk/zigbee-herdsman-converters/pull/11762
— Reply to this email directly, view it on GitHub https://github.com/Koenkk/zigbee2mqtt/issues/31604#issuecomment-4198513969, or unsubscribe https://github.com/notifications/unsubscribe-auth/A57EUI5J6H34TZGJJJ7ZMM34UTOOXAVCNFSM6AAAAACXMSPK26VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DCOJYGUYTGOJWHE . You are receiving this because you were mentioned.Message ID: @.***>
Hi,
If i think about the minimum overload protection settings then the plug is supposed to turn off if the power pulled is below min power and min power is enabled.
This could be used for an automatic turn off.
Klaus Treichel @.***> schrieb am Di., 7. Apr. 2026, 13:09: …
Hi @ktreichel0,
Yes, that makes sense.
If min power / min current protection is enabled, then the plug is expected to turn off once the measured value drops below the configured minimum threshold. That behavior can indeed be used as an automatic turn-off feature.
What we suspect here is not that this protection logic is wrong, but that the configuration shown in Zigbee2MQTT may not fully match the configuration that is actually active on the device. In other words, some protection-related settings may still be active internally even though they appear disabled in the UI.
What we are trying to verify is whether saving the settings again can overwrite the stale or not-yet-applied configuration on the device with the values currently shown in Zigbee2MQTT.
Could you please try explicitly disabling the minimum protection options and saving the configuration again? If needed, you can also change the related values once and then disable them again before saving, just to force the device to receive and apply the updated configuration.
This would help confirm whether the issue is caused by a configuration sync/write problem rather than by the protection feature itself behaving incorrectly.
Hi,
I can't enable the min protection featutes in 2.9.1 and i can't update to 2.9.2 because of the Danfoss ally issue. I need my thermostats working.
SONOFF CUBE @.***> schrieb am Mi., 8. Apr. 2026, 05:21:
CubeZ2mDeveloper left a comment (Koenkk/zigbee2mqtt#31604) https://github.com/Koenkk/zigbee2mqtt/issues/31604#issuecomment-4203570669
Hi,
If i think about the minimum overload protection settings then the plug is supposed to turn off if the power pulled is below min power and min power is enabled.
This could be used for an automatic turn off.
Klaus Treichel @.***> schrieb am Di., 7. Apr. 2026, 13:09: … <#m_5319085579168529675_>
Hi @ktreichel0 https://github.com/ktreichel0,
Yes, that makes sense.
If min power / min current protection is enabled, then the plug is expected to turn off once the measured value drops below the configured minimum threshold. That behavior can indeed be used as an automatic turn-off feature.
What we suspect here is not that this protection logic is wrong, but that the configuration shown in Zigbee2MQTT may not fully match the configuration that is actually active on the device. In other words, some protection-related settings may still be active internally even though they appear disabled in the UI.
What we are trying to verify is whether saving the settings again can overwrite the stale or not-yet-applied configuration on the device with the values currently shown in Zigbee2MQTT.
Could you please try explicitly disabling the minimum protection options and saving the configuration again? If needed, you can also change the related values once and then disable them again before saving, just to force the device to receive and apply the updated configuration.
This would help confirm whether the issue is caused by a configuration sync/write problem rather than by the protection feature itself behaving incorrectly.
— Reply to this email directly, view it on GitHub https://github.com/Koenkk/zigbee2mqtt/issues/31604#issuecomment-4203570669, or unsubscribe https://github.com/notifications/unsubscribe-auth/A57EUI54AEPEFSOYFJ3XFHT4UXAUVAVCNFSM6AAAAACXMSPK26VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DEMBTGU3TANRWHE . You are receiving this because you were mentioned.Message ID: @.***>
Hi,
at least simply applying the default displayed values in z2m with everything disabled fixed this issue for me.
Klaus Treichel @.***> schrieb am Mi., 8. Apr. 2026, 05:31:
Hi,
I can't enable the min protection featutes in 2.9.1 and i can't update to 2.9.2 because of the Danfoss ally issue. I need my thermostats working.
SONOFF CUBE @.***> schrieb am Mi., 8. Apr. 2026, 05:21:
CubeZ2mDeveloper left a comment (Koenkk/zigbee2mqtt#31604) https://github.com/Koenkk/zigbee2mqtt/issues/31604#issuecomment-4203570669
Hi,
If i think about the minimum overload protection settings then the plug is supposed to turn off if the power pulled is below min power and min power is enabled.
This could be used for an automatic turn off.
Klaus Treichel @.***> schrieb am Di., 7. Apr. 2026, 13:09: … <#m_5356172843290299526_m_5319085579168529675_>
Hi @ktreichel0 https://github.com/ktreichel0,
Yes, that makes sense.
If min power / min current protection is enabled, then the plug is expected to turn off once the measured value drops below the configured minimum threshold. That behavior can indeed be used as an automatic turn-off feature.
What we suspect here is not that this protection logic is wrong, but that the configuration shown in Zigbee2MQTT may not fully match the configuration that is actually active on the device. In other words, some protection-related settings may still be active internally even though they appear disabled in the UI.
What we are trying to verify is whether saving the settings again can overwrite the stale or not-yet-applied configuration on the device with the values currently shown in Zigbee2MQTT.
Could you please try explicitly disabling the minimum protection options and saving the configuration again? If needed, you can also change the related values once and then disable them again before saving, just to force the device to receive and apply the updated configuration.
This would help confirm whether the issue is caused by a configuration sync/write problem rather than by the protection feature itself behaving incorrectly.
— Reply to this email directly, view it on GitHub https://github.com/Koenkk/zigbee2mqtt/issues/31604#issuecomment-4203570669, or unsubscribe https://github.com/notifications/unsubscribe-auth/A57EUI54AEPEFSOYFJ3XFHT4UXAUVAVCNFSM6AAAAACXMSPK26VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DEMBTGU3TANRWHE . You are receiving this because you were mentioned.Message ID: @.***>
Hi,
I can't enable the min protection featutes in 2.9.1 and i can't update to 2.9.2 because of the Danfoss ally issue. I need my thermostats working.
SONOFF CUBE @.***> schrieb am Mi., 8. Apr. 2026, 05:21: …
Hi @ktreichel0,
Understood. I misinterpreted your previous comment.
Since you are staying on 2.9.1, please try the following external converter.
Save this as external_converters/s60zb.js and restart Zigbee2MQTT.
Alternatively, you can paste it in Settings -> Dev console -> External converters in the Zigbee2MQTT frontend.
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
const zigbee_herdsman_1 = require("zigbee-herdsman");
const fz = __importStar(require("zigbee-herdsman-converters/converters/fromZigbee"));
const exposes = __importStar(require("zigbee-herdsman-converters/lib/exposes"));
const m = __importStar(require("zigbee-herdsman-converters/lib/modernExtend"));
const reporting = __importStar(require("zigbee-herdsman-converters/lib/reporting"));
const utils = __importStar(require("zigbee-herdsman-converters/lib/utils"));
const defaultResponseOptions = { disableDefaultResponse: false };
const manufacturerCode = zigbee_herdsman_1.Zcl.ManufacturerCode.SHENZHEN_COOLKIT_TECHNOLOGY_CO_LTD;
const e = exposes.presets;
const ea = exposes.access;
const fzLocal = {
on_off_clear_electricity: {
cluster: "genOnOff",
type: ["attributeReport", "readResponse"],
options: [exposes.options.state_action()],
convert: (model, msg, publish, options, meta) => {
// Device keeps reporting current/power after turning OFF.
let result = fz.on_off.convert(model, msg, publish, options, meta);
if (msg.data.onOff === 0) {
result = { ...result, power: 0, current: 0 };
}
return result;
},
},
};
const sonoffExtend = {
addCustomClusterEwelink: () => {
return m.deviceAddCustomCluster("customClusterEwelink", {
name: "customClusterEwelink",
ID: 0xfc11,
attributes: {
networkLed: { name: "networkLed", ID: 0x0001, type: zigbee_herdsman_1.Zcl.DataType.BOOLEAN, write: true },
acCurrentCurrentValue: { name: "acCurrentCurrentValue", ID: 0x7004, type: zigbee_herdsman_1.Zcl.DataType.UINT32, write: true, max: 0xffffffff },
acCurrentVoltageValue: { name: "acCurrentVoltageValue", ID: 0x7005, type: zigbee_herdsman_1.Zcl.DataType.UINT32, write: true, max: 0xffffffff },
acCurrentPowerValue: { name: "acCurrentPowerValue", ID: 0x7006, type: zigbee_herdsman_1.Zcl.DataType.UINT32, write: true, max: 0xffffffff },
outlet_control_protect: { name: "outlet_control_protect", ID: 0x7007, type: zigbee_herdsman_1.Zcl.DataType.UINT8, write: true, max: 0xff },
energyToday: { name: "energyToday", ID: 0x7009, type: zigbee_herdsman_1.Zcl.DataType.UINT32, write: true, max: 0xffffffff },
energyMonth: { name: "energyMonth", ID: 0x700a, type: zigbee_herdsman_1.Zcl.DataType.UINT32, write: true, max: 0xffffffff },
energyYesterday: { name: "energyYesterday", ID: 0x700b, type: zigbee_herdsman_1.Zcl.DataType.UINT32, write: true, max: 0xffffffff },
},
commands: {
protocolData: { name: "protocolData", ID: 0x01, parameters: [{ name: "data", type: zigbee_herdsman_1.Zcl.BuffaloZclDataType.LIST_UINT8 }] },
},
commandsResponse: {},
});
},
inchingControlSet: (args = {}, maxTime = 3599.5) => {
const { endpointNames = undefined } = args;
const clusterName = "customClusterEwelink";
const commandName = "protocolData";
const exposes = utils.exposeEndpoints(e
.composite("inching_control_set", "inching_control_set", ea.SET)
.withDescription("Device inching function settings. The device will automatically turn off (turn on) " +
"after each turn on (turn off) for a specified period of time.")
.withFeature(e.binary("inching_control", ea.SET, "ENABLE", "DISABLE").withDescription("Enable/disable inching function."))
.withFeature(e
.numeric("inching_time", ea.SET)
.withDescription("Delay time for executing an inching action.")
.withUnit("seconds")
.withValueMin(0.5)
.withValueMax(maxTime)
.withValueStep(0.5))
.withFeature(e.binary("inching_mode", ea.SET, "ON", "OFF").withDescription("Set inching off or inching on mode.").withValueToggle("ON")), endpointNames);
const toZigbee = [
{
key: ["inching_control_set"],
convertSet: async (entity, key, value, meta) => {
let inchingControl = "inching_control";
let inchingTime = "inching_time";
let inchingMode = "inching_mode";
if (meta.endpoint_name) {
inchingControl = `inching_control_${meta.endpoint_name}`;
inchingTime = `inching_time_${meta.endpoint_name}`;
inchingMode = `inching_mode_${meta.endpoint_name}`;
}
const tmpTime = Number(Math.round(Number((value[inchingTime] * 2).toFixed(1))).toFixed(1));
const payloadValue = [];
payloadValue[0] = 0x01;
payloadValue[1] = 0x17;
payloadValue[2] = 0x07;
payloadValue[3] = 0x80;
payloadValue[4] = 0x00;
if (value[inchingControl] !== "DISABLE") {
payloadValue[4] |= 0x80;
}
if (value[inchingMode] !== "OFF") {
payloadValue[4] |= 0x01;
}
payloadValue[5] = meta.endpoint_name === "l2" ? 0x01 : 0x00;
payloadValue[6] = tmpTime & 0xff;
payloadValue[7] = (tmpTime >> 8) & 0xff;
payloadValue[8] = 0x00;
payloadValue[9] = 0x00;
payloadValue[10] = 0x00;
for (let i = 0; i < payloadValue[2] + 3; i++) {
payloadValue[10] ^= payloadValue[i];
}
await entity.command(clusterName, commandName, { data: payloadValue }, { manufacturerCode });
return { state: { [key]: value } };
},
},
];
return {
exposes,
fromZigbee: [],
toZigbee,
isModernExtend: true,
};
},
buildOverloadProtectionPayload: (value, powerMaxLimit, currentMaxLimit) => {
let maxCurrent = 1000 * Number(value.max_current ?? 0);
const minCurrent = 1000 * Number(value.min_current ?? 0);
const maxVoltage = 1000 * Number(value.max_voltage ?? 0);
const minVoltage = 1000 * Number(value.min_voltage ?? 0);
let maxPower = 1000 * Number(value.max_power ?? 0);
const minPower = 1000 * Number(value.min_power ?? 0);
const enableMinCurrent = value.enable_min_current;
const enableMaxVoltage = value.enable_max_voltage;
const enableMinVoltage = value.enable_min_voltage;
const enableMinPower = value.enable_min_power;
const payloadValue = new Uint8Array(30);
let index = 0;
payloadValue[index++] = 0;
payloadValue[index++] = 0x04;
payloadValue[index++] = 27;
payloadValue[index++] = 1;
payloadValue[index++] = 0;
payloadValue[index++] = 1;
if (maxCurrent === 0) {
maxCurrent = currentMaxLimit * 1000;
}
payloadValue[index++] = maxCurrent & 0xff;
payloadValue[index++] = (maxCurrent >> 8) & 0xff;
payloadValue[index++] = (maxCurrent >> 16) & 0xff;
payloadValue[index++] = (maxCurrent >> 24) & 0xff;
if (enableMinCurrent === "ENABLE") {
payloadValue[3] |= 2;
payloadValue[index++] = minCurrent & 0xff;
payloadValue[index++] = (minCurrent >> 8) & 0xff;
payloadValue[index++] = (minCurrent >> 16) & 0xff;
payloadValue[index++] = (minCurrent >> 24) & 0xff;
}
if (enableMaxVoltage === "ENABLE") {
payloadValue[4] |= 1;
payloadValue[index++] = maxVoltage & 0xff;
payloadValue[index++] = (maxVoltage >> 8) & 0xff;
payloadValue[index++] = (maxVoltage >> 16) & 0xff;
payloadValue[index++] = (maxVoltage >> 24) & 0xff;
}
if (enableMinVoltage === "ENABLE") {
payloadValue[4] |= 2;
payloadValue[index++] = minVoltage & 0xff;
payloadValue[index++] = (minVoltage >> 8) & 0xff;
payloadValue[index++] = (minVoltage >> 16) & 0xff;
payloadValue[index++] = (minVoltage >> 24) & 0xff;
}
if (maxPower === 0) {
maxPower = powerMaxLimit * 1000;
}
payloadValue[index++] = maxPower & 0xff;
payloadValue[index++] = (maxPower >> 8) & 0xff;
payloadValue[index++] = (maxPower >> 16) & 0xff;
payloadValue[index++] = (maxPower >> 24) & 0xff;
if (enableMinPower === "ENABLE") {
payloadValue[5] |= 2;
payloadValue[index++] = minPower & 0xff;
payloadValue[index++] = (minPower >> 8) & 0xff;
payloadValue[index++] = (minPower >> 16) & 0xff;
payloadValue[index++] = (minPower >> 24) & 0xff;
}
payloadValue[0] = index - 1;
payloadValue[2] = payloadValue[0] - 2;
if (payloadValue[3] === 3 && minCurrent >= maxCurrent) {
throw new Error("Invalid input: maximum current must be greater than the minimum current ");
}
if (payloadValue[4] === 3 && minVoltage >= maxVoltage) {
throw new Error("Invalid input: maximum voltage must be greater than the minimum voltage ");
}
if (payloadValue[5] === 3 && minPower >= maxPower) {
throw new Error("Invalid input: maximum power must be greater than the minimum power ");
}
return payloadValue.slice(0, index);
},
applyS60DefaultOverloadProtection: async (device, powerMaxLimit, currentMaxLimit) => {
if (device.meta.s60DefaultOverloadProtectionApplied === true) {
return;
}
const endpoint = device.getEndpoint(1);
const payloadValue = sonoffExtend.buildOverloadProtectionPayload({
enable_max_voltage: "ENABLE",
enable_min_current: "ENABLE",
enable_min_power: "ENABLE",
enable_min_voltage: "ENABLE",
max_current: currentMaxLimit,
max_power: powerMaxLimit,
max_voltage: 277,
min_current: 0.1,
min_power: 0.1,
min_voltage: 165,
}, powerMaxLimit, currentMaxLimit);
// The private payload always carries max current and power values as well.
await endpoint.write("customClusterEwelink", { [0x7003]: { value: payloadValue, type: 0x42 } }, defaultResponseOptions);
await endpoint.read("customClusterEwelink", [0x7003], defaultResponseOptions);
device.meta.s60DefaultOverloadProtectionApplied = true;
device.save();
},
overloadProtection: (powerMaxLimit, currentMaxLimit) => {
const exposes = e
.composite("overload_protection", "overload_protection", ea.ALL)
.withDescription("Over load protection, max power and max current are required,other is optional")
.withFeature(e
.numeric("max_power", ea.SET)
.withDescription("max power")
.withUnit("W")
.withValueMin(0.1)
.withValueMax(powerMaxLimit)
.withValueStep(0.1))
.withFeature(e.binary("enable_min_power", ea.SET, "ENABLE", "DISABLE").withDescription("Enable/disable lower limit of power overload protection."))
.withFeature(e
.numeric("min_power", ea.SET)
.withDescription("Lower limit of power overload protection")
.withUnit("W")
.withValueMin(0.1)
.withValueMax(powerMaxLimit)
.withValueStep(0.1))
.withFeature(e
.binary("enable_max_voltage", ea.SET, "ENABLE", "DISABLE")
.withDescription("Enable/disable upper limit of voltage overload protection.."))
.withFeature(e
.numeric("max_voltage", ea.SET)
.withDescription("Upper limit of voltage overload protection.")
.withUnit("V")
.withValueMin(165)
.withValueMax(277)
.withValueStep(1))
.withFeature(e
.binary("enable_min_voltage", ea.SET, "ENABLE", "DISABLE")
.withDescription("Enable/disable lower limit of voltage overload protection."))
.withFeature(e
.numeric("min_voltage", ea.SET)
.withDescription("Lower limit of voltage overload protection.")
.withUnit("V")
.withValueMin(165)
.withValueMax(277)
.withValueStep(1))
.withFeature(e
.numeric("max_current", ea.SET)
.withDescription("Upper limit of current overload protection.")
.withUnit("A")
.withValueMin(0.1)
.withValueMax(currentMaxLimit)
.withValueStep(0.1))
.withFeature(e
.binary("enable_min_current", ea.SET, "ENABLE", "DISABLE")
.withDescription("Enable/disable lower limit of current overload protection."))
.withFeature(e
.numeric("min_current", ea.SET)
.withDescription("Lower limit of current overload protection.")
.withUnit("A")
.withValueMin(0.1)
.withValueMax(currentMaxLimit)
.withValueStep(0.1));
const fromZigbee = [
{
cluster: "customClusterEwelink",
type: ["attributeReport", "readResponse"],
convert: (model, msg, publish, options, meta) => {
const attributeKey = 0x7003; // attr
if (attributeKey in msg.data) {
const rawData = msg.meta.rawData;
const dataStartIndex = 7;
let enableMaxCurrentBuffer = "DISABLE";
let enableMinCurrentBuffer = "DISABLE";
let enableMaxVoltageBuffer = "DISABLE";
let enableMinVoltageBuffer = "DISABLE";
let enableMinPowerBuffer = "DISABLE";
let enableMaxPowerBuffer = "DISABLE";
let maxCurrent = 0;
let minCurrent = 0;
let maxVoltage = 0;
let minVoltage = 0;
let maxActPower = 0;
let minActPower = 0;
const cfg_set_flag = rawData.readUInt8(1 + dataStartIndex);
let currentSetFlag = 0;
let voltageSetFlag = 0;
let actPowerSetFlag = 0;
let index = 3;
if (cfg_set_flag === 1) {
currentSetFlag = rawData.readUInt8(index + dataStartIndex);
index += 1;
}
else if (cfg_set_flag === 2) {
voltageSetFlag = rawData.readUInt8(index + dataStartIndex);
index += 1;
}
else if (cfg_set_flag === 3) {
actPowerSetFlag = rawData.readUInt8(index + dataStartIndex);
index += 1;
}
else if (cfg_set_flag === 4) {
currentSetFlag = rawData.readUInt8(index + dataStartIndex);
voltageSetFlag = rawData.readUInt8(index + 1 + dataStartIndex);
actPowerSetFlag = rawData.readUInt8(index + 2 + dataStartIndex);
index += 3;
}
if (currentSetFlag === 1) {
enableMaxCurrentBuffer = "ENABLE";
}
else if (currentSetFlag === 2) {
enableMinCurrentBuffer = "ENABLE";
}
else if (currentSetFlag === 3) {
enableMaxCurrentBuffer = "ENABLE";
enableMinCurrentBuffer = "ENABLE";
}
if (voltageSetFlag === 1) {
enableMaxVoltageBuffer = "ENABLE";
}
else if (voltageSetFlag === 2) {
enableMinVoltageBuffer = "ENABLE";
}
else if (voltageSetFlag === 3) {
enableMaxVoltageBuffer = "ENABLE";
enableMinVoltageBuffer = "ENABLE";
}
if (actPowerSetFlag === 1) {
enableMaxPowerBuffer = "ENABLE";
}
else if (actPowerSetFlag === 2) {
enableMinPowerBuffer = "ENABLE";
}
else if (actPowerSetFlag === 3) {
enableMaxPowerBuffer = "ENABLE";
enableMinPowerBuffer = "ENABLE";
}
if (enableMaxCurrentBuffer === "ENABLE") {
maxCurrent = rawData.readUint32LE(index + dataStartIndex) / 1000;
index += 4;
}
if (enableMinCurrentBuffer === "ENABLE") {
minCurrent = rawData.readUint32LE(index + dataStartIndex) / 1000;
index += 4;
}
if (enableMaxVoltageBuffer === "ENABLE") {
maxVoltage = rawData.readUint32LE(index + dataStartIndex) / 1000;
index += 4;
}
if (enableMinVoltageBuffer === "ENABLE") {
minVoltage = rawData.readUint32LE(index + dataStartIndex) / 1000;
index += 4;
}
if (enableMaxPowerBuffer === "ENABLE") {
maxActPower = rawData.readUint32LE(index + dataStartIndex) / 1000;
index += 4;
}
if (enableMinPowerBuffer === "ENABLE") {
minActPower = rawData.readUint32LE(index + dataStartIndex) / 1000;
index += 4;
}
return {
overload_protection: {
enable_max_voltage: enableMaxVoltageBuffer,
enable_min_current: enableMinCurrentBuffer,
enable_min_power: enableMinPowerBuffer,
enable_min_voltage: enableMinVoltageBuffer,
max_current: maxCurrent,
max_power: maxActPower,
max_voltage: maxVoltage,
min_current: minCurrent,
min_power: minActPower,
min_voltage: minVoltage,
},
};
}
},
},
];
const toZigbee = [
{
key: ["overload_protection"],
convertSet: async (entity, key, value, meta) => {
const payloadValue = sonoffExtend.buildOverloadProtectionPayload(value, powerMaxLimit, currentMaxLimit);
// Write the private overload-protection payload so the device stores concrete thresholds instead of leaving them unset.
await entity.write("customClusterEwelink", { [0x7003]: { value: payloadValue, type: 0x42 } }, defaultResponseOptions);
// Read back the private attribute immediately.
await entity.read("customClusterEwelink", [0x7003], defaultResponseOptions);
return { state: { [key]: value } };
},
convertGet: async (entity, key, meta) => {
await entity.read("customClusterEwelink", [0x7003], defaultResponseOptions);
},
},
];
return {
exposes: [exposes],
toZigbee,
fromZigbee,
isModernExtend: true,
};
},
s60OverloadProtection: (powerMaxLimit, currentMaxLimit) => {
const overloadProtection = sonoffExtend.overloadProtection(powerMaxLimit, currentMaxLimit);
return {
...overloadProtection,
configure: [
...(overloadProtection.configure ?? []),
async (device) => {
await sonoffExtend.applyS60DefaultOverloadProtection(device, powerMaxLimit, currentMaxLimit);
},
],
isModernExtend: true,
};
},
};
const definition = [
{
zigbeeModel: ["S60ZBTPF"],
model: "S60ZBTPF",
vendor: "SONOFF",
description: "Zigbee smart plug",
fromZigbee: [fzLocal.on_off_clear_electricity, fz.metering],
exposes: [e.energy()],
extend: [
m.onOff({
powerOnBehavior: true,
skipDuplicateTransaction: true,
configureReporting: true,
}),
sonoffExtend.addCustomClusterEwelink(),
m.binary({
name: "network_indicator",
cluster: "customClusterEwelink",
attribute: "networkLed",
description: "Turn the blue network indicator on or off.",
entityCategory: "config",
valueOff: [false, 0],
valueOn: [true, 1],
}),
m.numeric({
name: "current",
cluster: "customClusterEwelink",
attribute: "acCurrentCurrentValue",
description: "Current",
unit: "A",
access: "STATE_GET",
reporting: { min: "10_SECONDS", max: "MAX", change: 2 },
fzConvert: (model, msg, publish, options, meta) => {
if ("acCurrentCurrentValue" in msg.data) {
return { current: meta.state.state === "ON" ? msg.data.acCurrentCurrentValue / 1000 : 0 };
}
},
}),
m.numeric({
name: "voltage",
cluster: "customClusterEwelink",
attribute: "acCurrentVoltageValue",
description: "Voltage",
unit: "V",
scale: 1000,
access: "STATE_GET",
}),
m.numeric({
name: "power",
cluster: "customClusterEwelink",
attribute: "acCurrentPowerValue",
description: "Active power",
unit: "W",
access: "STATE_GET",
reporting: { min: "10_SECONDS", max: "MAX", change: 0 },
fzConvert: (model, msg, publish, options, meta) => {
if ("acCurrentPowerValue" in msg.data) {
return { power: meta.state.state === "ON" ? msg.data.acCurrentPowerValue / 1000 : 0 };
}
},
}),
m.numeric({
name: "energy_yesterday",
cluster: "customClusterEwelink",
attribute: "energyYesterday",
description: "Electricity consumption for yesterday",
unit: "kWh",
scale: 1000,
access: "STATE_GET",
}),
m.numeric({
name: "energy_today",
cluster: "customClusterEwelink",
attribute: "energyToday",
description: "Electricity consumption for today",
unit: "kWh",
scale: 1000,
access: "STATE_GET",
}),
m.numeric({
name: "energy_month",
cluster: "customClusterEwelink",
attribute: "energyMonth",
description: "Electricity consumption for this month",
unit: "kWh",
scale: 1000,
access: "STATE_GET",
}),
sonoffExtend.inchingControlSet(),
m.binary({
name: "outlet_control_protect",
cluster: "customClusterEwelink",
attribute: "outlet_control_protect",
description: "Outlet overload protection setting",
valueOff: [false, 0],
valueOn: [true, 1],
}),
sonoffExtend.s60OverloadProtection(4000, 17),
],
ota: true,
configure: async (device, coordinatorEndpoint) => {
const endpoint = device.getEndpoint(1);
await reporting.bind(endpoint, coordinatorEndpoint, ["genOnOff", "customClusterEwelink", "seMetering"]);
await reporting.onOff(endpoint, { min: 1, max: 1800, change: 0 });
await endpoint.read("customClusterEwelink", ["acCurrentCurrentValue", "acCurrentVoltageValue", "acCurrentPowerValue", 0x7003, "outlet_control_protect"], defaultResponseOptions);
await endpoint.configureReporting("customClusterEwelink", [
{ attribute: "energyMonth", minimumReportInterval: 60, maximumReportInterval: 3600, reportableChange: 50 },
{ attribute: "energyYesterday", minimumReportInterval: 60, maximumReportInterval: 3600, reportableChange: 50 },
{ attribute: "energyToday", minimumReportInterval: 60, maximumReportInterval: 3600, reportableChange: 50 },
]);
await endpoint.read("seMetering", ["multiplier", "divisor"]);
await reporting.currentSummDelivered(endpoint);
},
},
{
zigbeeModel: ["S60ZBTPG"],
model: "S60ZBTPG",
vendor: "SONOFF",
description: "Zigbee smart plug",
fromZigbee: [fzLocal.on_off_clear_electricity, fz.metering],
exposes: [e.energy()],
extend: [
m.onOff({
powerOnBehavior: true,
skipDuplicateTransaction: true,
configureReporting: true,
}),
sonoffExtend.addCustomClusterEwelink(),
m.binary({
name: "network_indicator",
cluster: "customClusterEwelink",
attribute: "networkLed",
description: "Network indicator settings, turn off/on the blue online status network indicator.",
entityCategory: "config",
valueOff: [false, 0],
valueOn: [true, 1],
}),
m.numeric({
name: "current",
cluster: "customClusterEwelink",
attribute: "acCurrentCurrentValue",
description: "Current",
unit: "A",
access: "STATE_GET",
// https://github.com/Koenkk/zigbee2mqtt/issues/28470#issuecomment-3369116710
reporting: { min: "10_SECONDS", max: "MAX", change: 2 },
fzConvert: (model, msg, publish, options, meta) => {
// Device keeps reporting a acCurrentCurrentValue after turning OFF.
// Make sure power = 0 when turned OFF
// https://github.com/Koenkk/zigbee2mqtt/issues/28470
if ("acCurrentCurrentValue" in msg.data) {
return { current: meta.state.state === "ON" ? msg.data.acCurrentCurrentValue / 1000 : 0 };
}
},
}),
m.numeric({
name: "voltage",
cluster: "customClusterEwelink",
attribute: "acCurrentVoltageValue",
description: "Voltage",
unit: "V",
scale: 1000,
access: "STATE_GET",
}),
m.numeric({
name: "power",
cluster: "customClusterEwelink",
attribute: "acCurrentPowerValue",
description: "Active power",
unit: "W",
access: "STATE_GET",
reporting: { min: "10_SECONDS", max: "MAX", change: 0 },
fzConvert: (model, msg, publish, options, meta) => {
// Device keeps reporting a acCurrentPowerValue after turning OFF.
// Make sure power = 0 when turned OFF
// https://github.com/Koenkk/zigbee2mqtt/issues/28470
if ("acCurrentPowerValue" in msg.data) {
return { power: meta.state.state === "ON" ? msg.data.acCurrentPowerValue / 1000 : 0 };
}
},
}),
m.numeric({
name: "energy_yesterday",
cluster: "customClusterEwelink",
attribute: "energyYesterday",
description: "Electricity consumption for the yesterday",
unit: "kWh",
scale: 1000,
access: "STATE_GET",
}),
m.numeric({
name: "energy_today",
cluster: "customClusterEwelink",
attribute: "energyToday",
description: "Electricity consumption for the day",
unit: "kWh",
scale: 1000,
access: "STATE_GET",
}),
m.numeric({
name: "energy_month",
cluster: "customClusterEwelink",
attribute: "energyMonth",
description: "Electricity consumption for the month",
unit: "kWh",
scale: 1000,
access: "STATE_GET",
}),
sonoffExtend.inchingControlSet(),
m.binary({
name: "outlet_control_protect",
cluster: "customClusterEwelink",
attribute: "outlet_control_protect",
description: "Outlet overload protection Settings",
valueOff: [false, 0],
valueOn: [true, 1],
}),
sonoffExtend.s60OverloadProtection(3250, 14),
],
ota: true,
configure: async (device, coordinatorEndpoint) => {
const endpoint = device.getEndpoint(1);
await reporting.bind(endpoint, coordinatorEndpoint, ["genOnOff", "customClusterEwelink", "seMetering"]);
await reporting.onOff(endpoint, { min: 1, max: 1800, change: 0 });
await endpoint.read("customClusterEwelink", ["acCurrentCurrentValue", "acCurrentVoltageValue", "acCurrentPowerValue", 0x7003, "outlet_control_protect"], defaultResponseOptions);
await endpoint.configureReporting("customClusterEwelink", [
{ attribute: "energyMonth", minimumReportInterval: 60, maximumReportInterval: 3600, reportableChange: 50 },
{ attribute: "energyYesterday", minimumReportInterval: 60, maximumReportInterval: 3600, reportableChange: 50 },
{ attribute: "energyToday", minimumReportInterval: 60, maximumReportInterval: 3600, reportableChange: 50 },
]);
await endpoint.read("seMetering", ["multiplier", "divisor"]);
await reporting.currentSummDelivered(endpoint);
},
},
];
module.exports = definition;
Please let us know whether this changes the behavior.