zigbee2mqtt icon indicating copy to clipboard operation
zigbee2mqtt copied to clipboard

Innr smart plug sp240 not showing power monitoring

Open asterix778 opened this issue 2 years ago • 58 comments

What happened?

Innr SP240 isnt a supported device, I followed the manual on the website to add unsupported devices. Made a innr.JS file with the following code:

const` fz = require('zigbee-herdsman-converters/converters/fromZigbee'); const tz = require('zigbee-herdsman-converters/converters/toZigbee'); const exposes = require('zigbee-herdsman-converters/lib/exposes'); const reporting = require('zigbee-herdsman-converters/lib/reporting'); const extend = require('zigbee-herdsman-converters/lib/extend'); const e = exposes.presets; const ea = exposes.access;

const definition = { zigbeeModel: ['SP 240'], // The model ID from: Device with modelID 'lumi.sens' is not supported. model: 'SP 240', // Vendor model number, look on the device for a model number vendor: 'inrr', // Vendor of the device (only used for documentation and startup logging) description: 'smart plug innr', // Description of the device, copy from vendor site. (only used for documentation and startup
fromZigbee: [fz.electrical_measurement, fz.on_off], // We will add this later toZigbee: [tz.on_off], // Should be empty, unless device can be controlled (e.g. lights, switches). exposes: [e.switch(), e.power(), e.energy(), e.current(), e.voltage().withAccess(ea.STATE),], // Defines what this device exposes, used for e.g. Home Assistant discovery and in the frontend };

module.exports = definition;

Zigbee starts up I'm able to switch the device on and off but the energy readings are "Null"

What did you expect to happen?

What I expected to happen was that I had used the right exposes to add al the things this plug provides. I hope that someone could help me further and that we can add this device to the supported list.

How to reproduce it (minimal and precise)

Using the code above you can reproduce it. Tried removing the sp240 plug and re-adding it using the same code same effect

Zigbee2MQTT version

1.34.0-1

Adapter firmware version

0x26580700

Adapter

ConBee2/RaspBee2

Debug log

No response

asterix778 avatar Dec 05 '23 13:12 asterix778

Whilst digging through the documentation I found the following: https://github.com/Koenkk/zigbee-herdsman-converters/blob/master/src/devices/innr.ts

I've used the SP 234 as a baseline to try and get the energy measurement part working and it seems to be working:

Code snippet from the linked innr.ts file: zigbeeModel: ['SP 234'], model: 'SP 234', vendor: 'Innr', description: 'Smart plug', extend: [ onOff(), electricityMeter({current: {divisor: 1000}, voltage: {divisor: 1}, power: {divisor: 1}, energy: {divisor: 100}}), ], ota: ota.zigbeeOTA,

This is my innr.js file:

` const fz = require('zigbee-herdsman-converters/converters/fromZigbee'); const tz = require('zigbee-herdsman-converters/converters/toZigbee'); const exposes = require('zigbee-herdsman-converters/lib/exposes'); const reporting = require('zigbee-herdsman-converters/lib/reporting'); const extend = require('zigbee-herdsman-converters/lib/extend'); const {onOff, electricityMeter} = require('zigbee-herdsman-converters/lib/modernExtend'); const ota = require ('zigbee-herdsman-converters/lib/ota'); const e = exposes.presets; const ea = exposes.access;

