Koenkk / zigbee-herdsman-converters

Collection of device converters to be used with zigbee-herdsman
MIT License
869 stars 2.86k forks source link

Innr SP-242 Smart Plug not reporting status automatically #6747

Open davmc123 opened 7 months ago

davmc123 commented 7 months ago

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
Koenkk commented 7 months ago

@ukgrant can you confirm this issue?

ukgrant commented 7 months ago

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

Koenkk commented 7 months ago

Pushed a fix, let me know if it works.

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

davmc123 commented 7 months ago

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

Koenkk commented 7 months ago

Could you provide the debug log of this?

See this on how to enable debug logging.

davmc123 commented 7 months ago

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.

Koenkk commented 7 months ago

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

ukgrant commented 7 months ago

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

Koenkk commented 7 months ago

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.

remybohmer commented 7 months ago

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

Koenkk commented 7 months ago

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)

WhimsySpoon commented 6 months ago

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?

Koenkk commented 6 months ago

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

No workaround has been implemented as of now.

WhimsySpoon commented 6 months ago

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

Koenkk commented 6 months ago

What is the issue with this?

WhimsySpoon commented 6 months ago

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.

ablig77 commented 6 months ago

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

jwmcintosh commented 6 months ago

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.

jrossouw777 commented 5 months ago

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?

leander091 commented 5 months ago

@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

andyjayh commented 4 months ago

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?

Koenkk commented 4 months ago

No updates from Innr yet

andyjayh commented 4 months ago

Shame as these look potentially good plugs.

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

trinode commented 4 months ago

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)

ablig77 commented 4 months ago

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.

trinode commented 4 months ago

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
rurlaender commented 4 months ago

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

Thanks

jrossouw777 commented 4 months ago

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

trinode commented 4 months ago

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

thebatfink commented 4 months ago

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?

jwmcintosh commented 3 months ago

I reached out again to Innr for an update and they've gone in to deflect mode, right or wrong. Here is their update if it helps anyone that understand this more than I, and perhaps a little of the above fixes coincide.


Unfortunately, the update for these plugs is still not finished. I did get some new insights from our team, about what the update will do, and which functions are dependent on the hub with which the plug is used.

The following information is what our engineer told me about the SP 244 version: The SP 24x reports voltage, current, and active power to any other interested device (for example a hub/bridge) that creates a binding to the Electrical Measurement cluster on the SP 24x. The SP 24x supports the Configure Attribute Reporting command to let the receiving device determine the intervals with which data is reported. The SP 24x does NOT report attributes autonomously, without being asked to do so by a binding to the cluster. Tuya based smart plugs do this, always to address 0x0000, and quite possibly also the old Innr SP 120 may do this, but this is not Zigbee compliant! Address 0x0000 is usually the hub in a system but not necessarily, and in addition there may be other devices in a system than the hub on other addresses that may be interested in the attribute reports.

The “CurrentSummationDelivered” attribute of the Metering cluster is not defined as reportable by Zigbee and therefore not reported by the SP 24x. Interested devices must regularly retrieve the value, or retrieve it on demand when the user wants to see it.

If the SP 24x seems to report updates irregularly, or slowly, or not at all, please check with the manufacturer of your hub or ask the community of your open source system for help, before contacting Innr support.

Note: there is a known problem that the SP 24x stops reporting attributes after a power-cycle (unplugging and re-plugging); it seems the bindings are not persistently remembered. We are working on a fix. The SP 24x starts reporting attributes again if the interested device creates a binding again and/or calls the Configure Attribute Reporting again, so in most systems a work-around is to re-apply the settings. In the Homey system, a work-around is to uninstall and re-install the Innr Homey app. In systems where this is not possible, the only currently available solution is to remove the device from the network and pair it again. The easiest solution however is not to power-cycle the SP 24x and leave it plugged in. If the plug is switched off (the plug, not the appliance connected to it), power consumption is less than 0.35W.

I hope that this information helps. If the issue from your first message still isn't resolved, could you give me a bit of a more elaborate explanation about the issue that you see?

We hope that the issue can be resolved with this information. If you have any questions or feedback for us, let us know.

