Koenkk / zigbee-herdsman-converters

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

Adding support for "Develco AMS HAN sensor (EMIZB-132)" #974

Closed ShrinkWrapper closed 4 years ago

ShrinkWrapper commented 4 years ago

So I've been going at it for a while now and I'm at a loss on what to do next. Posting what I have so far in the hopes that someone can help me out a bit.

This is a device that connects to the HAN-port on a digital electricity meter and it should be able to read electrical measurements from the device.

Here is the datasheet for the device. https://www.develcoproducts.com/media/1783/emizb-132-technical-manual-emi-norwegian-han.pdf

This is the initial log when I connect the device in HA: https://gist.github.com/SilentFez/94cdc5a6aa953d648323b403a6247dcc

And this is the log after adding the following in devices.js

{
    zigbeeModel: ['EMIZB-132'], 
    model: 'emizb-132',
    vendor: 'Develco',
    description: 'Wattle AMS HAN power-meter sensor',
    supports: 'Monitoring stats from central household power-meter',
    fromZigbee: [],
    toZigbee: [],
},

https://gist.github.com/SilentFez/8e28969c0a677a22c46cad9d7baa9afd

And this is the log for when I add the converter that is showing up in the second log: https://gist.github.com/SilentFez/026af1cf913fd899d1430f9c756f8b63

When I add the device in homeassistant.js and try to pair it, nothing seems not show up and I cant seem to get any other readings for converters in the logs.

Koenkk commented 4 years ago

Can you share your database.db?

ShrinkWrapper commented 4 years ago

Thanks for helping out, much appreciated! Here is the database for zigbee2mqtt: https://gist.github.com/SilentFez/58513f9b68e839aa86c5e6d6f0a6d95a

Koenkk commented 4 years ago

Please try with

{
    zigbeeModel: ['EMIZB-132'], 
    model: 'emizb-132',
    vendor: 'Develco',
    description: 'Wattle AMS HAN power-meter sensor',
    supports: 'Monitoring stats from central household power-meter',
    fromZigbee: [fz.on_off, fz.generic_power],
    toZigbee: [tz.on_off],
    meta: {configureKey: 1},
    configure: async (device, coordinatorEndpoint) => {
        const endpoint = device.getEndpoint(2);
        await bind(endpoint, coordinatorEndpoint, ['genOnOff', 'seMetering']);
        await configureReporting.onOff(endpoint);
        await configureReporting.instantaneousDemand(endpoint);
        await endpoint.read('seMetering', ['multiplier', 'divisor']);
    },
},
ShrinkWrapper commented 4 years ago

This is what I get in the logs when I try it out: https://gist.github.com/SilentFez/b6ff3f06a6dc6cea91786d84876cd8e0

It seems to output an error, then it connects on the second try. Currently I'm getting the following readout from the device: zigbee2mqtt:info 2020-02-12 16:27:47: MQTT publish: topic 'zigbee2mqtt/0x0015bc001b024362', payload '{"power":-8388608,"linkquality":47,"energy":4295032.83}'

I have added this in homeassistant.js in the pattern list. 'EMIZB-132': [cfg.switch, cfg.sensor_power],

Reading in the datasheet, these are the different values I should be getting https://i.imgur.com/rIYQj53.png

Edit: Just saw something else as well, there seems to be some extra code needed for some of the metering devices. I got the one marked in yellow https://i.imgur.com/lMrtown.png

Edit2: I'm getting the following when checking the device in Zigbee2MqttAssistant https://i.imgur.com/IVNGZum.png

ShrinkWrapper commented 4 years ago

I'm getting these lines as well, not sure if they are related to this device? https://gist.github.com/SilentFez/91f4e1e1d44ba4e9d619c90c171d2286

Koenkk commented 4 years ago
ShrinkWrapper commented 4 years ago

Here is the updated database.db https://gist.github.com/SilentFez/8d97e2a496f64aa9d03f5a5ac4976c66

Koenkk commented 4 years ago

And

Can you activate the zigbee2mqtt debug logging, connect a load with a known consumption (e.g. a 50 watt bulb), and provide the logging when getting the power measurements.

