Innr smart plug sp240 not showing power monitoring
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
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
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!
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 :).
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
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 :-)
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):
These are my reporting settings:
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.
Update: I did a factory reset an re-included the SP240 and now it is reporting properly.
I just picked up a pair of the SP 240, any idea when the support will be merged into main?
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
If you use the dev-Docker image the plug works fine with Home Assistant.
Also curious, when to expect this in the regular release schedule?
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
Will be supported in the 1 January release.
Just to confirm here: removed my custom external converter, upgrading Zigbee2MQTT, restarting, and everything reports correct wattage.
Thanks @Koenkk, and happy new year!
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 ?
Does it work after doing a reconfigure and not touching the rep change for currentSummDelivered?
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.
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
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.
This is with the following reporting configuration:
Any ideas @Koenkk ?