thebatfink commented 3 months ago

Hi, off topic from stats but I’m not sure where to ask were other owners are congregating. Don’t suppose anyone has experienced these plugs turning themselves off and back on again? I do have the manual polling in place, not sure how that would cause the issue though. I had one on the machine running my HA instance, which was seemingly randomly powering off and when it did this last I actually heard another of the switches in a different room power off too (I heard its relay engage) as the same time. Not sure if they turned off at the same time or it was in response to the coordinator disappearing.. I’ve since removed the one from the HA machine so it doesn’t kill my HA/z2m instance to see if it logs any of the others doing this going forward. Curious if any one else has seen this?

megakid commented 3 months ago

I think I’ve seen this. I’ve got one for power monitoring my washing machine and twice in 3 months has my machine not finished a cycle due to power failure.

Disappointing

On Tue, 9 Apr 2024 at 07:42, thebatfink @.***> wrote:

Hi, off topic from stats but I’m not sure where to ask were other owners are congregating. Don’t suppose anyone has experienced these plugs turning themselves off and back on again? I do have the manual polling in place, not sure how that would cause the issue though.

— Reply to this email directly, view it on GitHub https://github.com/Koenkk/zigbee-herdsman-converters/issues/6747#issuecomment-2044255229, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALI2422HKZ6O7VOKLOMRTTY4OEWNAVCNFSM6AAAAABA5URR2GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANBUGI2TKMRSHE . You are receiving this because you are subscribed to this thread.Message ID: @.***>

markormesher commented 3 months ago

I've seen the same behaviour with mine. I have two and they both seem to do it at exactly the same time. They were both powered up at the same time too, so I wonder whether there's some timeout or overflow in the firmware causing them to toggle. I've set up an alert to catch it next time it happens and I'll see if anything interesting is logged - if so I'll also email Innr support and post it here.

WhimsySpoon commented 3 months ago

I have two that have been relegated to the cupboard. I mentioned further up in the thread that they would just stop responding, flashing the LED, until manually power cycled.

Innr confirmed this is a safety feature that shuts down the device when a voltage greater than 253v is detected. There may be some calibration issues as I conducted some experiments where I monitored the voltage independently and they shut down at voltages lower than 253v.

Adjusting the voltage offsets in z2m didn't make a difference unfortunately.

Edit: Corrected shutdown voltage from 230v to 253v.

ablig77 commented 3 months ago

Yes, the same experience with the Innr SP242, shutting down for no apparent reason. Comparatively, my Innr SP222 sockets do not appear to have the same 'shutdown' behaviour.

thebatfink commented 3 months ago

Hmm, seems its common then. What intrigued me was how two went off very close together, potentially in unison. One was on the output of a UPS too, maybe it passes through when its not in battery mode (with regards to previous comment on voltage, I expected some circuitry which may or may not do some smoothing) so not sure mine were being triggered by this 253v cutoff. They also turned themselves back on shortly after they turned off, I didnt need to press the power button. But I didnt look to see what colour the light was at the time.

Presumably this can only be a hardware / firmware issue and nothing influenced from z2m?

markormesher commented 3 months ago

They also turned themselves back on shortly after they turned off

That's what I've seen too - they turn off and back on almost immediately, with no need for me to intervene. They stay paired to the network and continue to report power usage as soon as they turn back on. I'm waiting for it to happen again to see if Z2M records any log of the plug turning off and back on, and how quickly it really happens.

thebatfink commented 3 months ago

I already checked, one of mine did it this morning. In HA at 07:25:34 ‘turned off’ then at 07:25:41 ‘turned on’ reported in the device logs. At this time in z2m, I see off and on messages too:

