Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MHO-C401N-z #7507

Merged
merged 5 commits into from
May 10, 2024
Merged

MHO-C401N-z #7507

merged 5 commits into from
May 10, 2024

Conversation

TeHashX
Copy link
Contributor

@TeHashX TeHashX commented May 10, 2024

Requires firmware 0.1.2.1+

Copy link
Contributor Author

@TeHashX TeHashX left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the extra line

@Koenkk Koenkk merged commit c385d3f into Koenkk:master May 10, 2024
2 checks passed
@Koenkk
Copy link
Owner

Koenkk commented May 10, 2024

Thanks!

@TeHashX
Copy link
Contributor Author

TeHashX commented May 14, 2024

For some reason, the device is not recognised, if I use this converter it's all ok, something missing?

// Autor: Markus Bodengriller https://github.com/Bodengriller
// requires zigbee2mqtt v1.34+
// external converter for Xiaomi MHO-C401N https://github.com/pvvx/ZigbeeTLc
// based on external converter for devbis-Firmware
// https://raw.githubusercontent.com/devbis/z03mmc/master/converters/lywsd03mmc.js
// requires firmware 0.1.2.1+

const {
    battery,
    temperature,
    humidity,
    enumLookup,
    binary,
    numeric,
    quirkAddEndpointCluster,
} = require('zigbee-herdsman-converters/lib/modernExtend');
const reporting = require('zigbee-herdsman-converters/lib/reporting');
const ota = require('zigbee-herdsman-converters/lib/ota');

const dataType = {
    boolean: 0x10,
    uint8: 0x20,
    uint16: 0x21,
    int8: 0x28,
    int16: 0x29,
    enum8: 0x30,
};

const definition = {
    zigbeeModel: ['MHO-C401N-z'],
    model: 'MHO-C401N',
    vendor: 'Xiaomi',
    description: 'E-Ink Temperature & Humidity sensor with custom firmware (pvxx/ZigbeeTLc)',
    extend: [
        quirkAddEndpointCluster({
            endpointID: 1,
            outputClusters: [],
            inputClusters: [
                'genPowerCfg',
                'msTemperatureMeasurement',
                'msRelativeHumidity',
                'hvacUserInterfaceCfg',
            ],
        }),
        battery({percentage: true}),
        temperature({reporting: {min: 10, max: 300, change: 10}, access: 'STATE'}),
        humidity({reporting: {min: 2, max: 300, change: 50}, access: 'STATE'}),
        enumLookup({
            name: 'temperature_display_mode',
            lookup: {'celsius': 0, 'fahrenheit': 1},
            cluster: 'hvacUserInterfaceCfg',
            attribute: {ID: 0x0000, type: dataType.enum8},
            description: 'The units of the temperature displayed on the device screen.',
        }),
        binary({
            name: 'smiley',
            valueOn: ['SHOW', 0],
            valueOff: ['HIDE', 1],
            cluster: 'hvacUserInterfaceCfg',
            attribute: {ID: 0x0002, type: dataType.enum8},
            description: 'Whether to show a smiley on the device screen.',
        }),
        numeric({
            name: 'temperature_calibration',
            unit: 'ºC',
            cluster: 'hvacUserInterfaceCfg',
            attribute: {ID: 0x0100, type: dataType.int16},
            valueMin: -12.7,
            valueMax: 12.7,
            valueStep: 0.01,
            scale: 10,
            description: 'The temperature calibration, in 0.01° steps.',
        }),
        numeric({
            name: 'humidity_calibration',
            unit: '%',
            cluster: 'hvacUserInterfaceCfg',
            attribute: {ID: 0x0101, type: dataType.int16},
            valueMin: -12.7,
            valueMax: 12.7,
            valueStep: 0.01,
            scale: 10,
            description: 'The humidity offset is set in 0.01 % steps.',
        }),
        numeric({
            name: 'comfort_temperature_min',
            unit: 'ºC',
            cluster: 'hvacUserInterfaceCfg',
            attribute: {ID: 0x0102, type: dataType.int16},
            valueMin: -127.0,
            valueMax: 127.0,
            scale: 100,
            description: 'Comfort parameters/Temperature minimum, in 1°C steps.',
        }),
        numeric({
            name: 'comfort_temperature_max',
            unit: 'ºC',
            cluster: 'hvacUserInterfaceCfg',
            attribute: {ID: 0x0103, type: dataType.int16},
            valueMin: -127.0,
            valueMax: 127.0,
            scale: 100,
            description: 'Comfort parameters/Temperature maximum, in 1°C steps.',
        }),
        numeric({
            name: 'comfort_humidity_min',
            unit: '%',
            cluster: 'hvacUserInterfaceCfg',
            attribute: {ID: 0x0104, type: dataType.uint16},
            valueMin: 0.0,
            valueMax: 100.0,
            scale: 100,
            description: 'Comfort parameters/Humidity minimum, in 1% steps.',
        }),
        numeric({
            name: 'comfort_humidity_max',
            unit: '%',
            cluster: 'hvacUserInterfaceCfg',
            attribute: {ID: 0x0105, type: dataType.uint16},
            valueMin: 0.0,
            valueMax: 100.0,
            scale: 100,
            description: 'Comfort parameters/Humidity maximum, in 1% steps.',
        }),
        numeric({
            name: 'measurement_interval',
            unit: 's',
            cluster: 'hvacUserInterfaceCfg',
            attribute: {ID: 0x0107, type: dataType.uint8},
            valueMin: 3,
            valueMax: 255,
            description: 'Measurement interval, default 10 seconds.',
        }),
    ],
    ota: ota.zigbeeOTA,
    configure: async (device, coordinatorEndpoint, logger) => {
        const endpoint = device.getEndpoint(1);
        const bindClusters = ['msTemperatureMeasurement', 'msRelativeHumidity', 'genPowerCfg'];
        await reporting.bind(endpoint, coordinatorEndpoint, bindClusters);
        await reporting.temperature(endpoint, {min: 10, max: 300, change: 10});
        await reporting.humidity(endpoint, {min: 10, max: 300, change: 50});
        await reporting.batteryPercentageRemaining(endpoint);
        try {
            await endpoint.read('hvacThermostat', [0x0010, 0x0011, 0x0102, 0x0103, 0x0104, 0x0105, 0x0107]);
            await endpoint.read('msTemperatureMeasurement', [0x0010]);
            await endpoint.read('msRelativeHumidity', [0x0010]);
        } catch (e) {
            /* backward compatibility */
        }
    },
};
module.exports = definition;

@TeHashX
Copy link
Contributor Author

TeHashX commented May 14, 2024

Nevermind, please ignore, I readded Z2M Edge and it's recognised.

@TeHashX TeHashX deleted the patch-1 branch May 14, 2024 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants