zigbee-herdsman-converters
zigbee-herdsman-converters copied to clipboard
Innr SP-242 Smart Plug not reporting status automatically
The device support recently added in PR: Add device support for: Innr SP-242 Smart Plug #6703, does not seem to be reporting status information and sensor readings automatically. They only update when the 'Refresh' buttons are pressed in the Z2M 'Exposes' tab. This includes switch 'State', 'Power', 'Voltage' and 'Current'.
If I press the 'Apply' button for each item listed in the 'Reporting' settings menu, the smart plug will start reporting the sensors automatically, one by one.
If the smart plug is unplugged and plugged in again (power cycled) it stops reporting automatically. Pressing the 'Apply' button again for each item allows the automatic reporting to continue.
Smart Plug Info
Zigbee Model | SP 242 |
Firmware build date | 20231019 |
Firmware version | 1.4.3 |
Zigbee2MQTT Info
Zigbee2MQTT Bridge Coordinator Version | 6.10.3.0 build 297 |
Zigbee2MQTT Bridge Version | 1.34.0-dev |
@ukgrant can you confirm this issue?
Yes, I've just tested these steps and it behaves exactly as described by @davmc123 :( Any ideas what the cause could be?
Pushed a fix, let me know if it works.
Changes will be available in the dev branch in a few hours from now.
Updated to the latest Z2M development image, but still getting the same behaviour where reporting stops working after a power cycle of the smart plug
Zigbee2MQTT version 1.34.0-dev commit: 1a72650 Coordinator type EZSP v8 Coordinator revision 6.10.3.0 build 297
Frontend version 0.6.149 Zigbee-herdsman-converters version 16.17.0 Zigbee-herdsman version 0.28.0
Powered off the Smart Plug "Innr Smart Plug 2" at 23:09:40 and back on at 23:10:00, I'm not sure if the log is really showing anything useful though.
"Innr Smart Plug 2" doesn't appear again in the log until 23:26:13 when I some switch on/off commands from home assistant
I also attached the full log file but I don't think it will provide any more insight than the short one.
I would expect a "device announce" when the device is plugged back into power, @ukgrant does it do this in your case?
I've tested and no announcement is published when power cycling this device. Others do...
Then I cannot solve this problem from Z2M, it has to be fixed in the firmware. I've notified my contact person at Innr about this issue.
Just FYI: The Innr SP-240 device suffers from exactly the same bug.
Innr confirmed this issue and is looking into a solution, once fixed they will probably provide an OTA update (which can be done via Z2M)
I have the SP 242 with the same issues. Fortunately mine won't often be power cycled, so I hit the various apply buttons in the Reporting tab and it's been working well.
I have however noticed the green button flashes at random intervals. I can find no mention of this in any documentation. Could this be a side effect of this issue or the work around?
Could this be a side effect of this issue or the work around?
No workaround has been implemented as of now.
Apologies, I meant the action of going into the reporting menu and hitting apply on the various endpoints.
What is the issue with this?
It might not be an issue; I just wouldn't expect the power button to flash rapidly for a few seconds every minute or so, especially when the device state is off. It almost looks as if it's in a pairing mode (which it isn't).
I'll raise it with Innr directly as it's probably not related to this issue and I don't want to derail this issue any further.
FYI, my SP-242 device, same fw 1.4.3, exhibits the same issues reported.
Chiming in with SP244's exhibiting the same issue. fwiw
edit: I've been in contact with Innr and they report their expected ETA for the firmware update is Feb 20. It will be turned over immediately to the Z2M team for a commit to their code, after which we will be able to update the plugs themselves.
Eagerly awaiting this firmware upgrade. I don't currently see my two SP 242 plugs under the OTA section on Z2M. Is that expected? I do see my other SP 222 plugs in there so thought I'd check to see if you guys are seeing the same?
@jrossouw777, Zigbee2mqtt allows only the OTA capability when there is firmware available in the Zigbee-OTA repo. So until then the device won't show in the OTA section
Just bought myself a few SP 242’s with f/w 1.4.3 to then stumble across this issue. I’ve tried hitting the Apply button for all lines in the reporting tab but after 24hrs only 1 out of 4 plugs is still reporting back.
Any news on the firmware update from Innr?
No updates from Innr yet
Shame as these look potentially good plugs.
Thanks for confirming no update yet, means I’m not missing anything from my OTA setting.
Is there a way to programatically set the reporting intervals via HA scripts or similar whilst we wait for a firmware?
The fix for the firmware, is that to remember the reporting interval across power cycles, or just to broadcast an announce message when power is restored? (Looks like there's logic to reapply the intervals if an announce occurs in that potential fix that was merged)
Eagerly awaiting this firmware upgrade. I don't currently see my two SP 242 plugs under the OTA section on Z2M. Is that expected? I do see my other SP 222 plugs in there so thought I'd check to see if you guys are seeing the same?
I have several SP 222 which do not exhibit the same problems.
To answer my own question, while we wait for a firmware update we can update the configuration to use polling to update the stats regularly (every 60s by default):
I've stolen the method the tuya plugs with the same issue use, and inlined it in this definition so it won't break if the tuya method is modified / removed.
As per that implementation there's a field called Measurement poll interval
to set the number of seconds between stat updates.
Definition file:-
SP242.js
const {onOff, electricityMeter} = require('zigbee-herdsman-converters/lib/modernExtend');
const exposes = require('zigbee-herdsman-converters/lib/exposes');
const globalStore = require('zigbee-herdsman-converters/lib/store');
const utils = require('zigbee-herdsman-converters/lib/utils');
const fz = require('zigbee-herdsman-converters/converters/fromZigbee');
const tz = require('zigbee-herdsman-converters/converters/toZigbee');
const e = exposes.presets;
const ea = exposes.access;
async function onEventMeasurementPoll(type, data, device, options,
electricalMeasurement=true, metering=false) {
const endpoint = device.getEndpoint(1);
if (type === 'stop') {
clearTimeout(globalStore.getValue(device, 'measurement_poll'));
globalStore.clearValue(device, 'measurement_poll');
} else if (!globalStore.hasValue(device, 'measurement_poll')) {
const seconds = utils.toNumber(
options && options.measurement_poll_interval ? options.measurement_poll_interval : 60, 'measurement_poll_interval');
if (seconds === -1) return;
const setTimer = () => {
const timer = setTimeout(async () => {
try {
if (electricalMeasurement) {
await endpoint.read('haElectricalMeasurement', ['rmsVoltage', 'rmsCurrent', 'activePower']);
}
} catch (error) {/* Do nothing*/}
try {
if (metering) {
await endpoint.read('seMetering', ['currentSummDelivered']);
}
} catch (error) {/* Do nothing*/}
setTimer();
}, seconds * 1000);
globalStore.putValue(device, 'measurement_poll', timer);
};
setTimer();
}
}
const definition = {
zigbeeModel: ['SP 242'],
model: 'SP 242',
vendor: 'Innr',
description: 'Automatically generated definition',
extend: [onOff({"powerOnBehavior":false}), electricityMeter({current: {divisor: 1000}, voltage: {divisor: 1}, power: {divisor: 1}, energy: {divisor: 100}})],
meta: {},
options: [exposes.options.measurement_poll_interval()],
onEvent: (type, data, device, options) =>
onEventMeasurementPoll(type, data, device, options,
true, // polling for voltage, current and power
true, // polling for energy
),
};
module.exports = definition;
add the file as an external definition in the configuration.yaml file:-
external_converters:
- SP242.js
I have an SP240 but your script works like a charm after a few adaptions.
Thanks
@trinode,
- Can you please confirm where I should place the js file? I've never needed to create an external converter so I'm not familiar with doing this.
- Am I correct in saying that the reference to the file should be added to the bottom of the configuration.yaml file under zigbee2mqtt folder?
Thanks!
@jrossouw777
Full instructions for creating / using external definitions are here: https://www.zigbee2mqtt.io/advanced/support-new-devices/01_support_new_devices.html
But to answer those questions:-
- Yes in the same folder as the Z2M configuration.yaml
- the sections can be in any order, but make sure you're not messing up the configuration and make sure your indentation is correct.
Thanks for this, seems to work well as a temporary workaround. Whats the likelihood they’ll actually fix this firmware, do they have a good history?