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

Added Amina S device #8191

Merged
merged 10 commits into from
Oct 31, 2024
Merged

Added Amina S device #8191

merged 10 commits into from
Oct 31, 2024

Conversation

somlioy
Copy link
Contributor

@somlioy somlioy commented Oct 26, 2024

Added new device Amina S, EV charger.

Device Zigbee documentation:
https://doc.clickup.com/9004130215/p/h/8cb07x7-18308/c750786359b035a

Device firmware update procedure (atleast FW 1.8.7 is required, currently at 1.8.50):
https://doc.clickup.com/9004130215/p/h/8cb07x7-30795/12688a97b1dfa55

};

const aminaAlarms = [
'Welded relay(s)',
Copy link
Owner

Choose a reason for hiding this comment

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

Please make all of these snake_case:

Suggested change
'Welded relay(s)',
'welded_relays',

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just curious, what is the purpose of converting those to snake case but not status texts for ev_status for instance?

Copy link
Owner

Choose a reason for hiding this comment

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

Usually text is free format, but for this use case it may be better to use a e.enum()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably enum would work, but as the value from the device is «bit encoded» one could in theory have multiple alarms as once? Probably not very likely tho, but possible.

Copy link
Owner

Choose a reason for hiding this comment

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

Good point, e.list() with an e.enum() as the type would be the best then.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you have any examples of how to do this, because whatever I do, the GUI only shows an array of strings, or is this expected behaviour?
I defined:

const aminaAlarms = [
    'no_alarm',
    'welded_relay', // Bit 0
    'wrong_voltage_balance',
    'rdc_dd_dc_leakage',
    'rdc_dd_ac_leakage',
    'high_temperature',
    'overvoltage',
    'undervoltage',
    'overcurrent',
    'car_communication_error',
    'charger_processing_error',
    'critical_overcurrent',
    'critical_powerloss',
    'unknown_alarm_bit_12',
    'unknown_alarm_bit_13',
    'unknown_alarm_bit_14',
    'unknown_alarm_bit_15',
];

const aminaAlarmsEnum = e.enum('alarms', ea.STATE_GET, aminaAlarms);

In the fzLocal.alarms converter:

if (msg.data.alarms !== undefined) {
    const activeAlarms = [];
    result.alarm_active = false;

    for (let i = 0; i < 16; i++) {
        if ((msg.data['alarms'] >> i) & 0x01) {
            activeAlarms.push(aminaAlarmsEnum.values[i+1]);
            result.alarm_active = true;
        }
    }

    if (result.alarm_active === false) {
        activeAlarms.push(aminaAlarmsEnum.values[0]);
    }

    result.alarms = activeAlarms;
    return result;
}

And finally the expose:

e.list('alarms', ea.STATE_GET, aminaAlarmsEnum).withDescription('List of active alarms'),

Example result with bit 1, 3 and 12 enabled:
image

Example result with no alarms:
image

I would perhaps expect something like this, not editable of course:
image

Copy link
Owner

Choose a reason for hiding this comment

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

This is expected indeed, the frontend should be improved a bit here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright then, this is implemented in 8263316

@Koenkk Koenkk merged commit 24e4ab9 into Koenkk:master Oct 31, 2024
2 checks passed
@Koenkk
Copy link
Owner

Koenkk commented Oct 31, 2024

Thanks!

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.

3 participants