info 2024-04-09 07:25:07: MQTT publish: topic 'zigbee2mqtt/SynologyDS1821', payload '{"current":0.3,"energy":16.65,"linkquality":127,"power":62,"power_on_behavior":"on","state":"ON","voltage":252}' info 2024-04-09 07:25:34: MQTT publish: topic 'zigbee2mqtt/SynologyDS1821', payload '{"current":0.3,"energy":16.65,"linkquality":123,"power":62,"power_on_behavior":"on","state":"OFF","voltage":252}' info 2024-04-09 07:25:37: MQTT publish: topic 'zigbee2mqtt/SynologyDS1821', payload '{"current":0.3,"energy":16.65,"linkquality":127,"power":3,"power_on_behavior":"on","state":"OFF","voltage":252}' info 2024-04-09 07:25:39: MQTT publish: topic 'zigbee2mqtt/SynologyDS1821', payload '{"current":0,"energy":16.65,"linkquality":127,"power":3,"power_on_behavior":"on","state":"OFF","voltage":252}' info 2024-04-09 07:25:41: MQTT publish: topic 'zigbee2mqtt/SynologyDS1821', payload '{"current":0,"energy":16.65,"linkquality":123,"power":3,"power_on_behavior":"on","state":"ON","voltage":252}' info 2024-04-09 07:25:47: MQTT publish: topic 'zigbee2mqtt/SynologyDS1821', payload '{"current":0,"energy":16.65,"linkquality":127,"power":40,"power_on_behavior":"on","state":"ON","voltage":252}'

