Koenkk / zigbee-herdsman-converters

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

Aqara TVOC Air Quality Monitor #2749

Closed dasfuu closed 3 years ago

dasfuu commented 3 years ago

I gave supporting the Aqara Air Quality Monitor a try. But i need some help to finish it.

https://www.aqara.com/eu/product/tvoc-air-quality-monitor https://shop.smarthome-europe.com/en/peripheriques/4980-xiaomi-aqara-tvoc-air-quality-monitor-zigbee-30-6970504214644.html

Because the other issue was automatically closed I am opening a new one here. The information below is the same i posted there already. (Old one: https://github.com/Koenkk/zigbee2mqtt/issues/6872)


I got it to work - kinda. I don't think i got battery/power and the configure part correct. I manually added the reporting stuff through the UI. (I know the configure part is missing some stuff, but temperature and humidty didn't setup correct either. And there are two batteries in there so I think the voltage for the calculation might be wrong, or it shipped with very empty batteries. (Edit: Battery now shows 100% now without any changes to the software or hardware)

The sensor values match with the display. They are at times more up to date than on the device. The eInk screen only refreshes from time to time.

image image

// Import the regular converter package
const zigbeeHerdsmanConverters = require('zigbee-herdsman-converters');
// Set fz (also done in the original device list)
const fz = zigbeeHerdsmanConverters.fromZigbeeConverters;
// Set e (also done in the original device list)
const e = zigbeeHerdsmanConverters.exposes.presets;

const fzn = {
    tvoc: {
        cluster: 'genAnalogInput',
        type: 'attributeReport',
        convert: (model, msg, publish, options, meta) => {
            return {
                voc:  msg.data.presentValue
            };
        },
    }
};

const definition = {
    zigbeeModel: ['lumi.airmonitor.acn01'], // The model ID from: Device with modelID 'lumi.sens' is not supported.
    model: 'AAQS-S01', // Vendor model number, look on the device for a model number
    vendor: 'Xiaomi', // Vendor of the device (only used for documentation and startup logging)
    description: 'TVOC Air Quality Monitor', // Description of the device, copy from vendor site. (only used for documentation and startup logging)
    fromZigbee: [
      fzn.tvoc,
      fz.xiaomi_battery,
      fz.battery, 
      fz.temperature, 
      fz.humidity
    ], // We will add this later
    toZigbee: [], // Should be empty, unless device can be controlled (e.g. lights, switches).
    //meta: {battery: {voltageToPercentage: '3V_2100'}},
    meta: {configureKey: 2, battery: {voltageToPercentage: '3V_2100'}},    
    exposes: [e.battery(), e.temperature(), e.humidity(), e.voc()], // Defines what this device exposes, used for e.g. Home Assistant discovery and in the frontend
    configure: async (device, coordinatorEndpoint, logger) => {
            const endpoint = device.getEndpoint(1);
            const binds = ['msTemperatureMeasurement', 'msRelativeHumidity', 'genPowerCfg'];
            await reporting.bind(endpoint, coordinatorEndpoint, binds);
            await reporting.batteryVoltage(endpoint);
            await reporting.batteryPercentageRemaining(endpoint);
            device.powerSource = 'Battery';
            device.save();
        },
};

module.exports = definition;
Koenkk commented 3 years ago

Let's re-open https://github.com/Koenkk/zigbee2mqtt/issues/6872 instead