zigbee-herdsman-converters icon indicating copy to clipboard operation
zigbee-herdsman-converters copied to clipboard

Innr SP-242 Smart Plug not reporting status automatically

Open davmc123 opened this issue 1 year ago • 124 comments

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

davmc123 avatar Dec 21 '23 01:12 davmc123

@ukgrant can you confirm this issue?

Koenkk avatar Dec 21 '23 06:12 Koenkk

Yes, I've just tested these steps and it behaves exactly as described by @davmc123 :( Any ideas what the cause could be?

ukgrant avatar Dec 21 '23 11:12 ukgrant

Pushed a fix, let me know if it works.

Changes will be available in the dev branch in a few hours from now.

Koenkk avatar Dec 22 '23 07:12 Koenkk

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

davmc123 avatar Dec 23 '23 17:12 davmc123

Could you provide the debug log of this?

See this on how to enable debug logging.

Koenkk avatar Dec 24 '23 07:12 Koenkk

log_short.txt log.txt

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.

davmc123 avatar Dec 25 '23 00:12 davmc123

I would expect a "device announce" when the device is plugged back into power, @ukgrant does it do this in your case?

Koenkk avatar Dec 25 '23 08:12 Koenkk

I've tested and no announcement is published when power cycling this device. Others do...

ukgrant avatar Dec 27 '23 11:12 ukgrant

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.

Koenkk avatar Dec 27 '23 12:12 Koenkk

Just FYI: The Innr SP-240 device suffers from exactly the same bug.

remybohmer avatar Jan 02 '24 17:01 remybohmer

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)

Koenkk avatar Jan 02 '24 21:01 Koenkk

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?

WhimsySpoon avatar Jan 03 '24 06:01 WhimsySpoon

Could this be a side effect of this issue or the work around?

No workaround has been implemented as of now.

Koenkk avatar Jan 03 '24 08:01 Koenkk

Apologies, I meant the action of going into the reporting menu and hitting apply on the various endpoints.

WhimsySpoon avatar Jan 03 '24 10:01 WhimsySpoon

What is the issue with this?

Koenkk avatar Jan 03 '24 12:01 Koenkk

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.

WhimsySpoon avatar Jan 03 '24 12:01 WhimsySpoon

FYI, my SP-242 device, same fw 1.4.3, exhibits the same issues reported.

ablig77 avatar Jan 13 '24 12:01 ablig77

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.

jwmcintosh avatar Jan 24 '24 17:01 jwmcintosh

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 avatar Feb 23 '24 14:02 jrossouw777

@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

leander091 avatar Feb 23 '24 14:02 leander091

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?

andyjayh avatar Mar 03 '24 17:03 andyjayh

No updates from Innr yet

Koenkk avatar Mar 03 '24 17:03 Koenkk

Shame as these look potentially good plugs.

Thanks for confirming no update yet, means I’m not missing anything from my OTA setting.

andyjayh avatar Mar 03 '24 17:03 andyjayh

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)

trinode avatar Mar 12 '24 00:03 trinode

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.

ablig77 avatar Mar 12 '24 10:03 ablig77

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

trinode avatar Mar 23 '24 14:03 trinode

I have an SP240 but your script works like a charm after a few adaptions.

Thanks

rurlaender avatar Mar 23 '24 16:03 rurlaender

@trinode,

  1. 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.
  2. 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 avatar Mar 24 '24 15:03 jrossouw777

@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:-

  1. Yes in the same folder as the Z2M configuration.yaml
  2. the sections can be in any order, but make sure you're not messing up the configuration and make sure your indentation is correct.

trinode avatar Mar 24 '24 16:03 trinode

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?

thebatfink avatar Mar 29 '24 10:03 thebatfink