So they aren’t disconnecting, they are literally turning on and off and I know this one turned off here as I have a Synology NAS plugged in this 3rd plug and it emailed me to say it shut down incorrectly too. These plugs are pretty much trash right now for me and I brought 5 before I realised they were doing this :(

I wonder if they are shutting off because of sensed over voltage like Whimsy says. Mine was reporting up at 252.. What voltage are yours reporting? Are they getting up this high?

Editted as I screwed up all the times!

markormesher commented 3 months ago

My two are currently reporting 244v and 250v (so we know the accuracy isn't outstanding). I'm only recording power usage at the moment but I'm going to add voltage to the persisted metrics tonight and see whether any spikes line up with the bad behaviour.

thebatfink commented 3 months ago

I just realised I transposed the minutes and seconds so I was looking at the wrong time in the logs. I did find the z2m log which corresponds to HA seeing the plug go off. It messaged power state off and on again, so it definitely turned on and off and it wasnt me. I updated my last comment.

The voltage is also part of all the messages in z2m (although I added mine to HA now too to visualise it). Mine were up at 252 when it power cycled, the 253 cutoff could indeed be the culprit in my case.

Edit: I also just dug back on another of the 5 plugs, 3 days ago one power cycled at 1am in the morning. This is now 4 of the 5 plugs confirmed to be power cycling. This plug was already enabled in HA for voltage. The power cycle also coincided with a reported voltage spike. I think its the 253v safety switch Whimsy identified.

Voltage history: https://imgur.com/a/gr7DzDn Power State history: https://imgur.com/a/FgzOxdX

This is the same plug today. Around 7am it was reporting voltages ranging from 240 to 252.. https://imgur.com/a/IF954cv

I sent a message to support. If they won’t address this all 5 plugs are going back. I guess 253v was chosen as a google search suggests this is the maximum declared voltage considered in tolerance in the UK. But if the plugs only measure to an accuracy of +- X volt (they aren’t Fluke multimeters so presumably some error exists), then the over volt needs to be 253 + X at least. You can even see in my first ‘voltage history’ image, immediately after it power cycled the switch it immediately started reading a completely different stable voltage to the previous hours readings.. Urgh, what a waste of money.

WhimsySpoon commented 3 months ago

This is the exact message I received from Innr:

Our engineer sent us a message about this rapid flashing that you saw.

His comment:

That’s the overload protection: In EU/UK, if voltage is > 253V or < 176V for longer than 4 seconds, plug switches off and fast-blinks. If over/undervoltage condition goes away and stays away longer than 4 seconds, plug automatically goes back to previous state (off or on) and stops blinking. If current > 16.8A (EU) or > 13.7A (UK), plug switches off and fast-blinks, and this state can only be exited by manual control (button) or power-cycle.

So, the rapid flashing happens when the plug notices an irregularity in the power supplied.

I had both plugged into the same 2 gang socket for a few days, whilst also using a clamp and a voltmeter to measure the voltage. The latter was logging into HA so I could record the metrics. Sometimes one would "shut down" sometimes both. At no point did I record a voltage greater than 253v on the clamp.

househead commented 3 months ago

I was using the custom convertor posted by @trinode quite successfully for a few days, and now suddenly today, it has stopped working and reverted to the previous behaviour. I've not updated HA nor Zigbee2MQTT. Would rather not reset the plug or its pairing as it resets counters (although I do have a utility meter helper derived from the energy change).

Any ideas?

thebatfink commented 3 months ago

Did you validate the configuration and js file is still there? Is it still actually connected to the network, maybe it fell off? Any errors in the logs? All 5 of mine continue to work OK at least with 60 second intervals.

On the over voltage issue, I validated with a Shelly EM connected directly to the incoming mains cabling in my consumer box and a TP Link switch that my mains voltage is occasionally spiking very briefly to 253-255 volt. All three devices see the same spikes at the same time, albeit with marginally different voltage reasons. I’ve come to the conclusion that the plugs are most likely functioning fine, but the firmware is (in my case at least) too aggressive with the over volt protection. I wouldn't know where to start getting the mains voltage changed - if anyone would be even interested in listening to me.

househead commented 3 months ago

Did you validate the configuration and js file is still there? Is it still actually connected to the network, maybe it fell off? Any errors in the logs? All 5 of mine continue to work OK at least with 60 second intervals.

Yea, did all those things and a few more - unbound everything and rebound it in zigbee2mqtt and also "reconfigured" it (not entirely sure what this actually does).

It did all work again for a very short period, but now the total energy used is not polling, whilst voltage, current, power etc are. Very strange. It always updates when I refresh it in zigbee2mqtt's "expose" panel.

megakid commented 3 months ago

I have two that have been relegated to the cupboard. I mentioned further up in the thread that they would just stop responding, flashing the LED, until manually power cycled.

Innr confirmed this is a safety feature that shuts down the device when a voltage greater than 253v is detected. There may be some calibration issues as I conducted some experiments where I monitored the voltage independently and they shut down at voltages lower than 253v.

Adjusting the voltage offsets in z2m didn't make a difference unfortunately.

Edit: Corrected shutdown voltage from 230v to 253v.

Mine are also now unplugged and unused. I would not recommend these to anyone in the UK because of these two issues:

WhimsySpoon commented 3 months ago

I would not recommend these to anyone in the UK

Agreed. I replaced mine with one of these. Been working flawlessly for months. The led always on, and it is a bit bright, but mine is out of sight so not an issue

Aurora AOne Zigbee 13A Plug-In Adaptor UK Smart Socket (ZigBee 3.0) With Power Monitoring, Works with Home Assistant Zigbee2MQTT / ZHA https://amzn.eu/d/18N96Ul

digital-cowboy-91 commented 3 months ago

Oh gents. Thanks for this thread. It's 2AM and I am trying to find out a second night in a row why my devices are randomly turning ON/OFF. I had dehumidifier plugged in one of these and it woke me several times at night with loud beep what it does on power ON. This is very frustrating. Today the dehumidifer has started beeping again around midnight and since then it powercycled like 10 times. So I've put together to one power strip both plugs from one pack with no load and I can definitely see both having this behaviour/issue but they do not power cycle at the same time, it's very random. Currently while writing this message both are power cycling like lights on Christmas tree, that's wild. I am gonna return these plugs first thing in Monday.

thebatfink commented 3 months ago

Ahh nice. I have an Auora plug and it works solidly but I was struggling to find them for a good price. I got some frient plugs which looked identical to my auora plug and they forever disconnect from the network / become broken in z2m. I may try one of these.

I’m still waiting for a response to my support question for them to change the ‘overvolt’ (its not really as UK used to have even higher voltage until it harmonised with the EU) and consumer devices are fine at these voltages - but no response yet.

edit: actually looks like those auora plugs have no amp measurement. Is that the plug or something missing with z2m? Current is one thing I use in automations to determine if the device attached to the plug is running or not.

WhimsySpoon commented 3 months ago

actually looks like those auora plugs have no amp measurement

You're right. Volts, amps and wattage are exposed, but only wattage has a value. Not sure if this is a device or a z2m problem.