?

ShrinkWrapper commented 4 years ago

It's not a power socket so I wont be able to see a direct comparison to a bulb being connected. It's a AMS HAN reader for the fuse box. It plugs into the main relay in the house and monitors the total consumption of power and throughput in real time. Its the device circled in the picture. Its a fairly new thing and I haven't seen many other implementations of it. So in theory I should be seeing the total wattage/consumption used in total for all my outlets, computer, heater etc. image

And here is what I'm currently getting with debugging enabled: https://gist.github.com/SilentFez/e3ef1aab3706b541fe0b3cbe07ba9f84

ShrinkWrapper commented 4 years ago

Reading in the deconz where they are adding the same device, they couldnt get any readings from it before they added the manufacture specific attributes. How would I go about adding that to the above snippet you gave me? Or is that not needed for zigbee2mqtt? These are the attributes I need: image

Edit: If I try with the following snippet:

{
    zigbeeModel: ['EMIZB-132'], 
    model: 'emizb-132',
    vendor: 'Develco',
    description: 'Wattle AMS HAN power-meter sensor',
    supports: 'Monitoring stats from central household power-meter',
    fromZigbee: [fz.on_off, fz.electrical_measurement],
    toZigbee: [tz.on_off],
    meta: {configureKey: 1},
    configure: async (device, coordinatorEndpoint) => {
        const endpoint = device.getEndpoint(2);
            await bind(endpoint, coordinatorEndpoint, ['genOnOff', 'haElectricalMeasurement']);
            await endpoint.read('haElectricalMeasurement', [
                'acVoltageMultiplier', 'acVoltageDivisor', 'acCurrentMultiplier',
                'acCurrentDivisor', 'acPowerMultiplier', 'acPowerDivisor',
            ]);
            await configureReporting.onOff(endpoint);
            await configureReporting.rmsVoltage(endpoint);
            await configureReporting.rmsCurrent(endpoint);
            await configureReporting.activePower(endpoint);
        },
},

I get the following in debugging:

{"frameType":0,"manufacturerSpecific":false,"direction":1,"disableDefaultResponse":true},"transactionSequenceNumber":67,"manufacturerCode":null,"commandIdentifier":10},"Payload":[{"attrId":1285,"dataType":33,"attrData":65535},{"attrId":1288,"dataType":33,"attrData":65535},{"attrId":2309,"dataType":33,"attrData":65535},{"attrId":2312,"dataType":33,"attrData":65535},{"attrId":2565,"dataType":33,"attrData":65535},{"attrId":2568,"dataType":33,"attrData":65535}]},"address":52630,"endpoint":2,"linkquality":60,"groupID":0}'
zigbee2mqtt:debug 2020-02-14 20:36:00: Received Zigbee message from '0x0015bc001b024362', type 'attributeReport', cluster 'haElectricalMeasurement', data 
zigbee2mqtt:info  2020-02-14 20:36:08: MQTT publish: topic 'zigbee2mqtt/0x0015bc001b024362', payload '{"power":65535,"linkquality":63,"energy":4295032.83,"current":65535,"voltage":65535,"state":"OFF"}
zigbee2mqtt:debug 2020-02-14 20:37:07: Received Zigbee message from '0x0015bc001b024362', type 'attributeReport', cluster 'haElectricalMeasurement', data '{"rmsVoltage":65535,"rmsCurrent":65535,"rmsVoltagePhB":65535,"rmsCurrentPhB":65535,"rmsVoltagePhC":65535,"rmsCurrentPhC":65535}' from endpoint 2 with groupID 0

Those attributes correspond with what I want to get from the meter as shown here: image

Only problem is all the data is showing the same and Im pretty sure that has to do with the manufacture spesific attributes. But I might be wrong..

Koenkk commented 4 years ago

I don't know if it has to be added yet, it only make sense if after that we issue write requests to it.

Looking at your we already got some luck with the config from https://github.com/Koenkk/zigbee-herdsman-converters/issues/974#issuecomment-585143642 as I can see you got an energy value "energy":4295032.83, this shows the total electricity that has been delivered in watts (??) does this value make sense?

ShrinkWrapper commented 4 years ago

The energy reading seems to always be 4295032.83 when it is showing up in the log. There is a display in the fusebox that will also show the values and the total energy should be at 13270 as of now (6 PM).

Koenkk commented 4 years ago

Can you try with below, this will set the mode to Kaifa (don't know if this is correct for your config), if not you can change the value: 0x0203 to the correct one.

{
    zigbeeModel: ['EMIZB-132'],
    model: 'emizb-132',
    vendor: 'Develco',
    description: 'Wattle AMS HAN power-meter sensor',
    supports: 'Monitoring stats from central household power-meter',
    fromZigbee: [fz.electrical_measurement, fz.generic_power],
    toZigbee: [],
    meta: {configureKey: 5},
    configure: async (device, coordinatorEndpoint) => {
        const endpoint = device.getEndpoint(2);
        // Kaifka meter mode https://github.com/Koenkk/zigbee-herdsman-converters/issues/974#issuecomment-586455655
        await endpoint.write('seMetering', {0x0302: {value: 0x0203, type: 49}}, {manufacturerCode: 0x1015});
        await bind(endpoint, coordinatorEndpoint, ['haElectricalMeasurement', 'seMetering']);
        await endpoint.read('haElectricalMeasurement', [
            'acVoltageMultiplier', 'acVoltageDivisor', 'acCurrentMultiplier',
            'acCurrentDivisor', 'acPowerMultiplier', 'acPowerDivisor',
        ]);
        await configureReporting.rmsVoltage(endpoint);
        await configureReporting.rmsCurrent(endpoint);
        await configureReporting.activePower(endpoint);

        await endpoint.read('seMetering', ['multiplier', 'divisor']);
        await configureReporting.instantaneousDemand(endpoint);
    },
},
ShrinkWrapper commented 4 years ago

Thanks for the new code. I have the Aidon meter, so I believe I need to use value: 0x0201 to enable communication. Unfortunately I don't seem to get any usable readings, they are still showing 65535 on all the data. I tried all the manufacture specific values one by one to check and repaired the device each time. Here is the log for when I pair with 0x0201 as a value:

https://gist.github.com/SilentFez/20caf69844c5e6b8eaf7881054c9b06b

Edit: I noticed something. The data I get on "power":-8388608 corresponds with the following in the datasheet. Does that mean it is picking the power data from the wrong endpoint? image

And I'm alos getting zigbee2mqtt:debug 2020-02-20 22:28:13: No converter available for 'emizb-132' with cluster 'genBasic' and type 'readResponse' and data '{}' in the log now

Koenkk commented 4 years ago

Can you provide the log with:

{
    zigbeeModel: ['EMIZB-132'],
    model: 'emizb-132',
    vendor: 'Develco',
    description: 'Wattle AMS HAN power-meter sensor',
    supports: 'Monitoring stats from central household power-meter',
    fromZigbee: [fz.electrical_measurement, fz.generic_power],
    toZigbee: [],
    meta: {configureKey: 5},
    configure: async (device, coordinatorEndpoint) => {
        const endpoint = device.getEndpoint(2);
        // Kaifka meter mode https://github.com/Koenkk/zigbee-herdsman-converters/issues/974#issuecomment-586455655
        await endpoint.write('seMetering', {0x0302: {value: 0x201, type: 49}}, {manufacturerCode: 0x1015});
        const result = await entity.read('seMetering', [0x0302], {manufacturerCode: 0x1015});
        console.log('\n\n\n', 'result', result, '\n\n\n');
        await bind(endpoint, coordinatorEndpoint, ['haElectricalMeasurement', 'seMetering']);
        await endpoint.read('haElectricalMeasurement', [
            'acVoltageMultiplier', 'acVoltageDivisor', 'acCurrentMultiplier',
            'acCurrentDivisor', 'acPowerMultiplier', 'acPowerDivisor',
        ]);
        await configureReporting.rmsVoltage(endpoint);
        await configureReporting.rmsCurrent(endpoint);
        await configureReporting.activePower(endpoint);

        await endpoint.read('seMetering', ['multiplier', 'divisor']);
        await configureReporting.instantaneousDemand(endpoint);
    },
},
ShrinkWrapper commented 4 years ago

Here is the log when testing with the latest code. And thanks for still helping out! 👍 https://gist.github.com/SilentFez/c7c54bc903257240a0777edc3d559231

Koenkk commented 4 years ago

I dont see a configure in the log which is the only thing im interested in for know. You dont have to repair everytime as you can also trigger a configure manually via https://www.zigbee2mqtt.io/information/mqtt_topics_and_message_structure.html#zigbee2mqttbridgeconfigure

ShrinkWrapper commented 4 years ago

Aha thanks, good to know! Here is the log with configure in it: It seems to throw an error each time it tries to configure https://gist.github.com/SilentFez/60b7a05bdd8a7056b359296437f7956c

Here is line 484 in devices.js as referenced in the log: image

Koenkk commented 4 years ago

I made a mistake, it has to be

{
    zigbeeModel: ['EMIZB-132'],
    model: 'emizb-132',
    vendor: 'Develco',
    description: 'Wattle AMS HAN power-meter sensor',
    supports: 'Monitoring stats from central household power-meter',
    fromZigbee: [fz.electrical_measurement, fz.generic_power],
    toZigbee: [],
    meta: {configureKey: 5},
    configure: async (device, coordinatorEndpoint) => {
        const endpoint = device.getEndpoint(2);
        // Kaifka meter mode https://github.com/Koenkk/zigbee-herdsman-converters/issues/974#issuecomment-586455655
        await endpoint.write('seMetering', {0x0302: {value: 0x201, type: 49}}, {manufacturerCode: 0x1015});
        const result = await endpoint.read('seMetering', [0x0302], {manufacturerCode: 0x1015});
        console.log('\n\n\n', 'result', result, '\n\n\n');
        await bind(endpoint, coordinatorEndpoint, ['haElectricalMeasurement', 'seMetering']);
        await endpoint.read('haElectricalMeasurement', [
            'acVoltageMultiplier', 'acVoltageDivisor', 'acCurrentMultiplier',
            'acCurrentDivisor', 'acPowerMultiplier', 'acPowerDivisor',
        ]);
        await configureReporting.rmsVoltage(endpoint);
        await configureReporting.rmsCurrent(endpoint);
        await configureReporting.activePower(endpoint);

        await endpoint.read('seMetering', ['multiplier', 'divisor']);
        await configureReporting.instantaneousDemand(endpoint);
    },
},
ShrinkWrapper commented 4 years ago

Thanks, here is the updated log with the new code. It successfully configures again, but the data seems to still be the same values.

https://gist.github.com/SilentFez/6610e64d0fe7ebb2af214c7d5d18f3b3

Edit: Here is the database.db entry as well if needed:

{"id":6,"type":"EndDevice","ieeeAddr":"0x0015bc001b024362","nwkAddr":54287,"manufId":4117,"manufName":"Develco Products A/S","powerSource":"DC Source","modelId":"EMIZB-132","epList":[1,2],"endpoints":{"1":{"profId":49353,"epId":1,"devId":1,"inClusterList":[3,5,6],"outClusterList":[],"clusters":{},"binds":[]},"2":{"profId":260,"epId":2,"devId":83,"inClusterList":[0,3,32,1794,1796,2820],"outClusterList":[3,10,25],"clusters":{"genBasic":{"attributes":{"modelId":"EMIZB-132","manufacturerName":"Develco Products A/S","powerSource":4,"zclVersion":1,"dateCode":"2017-11-01 18:40"}},"seMetering":{"attributes":{"divisor":1000,"currentSummDelivered":[65535,4294967295],"instantaneousDemand":-8388608,"status":0,"multiplier":1}},"haElectricalMeasurement":{"attributes":{"rmsVoltage":65535,"rmsCurrent":65535,"rmsVoltagePhB":65535,"rmsCurrentPhB":65535,"rmsVoltagePhC":65535,"rmsCurrentPhC":65535,"acVoltageMultiplier":65535,"acVoltageDivisor":65535,"acCurrentMultiplier":65535,"acCurrentDivisor":65535}}},"binds":[{"cluster":2820,"type":"endpoint","deviceIeeeAddress":"0x00124b000be89ce1","endpointID":1},{"cluster":1794,"type":"endpoint","deviceIeeeAddress":"0x00124b000be89ce1","endpointID":1}]}},"dateCode":"2017-11-01 18:40","zclVersion":1,"interviewCompleted":true,"meta":{"configured":5},"lastSeen":1582464591712}
Koenkk commented 4 years ago

Are you sure this is with the code from https://github.com/Koenkk/zigbee-herdsman-converters/issues/974#issuecomment-590067885.

I'm asking because I don't see the endpoint.read('seMetering', [0x0302], {manufacturerCode: 0x1015}); being executed and also the console.log output is missing.

ShrinkWrapper commented 4 years ago

Yep it should be. Just in case I restarted zigbee2mqtt from inside HA just now and logged in to the new docker instance and added the code again. Screenshot of what I have added: image

I have log_level: debug inside advanced and also zigbee_herdsman_debug: true at top-level if that could be messing up the console output. And here is the log from the new testing: https://gist.github.com/SilentFez/3055f94f4b9607591fe92e24a3802586

Koenkk commented 4 years ago

Sorry, but I still don't see it. could it be that after a restart of the addon changes to devices.js are lost?

Also in the Deconz issue they talk about having the energy company opening the HAN port, are you sure this port is opened by your energy provider?

ShrinkWrapper commented 4 years ago

I did it like this:

  1. Restart zigbee2mqtt from the addon
  2. Open a terminal to HA and run docker ps to check for the new ID on the z2m docker
  3. Open bash for the new docker ID and add the device in devices.js
  4. Close the docker and restart the docker with docker restart ID
  5. Open the docker again to confirm the data is still present in device.js
  6. Repaired the device and checked the log

I contacted my energy company a couple of months ago for them to open the HAN-port and got a confirmation mail stating that they had opened it. It is also possible to measure the voltage across pin 1 and 2 on the HAN-port. The port is polling data every 30 seconds and if the port is in fact opened it should show 24V, and I have confirmed this with a multimeter so it should be sending data.

I'm on the zigbee2mqtt and Home Assistant discords (nick: SilentFez#8888) if you want login-info to my HA or terminal if that would make it easier to debug.

Edit: I can see the following lines regarding seMetering in the last log I provided, is that for something else?

zigbee2mqtt:debug 2020-02-23 18:39:05: Received Zigbee message from '0x0015bc001b024362', type 'readResponse', cluster 'seMetering', data '{"multiplier":1,"divisor":1000}' from endpoint 2 with groupID 0
2020-02-23T18:39:05.295Z zigbee-herdsman:controller:endpoint ConfigureReporting 0x0015bc001b024362/2 seMetering([{"attribute":"instantaneousDemand","minimumReportInterval":0,"maximumReportInterval":3600,"reportableChange":1}], {"timeout":10000,"defaultResponseTimeout":15000,"manufacturerCode":null,"disableDefaultResponse":true})
Koenkk commented 4 years ago

@SilentFez somehow I cannot find you, could you contact me on telegram (@koenkk)?

ShrinkWrapper commented 4 years ago

Update: @Koenkk have been doing some debugging on the device and after testing we have concluded that the code is definitely working but because of an older firmware on the Wattle/Develco stick we can not get any proper readings from the device at the current time. The same has been confirmed by another user over at the deconz github with the same device connected to an Aidon meter.

ShrinkWrapper commented 4 years ago

Update 2: I contacted Wattle and asked them if it was possible to get the new firmware for the device. But I need to have their bridge/gateway in order to update it myself. But they were nice enough to offer to update it for me, so if I send the device to them they will make sure to upgrade it to the 2019 version that is needed for the Aidon meters. So if anyone else were to bump in to the same problem they could try and do the same, just ask if they are willing to update it for you.

ShrinkWrapper commented 4 years ago

Just picked up the device. They have sent me a new one with the updated firmware. Connected, paired and configured it now. It is definitely picking up values now and not just the default one we saw earlier. But I'm not sure if it is showing them correct, the voltage is at 2300 and energy seems to be a bit high as well. https://gist.github.com/SilentFez/fcaa431d0b53f9541fac7a3c5cb25ab6

Koenkk commented 4 years ago

Cool! Could you share your debug logging (when receiving measurements from the device) and database.db now?

To enable debug logging set in configuration.yaml:

advanced:
  log_level: debug
ShrinkWrapper commented 4 years ago

log: https://gist.github.com/SilentFez/c7cc887a9b355e19f241683c3ef02eec database.db:

{"id":6,"type":"EndDevice","ieeeAddr":"0x0015bc001b024000","nwkAddr":61175,"manufId":4117,"manufName":"Develco Products A/S","powerSource":"DC Source","modelId":"EMIZB-132","epList":[1,2],"endpoints":{"1":{"profId":49353,"epId":1,"devId":1,"inClusterList":[3,5,6],"outClusterList":[],"clusters":{},"binds":[]},"2":{"profId":260,"epId":2,"devId":83,"inClusterList":[0,3,32,1794,1796,2820],"outClusterList":[3,10,25],"clusters":{"genBasic":{"attributes":{"modelId":"EMIZB-132","manufacturerName":"Develco Products A/S","powerSource":4,"zclVersion":1,"dateCode":"2017-08-22 06:18"}},"seMetering":{"attributes":{"divisor":1000,"currentSummDelivered":[65535,4294967295],"instantaneousDemand":560,"status":0,"multiplier":1}},"haElectricalMeasurement":{"attributes":{"rmsVoltage":2374,"rmsCurrent":26,"rmsVoltagePhB":65535,"rmsCurrentPhB":65535,"rmsVoltagePhC":65535,"rmsCurrentPhC":65535,"acVoltageMultiplier":65535,"acVoltageDivisor":65535,"acCurrentMultiplier":65535,"acCurrentDivisor":65535}}},"binds":[{"cluster":2820,"type":"endpoint","deviceIeeeAddress":"0x00124b000be89ce1","endpointID":1},{"cluster":1794,"type":"endpoint","deviceIeeeAddress":"0x00124b000be89ce1","endpointID":1}]}},"dateCode":"2017-08-22 06:18","zclVersion":1,"interviewCompleted":true,"meta":{"configured":5},"lastSeen":1584533200165}
Koenkk commented 4 years ago

Great, let's start with the metering cluster

ShrinkWrapper commented 4 years ago

Had to run it on the bare bones server since I'm using hassio on my main. Updated to 1.12.0 and added the changes in the pull request. The energy value is 0 at the moment. The values of all the rms outputs seems to be 65535 as well.

Here is the database.db

{"id":2,"type":"EndDevice","ieeeAddr":"0x0015bc001b024000","nwkAddr":64904,"manufId":4117,"manufName":"Develco Products A/S","powerSource":"DC Source","modelId":"EMIZB-132","epList":[1,2],"endpoints":{"1":{"profId":49353,"epId":1,"devId":1,"inClusterList":[3,5,6],"outClusterList":[],"clusters":{},"binds":[]},"2":{"profId":260,"epId":2,"devId":83,"inClusterList":[0,3,32,1794,1796,2820],"outClusterList":[3,10,25],"clusters":{"genBasic":{"attributes":{"modelId":"EMIZB-132","manufacturerName":"Develco Products A/S","powerSource":4,"zclVersion":1,"dateCode":"2017-08-22 06:18"}},"haElectricalMeasurement":{"attributes":{"rmsVoltage":2380,"rmsCurrent":25,"rmsVoltagePhB":65535,"rmsCurrentPhB":65535,"rmsVoltagePhC":65535,"rmsCurrentPhC":65535,"acVoltageMultiplier":65535,"acVoltageDivisor":65535,"acCurrentMultiplier":65535,"acCurrentDivisor":65535}},"seMetering":{"attributes":{"currentSummDelivered":[65535,4294967295],"instantaneousDemand":534,"status":0,"multiplier":1,"divisor":1000,"currentSummReceived":[65535,4294967295]}}},"binds":[{"cluster":2820,"type":"endpoint","deviceIeeeAddress":"0x00124b000be89ce1","endpointID":1},{"cluster":1794,"type":"endpoint","deviceIeeeAddress":"0x00124b000be89ce1","endpointID":1}]}},"dateCode":"2017-08-22 06:18","zclVersion":1,"interviewCompleted":true,"meta":{"configured":6},"lastSeen":1584560213446}

And here is the log: https://gist.github.com/SilentFez/e89d92315c09418bb820f76a5bb42288

Koenkk commented 4 years ago

What about the power value? ('{"power":584,"linkquality":60,"energy":0}') does 584 watt makes sense?

EDIT: also please provide the log with debug enabled

To enable debug logging set in configuration.yaml:

advanced:
  log_level: debug
ShrinkWrapper commented 4 years ago

It could be correct. I can't be totally sure, but a tally of what is currently running in the house could add up to that value. If we could get a reading from 0x0304 on the sheet here that should total up to 14020 at the moment image

Here is the log with debug activated: https://gist.github.com/SilentFez/2cd1b56759442ee39fcfa41a6fe1278e

Koenkk commented 4 years ago

I've updated https://github.com/Koenkk/zigbee-herdsman-converters/pull/1070/files to add current and voltage. Please provide the debug logging again after this.

I don't see 0x0304 being reported at the moment by the device, so I forced a read in the configure know (which should be seen in the logging).

Btw one thing I noticed is that this device seems to have an older firmware that you previously had? Current "dateCode":"2017-08-22 06:18", before you send it back you had "dateCode":"2017-11-01 18:40". The ones from the Deconz issue have a date code of 2019-07-11 21:41 (https://github.com/dresden-elektronik/deconz-rest-plugin/issues/2127#issuecomment-587658155)

ShrinkWrapper commented 4 years ago

Yeah I noticed the date as well. Could it be the manufacturer date and not the firmware date? Weird if they have sent me a device with even older firmware.

Here is the log with updated files: https://gist.github.com/SilentFez/c8fc19a0b44c73c3ffddf5daf3022dbf

If you look at line 20 and 24 it actually reports the correct total used energy level (14041) for a couple of seconds then it goes back to showing energy 0. After it successfully configures on line 42 the voltage and current seems to be correct as well. I just did a test with my multimeter and the voltage is 237/238.

Here is the current readout from the aidon meter image

Koenkk commented 4 years ago

Regarding the energy, can you let it run for 2 hours and see what happens? The energy will only be reported every hour so maybe we just need to wait until a new value comes in.

ShrinkWrapper commented 4 years ago

Yep, you are correct. It didn't take long before it starting showing values. It is definitely working. Even the power seems to be correct. I put on my microwave on full and that is drawing about 1200W, and you can see it fluctuate in the values with about 1200W right about line 29. Total consumption just wen up to 14042 as well on the aidon meter and that corresponds with the values in the log.

https://gist.github.com/SilentFez/7f70b839c829619fdebac63b5b9bd844

Edit: Now it is only the rms values that seems to be off. {"rmsVoltage":2394,"rmsCurrent":21,"rmsVoltagePhB":65535,"rmsCurrentPhB":65535,"rmsVoltagePhC":65535,"rmsCurrentPhC":65535}

Koenkk commented 4 years ago

It only shows the incorrect values for the phases right? Do you have a 3 phase connection?

ShrinkWrapper commented 4 years ago

Seems like it and I don't have 3 phase. So with the current values I'm getting I guess I should be able to calculate how much money I spend on power per hour, day, week and month. As long as I have the total consumption, wattage and voltage I think I should be all set. How will you add the device to your devices list? Since it requires different values depending on people having Aidon or Kaifa? I is possible for the code to "look" for the correct device or will they just have to change that them self?

And thank you very much for all the help!

Koenkk commented 4 years ago

How will you add the device to your devices list? Since it requires different values depending on people having Aidon or Kaifa? I is possible for the code to "look" for the correct device or will they just have to change that them self?

Good question, I've implemented this now.

ShrinkWrapper commented 4 years ago

Its working! Log with the new changes and repairing the device: https://gist.github.com/SilentFez/54611573c91fa1c4893b56f6714fb37d

I cut out a big chunk on line 182 and 183 until it showed a read on energy. Also did some more testing on the wattage (line 118 to 166), put on my oven, tabletop, microwave and different appliances and they all seem to add up the total!

Koenkk commented 4 years ago

Great, it's officially supported in the latest zigee2mqtt dev branch now.

I added some documentation here: https://github.com/Koenkk/zigbee2mqtt.io/blob/develop/docs/devices/EMIZB-132.md

ShrinkWrapper commented 4 years ago

Nice! Thanks for all your hard work. This is awesome. Do I close the thread or will it close when it hits the main branch?

Koenkk commented 4 years ago

If its working ok for you you can close it, it will be in next z2m release.

ShrinkWrapper commented 4 years ago

Seems to work perfectly, just added it into Home Assistant with some daily graphs and monthly graphs. image

toremick commented 4 years ago

Have z2m ver 1.12.0 and bought one of these . Have a kaifa MA304H3E (3-phase) meter and only getting strange values.

info 2020-03-23 15:34:59: MQTT publish: topic 'zigbee2mqtt/0x0015bc001b02508c', payload '{"current":6553.5,"voltage":6553.5,"linkquality":198,"power":-8388608,"energy":0,"interface_mode":513}' debug 2020-03-23 15:34:59: Received Zigbee message from '0x0015bc001b02508c', type 'attributeReport', cluster 'seMetering', data '{"currentSummDelivered":[65535,4294967295],"currentSummReceived":[65535,4294967295],"instantaneousDemand":-8388608,"status":0}' from endpoint 2 with groupID 0

Do i need to "tell" it what kind of meter im running? If so how do i do that?

ShrinkWrapper commented 4 years ago

Indeed, you have to tell it what interface you have. @Koenkk wrote a readme for the device. if you look under Configuring interface mode you will see how you need to do that. https://github.com/Koenkk/zigbee2mqtt.io/blob/develop/docs/devices/EMIZB-132.md If you still don't get any readings from it after configuration you might have a device with old firmware on it. I was in the same boat (https://github.com/Koenkk/zigbee-herdsman-converters/issues/974#issuecomment-591512940) The friendly name in the guide is the name your device gets in zigbee after pairing.

Edit: And also make sure you are on the dev-branch. You can install the dev-branch in Home Assistant, copy over the config and run the dev-branch version. Its not out in the stable version yet.

toremick commented 4 years ago

Thanks! I'm running the latest 1.12.0 and support for it is released there. Is there anything else in the dev than that?

Set it to "kaifa_and_kamstrup" and that helped. But the value for Amps has wrong decimal placement, and its not showing the other two phases of V and A.

rmsCurrent shows as 496.2, but should be 4.962

How do i get the other phases, and how do i correct the decimalpoint?

debug 2020-03-24 09:29:00: Received Zigbee message from '0x0015bc001b02508c', type 'attributeReport', cluster 'haElectricalMeasurement', data '{"rmsVoltage":2378,"rmsCurrent":4962,"rmsVoltagePhB":0,"rmsCurrentPhB":3504,"rmsVoltagePhC":2378,"rmsCurrentPhC":6062}' from endpoint 2 with groupID 0
info  2020-03-24 09:29:00: MQTT publish: topic 'zigbee2mqtt/0x0015bc001b02508c', payload '{"current":496.2,"voltage":237.8,"linkquality":195,"power":1879,"energy":30396.21,"interface_mode":515}'
Koenkk commented 4 years ago

@toremick can you share your database.db file?