const definition = { zigbeeModel: ['SP 240'], // The model ID from: Device with modelID 'lumi.sens' is not supported. model: 'SP 240', // Vendor model number, look on the device for a model number vendor: 'Inrr', // Vendor of the device (only used for documentation and startup logging) description: 'Smart plug', // Description of the device, copy from vendor site. (only used for documentation and startup fromZigbee: [fz.electrical_measurement, fz.on_off], // We will add this later toZigbee: [tz.on_off], // Should be empty, unless device can be controlled (e.g. lights, switches). exposes: [e.switch(), e.power(), e.energy(), e.current(), e.voltage().withAccess(ea.STATE),], // Defines what this device exposes, used for e.g. Home Assistant discovery and in the frontend extend: [ onOff(), electricityMeter({current: {divisor: 1000}, voltage: {divisor: 1}, power: {divisor: 1}, energy: {divisor: 100}}), ], ota: ota.zigbeeOTA, };

module.exports = definition; `

Zigbee2MQTT version

1.34.0-1

Adapter

SONOFF ZBDongle-E

jorni2000 avatar Dec 06 '23 21:12 jorni2000

I saw the some documentation but could not get it to work.

Can confirm that your code works I will follow up if the reporting is correct if so i will change this problem to an add new device request.

thx alot!

asterix778 avatar Dec 06 '23 21:12 asterix778

Following @jorni2000's comment, I just patched the innr.js file to support the new sp240 plug.

I edited the /opt/zigbee2mqtt/node_modules/zigbee-herdsman-converters/devices/innr.js file and copy/pasted the definition for the SP 234 on line 648, and adjusted it - replaced "234" with "240" twice in the first couple of lines.

Seems to work just fine, and good enough for me until I (or someone else with more familiarity) have time to patch the typescript file and submit a real patch :).

tuinstoelen avatar Dec 09 '23 17:12 tuinstoelen

Wanted to send a patch today, but it was already done:

  • https://github.com/Koenkk/zigbee-herdsman-converters/pull/6637
  • https://github.com/Koenkk/zigbee-herdsman-converters/commit/8eb43be096eedcc322813987de3d6baf30c470ac

Ocramius avatar Dec 11 '23 16:12 Ocramius

Device is supported now!

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

Koenkk avatar Dec 11 '23 18:12 Koenkk

Can confirm that your code works I will follow up if the reporting is correct if so i will change this problem to an add new device request.

The reporting with the custom converter from @jorni2000 is a bit off: getting wrong Current, Power and Energy readings.

I tried adjusting the divisors too, with no success.

That said, at least the plug turns on/off and reports voltage correctly :-)

Ocramius avatar Dec 11 '23 18:12 Ocramius

I'm using the Dev-branch (from Docker) and the SP240 is recognised properly, including all attributes. However the reporting is not working.

The "Exposes"page in the Z2M front-end shows the attributes with a "refresh" button. When pressed it indeed sends the new info, but automatic reporting is not done.

The fact that it shows refresh buttons for the attributes suggest that polling is configured (but not working): image

These are my reporting settings:

image

Edit: I have now "solved" this by setting the minum reporting interval to 60 (seconds). This effectively activates polling, although a rather would like reporting based on changed % with a relative high "minimum reporting" interval.

bikeymouse avatar Dec 22 '23 12:12 bikeymouse

Update: I did a factory reset an re-included the SP240 and now it is reporting properly.

bikeymouse avatar Dec 24 '23 13:12 bikeymouse

I just picked up a pair of the SP 240, any idea when the support will be merged into main?

Kugelfang666 avatar Dec 28 '23 13:12 Kugelfang666

I have the same Problem. Unfortunately, I'm just a simple user. When will the sp240 be available with a homeassistant starndard installation? Thanks so much

and7891 avatar Dec 28 '23 14:12 and7891

If you use the dev-Docker image the plug works fine with Home Assistant.

bikeymouse avatar Dec 28 '23 16:12 bikeymouse

Also curious, when to expect this in the regular release schedule?

gewoonivar avatar Dec 29 '23 17:12 gewoonivar

hello everyone, Unfortunately, I'm new to Linux. Can someone give me a short step by step guide on how to switch to the dev branch? The instructions in https://www.zigbee2mqtt.io/advanced/more/switch-to-dev-branch.html didn't work. I don't have the opt directory. I didn't get any further with it. it would be nice if someone could help me

and7891 avatar Dec 29 '23 17:12 and7891

Will be supported in the 1 January release.

Koenkk avatar Dec 30 '23 21:12 Koenkk

Just to confirm here: removed my custom external converter, upgrading Zigbee2MQTT, restarting, and everything reports correct wattage.

Thanks @Koenkk, and happy new year!

Ocramius avatar Jan 01 '24 22:01 Ocramius

Updated to latest version, works like a charm when pairing. I had to factory reset the unit, and now all values are imported into HA.

However getting updates of the attributes is another thing, as @bikeymouse also noticed.

I changed the timing for periodically updating to have instant updates for all attributes. The only one that is not updating automatically is the 'currentSumDelivered', when manually 'refreshed' the value is updated accordingly. Also with the default reporting interval this isn't working automatically.

Any ideas on how to fix this @Koenkk ?

Screenshot 2024-01-02 at 19 03 43

gewoonivar avatar Jan 02 '24 18:01 gewoonivar

Does it work after doing a reconfigure and not touching the rep change for currentSummDelivered?

Koenkk avatar Jan 02 '24 21:01 Koenkk

After one day I see 2 sockets have updated the currentSummDelivered automatically.

One of which I changed to the original reporting setting (for this attribute). The other one has a modified reporting setting.

A 3rd socket I factory reset this morning and used for the TV, has no update as the TV has not been used.

How to interpret the reporting settings for this attribute? It seems random at this point when the sockets are updating this attribute (currentSummDelivered). The other attributes strictly follow the configured reporting timings according to their (changed) config.

gewoonivar avatar Jan 03 '24 20:01 gewoonivar

Is the reset still required? Paired my new Plugs but they seem not to report automatically. I do have to trigger the report manually via the refresh button on Zigbee2Mqtt

Edit: sorry, didn't see the discussion above 😃 but yes, I am facing the same issue. No automatic Reporting of Values to HA/Z2MQTT

stefan1495 avatar Jan 04 '24 15:01 stefan1495

It seems that a factory reset is required @stefan1495 , as far as I experienced. But it might be different with your units.

As can be seen in the screenshot, the Quooker has multiple times reheated, especially when making diner last night. However the attribute currentSummDelivered has only updated twice.

Screenshot 2024-01-04 at 17 08 32

This is with the following reporting configuration:

Screenshot 2024-01-04 at 17 11 30

Any ideas @Koenkk ?

gewoonivar avatar Jan 04 '24 16:01 gewoonivar