Enocean humidity and temperature readings incorrect in 4.0.2

Expected Behavior

The readings for temperature and humidity with EEP A5-10-12 should be correct.

Current Behavior

The readings are incorrect. Please see the drop in temperature and non changing humidity readings after updating from latest openocean version 3.2.0.0 to official Enocean binding 4.0.2.

Possible Solution

Merge all changes from the latest openocean version 3.2.0.0 to to official enocean binding. The wrong profile was fixed years ago but never merged into the official binding:

fruggy83/openocean#106

Unfortunately it looks like the maintainer for this binding @fruggy83 isn’t active anymore.

So who can merge these two versions together to get a binding which is working with OH4 but still got the latest changes from the openocean version? Unfortunately I am not able to do something like this :frowning:

Ok, I took a look at the EEP which is causing the issue.
It looks like that in the latest openocean version (from 2021) the EEP A5-10 was revised but these changes were never merged into the official binding.

I think using the enocean binding 4.0.2 as a base and the code from openocean https://github.com/fruggy83/openocean/blob/master/src/main/java/org/openhab/binding/enocean/internal/eep/A5_10/A5_10.java

combined with Add null annotations done by @lsiepel should fix the issue…hopefully.

Openocean code:

/**
 * Copyright (c) 2010-2021 Contributors to the openHAB project
 *
 * See the NOTICE file(s) distributed with this work for additional
 * information.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0
 *
 * SPDX-License-Identifier: EPL-2.0
 */
package org.openhab.binding.enocean.internal.eep.A5_10;

import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;

import java.util.function.Function;

import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
import org.openhab.core.config.core.Configuration;
import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.OpenClosedType;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.unit.SIUnits;
import org.openhab.core.library.unit.Units;
import org.openhab.core.types.State;
import org.openhab.core.types.UnDefType;

/**
 *
 * @author Daniel Weber - Initial contribution
 */
public abstract class A5_10 extends _4BSMessage {

    public A5_10(ERP1Message packet) {
        super(packet);
    }

    protected int getSetPointValue() {
        // this is the default one
        return getDB_2Value();
    }

    protected int getMaxUnscaledValue() {
        return 255;
    }

    protected double getTempScalingFactor() {
        return -6.375; // 255/40
    }

    protected State getTemperature() {
        double temp = (getDB_1Value() - getMaxUnscaledValue()) / getTempScalingFactor();
        return new QuantityType<>(temp, SIUnits.CELSIUS);
    }

    protected State getFanSpeedStage() {
        if (getDB_3Value() > 209) {
            return new DecimalType(-1);
        } else if (getDB_3Value() > 189) {
            return new DecimalType(0);
        } else if (getDB_3Value() > 164) {
            return new DecimalType(1);
        } else if (getDB_3Value() > 144) {
            return new DecimalType(2);
        } else {
            return new DecimalType(3);
        }
    }

    protected int getIlluminationValue() {
        return getDB_3Value();
    }

    protected State getIllumination() {
        return new QuantityType<>(getIlluminationValue() * 4, Units.LUX);
    }

    protected double getHumidityValue() {
        return getDB_2Value();
    }

    protected State getSupplyVoltage() {
        double voltage = ((double) getDB_3Value()) / 50.0;
        return new QuantityType<>(voltage, Units.VOLT);
    }

    @Override
    protected State convertToStateImpl(String channelId, String channelTypeId,
            Function<String, State> getCurrentStateFunc, Configuration config) {

        switch (channelId) {

            case CHANNEL_BATTERY_VOLTAGE:
                return getSupplyVoltage();

            case CHANNEL_ILLUMINATION:
                return getIllumination();

            case CHANNEL_FANSPEEDSTAGE:
                return getFanSpeedStage();

            case CHANNEL_SETPOINT:
                return new DecimalType(getSetPointValue());

            case CHANNEL_HUMIDITY:
                return new DecimalType(getHumidityValue() / 2.5);

            case CHANNEL_TEMPERATURE:
                return getTemperature();

            case CHANNEL_BATTERYLOW:
                return getBit(getDB_0(), 4) ? OnOffType.ON : OnOffType.OFF;

            case CHANNEL_OCCUPANCY:
                return getBit(getDB_0(), 0) ? OnOffType.OFF : OnOffType.ON;

            case CHANNEL_DAYNIGHTMODESTATE:
                return new DecimalType(getDB_0Value() & 0x01);

            case CHANNEL_CONTACT:
                return getBit(getDB_0(), 0) ? OpenClosedType.OPEN : OpenClosedType.CLOSED;

        }

        return UnDefType.UNDEF;
    }
}

Enocean binding code:

/**
 * Copyright (c) 2010-2023 Contributors to the openHAB project
 *
 * See the NOTICE file(s) distributed with this work for additional
 * information.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0
 *
 * SPDX-License-Identifier: EPL-2.0
 */
package org.openhab.binding.enocean.internal.eep.A5_10;

import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;

import java.util.function.Function;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
import org.openhab.core.config.core.Configuration;
import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.types.StringType;
import org.openhab.core.library.unit.SIUnits;
import org.openhab.core.types.State;
import org.openhab.core.types.UnDefType;

/**
 *
 * @author Daniel Weber - Initial contribution
 */
@NonNullByDefault
public abstract class A5_10 extends _4BSMessage {

    public A5_10(ERP1Message packet) {
        super(packet);
    }

    @Override
    protected State convertToStateImpl(String channelId, String channelTypeId,
            Function<String, @Nullable State> getCurrentStateFunc, Configuration config) {
        switch (channelId) {
            case CHANNEL_FANSPEEDSTAGE:
                if (getDB3Value() > 209) {
                    return new StringType("-1");
                } else if (getDB3Value() > 189) {
                    return new StringType("0");
                } else if (getDB3Value() > 164) {
                    return new StringType("1");
                } else if (getDB3Value() > 144) {
                    return new StringType("2");
                } else {
                    return new StringType("3");
                }

            case CHANNEL_SETPOINT:
                return new DecimalType(getDB2Value());

            case CHANNEL_TEMPERATURE:
                double temp = (getDB1Value() - 255) / -6.375;
                return new QuantityType<>(temp, SIUnits.CELSIUS);

            case CHANNEL_OCCUPANCY:
                return getBit(getDB0(), 0) ? OnOffType.OFF : OnOffType.ON;
        }

        return UnDefType.UNDEF;
    }
}

Unfortunately I got no coding skills. So changing the code and creating a jar file is far beyond my skills.
Any help is appreciated because all my temp and humidity readings are incorrect at the moment. So rules get triggered incorrect :frowning:

Thank you!

1 Like

I’m enjoying my holiday and not back before next weekend. If not fixed already, I’ll have a look.

1 Like

Thank you, this sounds great.
Wish you a wonderful holiday :sunny:

@dirkdirk and whom also interessted in, I do also run EnOcean TF Sensors (EEP A5-04-03) and the values for temperatur and humidity have been correct over all OH3 versions and also with OH4 versions 4.0.1 (workaround) and now 4.0.2.

I use some enocean temperature sensors which are NOT EEP A5-10-12 (green line). They are working (A5-10-06) fine.

So it looks like (only?) the A5-10-12 (blue line) is not correct. Daniel (@fruggy83 ) fixed them some time ago.
See here:

The issue was fixed. Installed snapshot version 4.1 and everything is working as expected.

Thanks for the fix!