Skip to content

Commit

Permalink
Feature: Add one channel HMS inverter with different byte assignment
Browse files Browse the repository at this point in the history
Fix #1148
  • Loading branch information
tbnobody committed Sep 14, 2023
1 parent 0533c0b commit 21fb10f
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/Hoymiles/src/Hoymiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "Hoymiles.h"
#include "Utils.h"
#include "inverters/HMS_1CH.h"
#include "inverters/HMS_1CHv2.h"
#include "inverters/HMS_2CH.h"
#include "inverters/HMS_4CH.h"
#include "inverters/HMT_6CH.h"
Expand Down Expand Up @@ -147,6 +148,8 @@ std::shared_ptr<InverterAbstract> HoymilesClass::addInverter(const char* name, u
i = std::make_shared<HMS_2CH>(_radioCmt.get(), serial);
} else if (HMS_1CH::isValidSerial(serial)) {
i = std::make_shared<HMS_1CH>(_radioCmt.get(), serial);
} else if (HMS_1CHv2::isValidSerial(serial)) {
i = std::make_shared<HMS_1CHv2>(_radioCmt.get(), serial);
} else if (HM_4CH::isValidSerial(serial)) {
i = std::make_shared<HM_4CH>(_radioNrf.get(), serial);
} else if (HM_2CH::isValidSerial(serial)) {
Expand Down
54 changes: 54 additions & 0 deletions lib/Hoymiles/src/inverters/HMS_1CHv2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (C) 2023 Thomas Basler and others
*/
#include "HMS_1CHv2.h"

static const byteAssign_t byteAssignment[] = {
{ TYPE_DC, CH0, FLD_UDC, UNIT_V, 2, 2, 10, false, 1 },
{ TYPE_DC, CH0, FLD_IDC, UNIT_A, 6, 2, 100, false, 2 },
{ TYPE_DC, CH0, FLD_PDC, UNIT_W, 10, 2, 10, false, 1 },
{ TYPE_DC, CH0, FLD_YD, UNIT_WH, 22, 2, 1, false, 0 },
{ TYPE_DC, CH0, FLD_YT, UNIT_KWH, 14, 4, 1000, false, 3 },
{ TYPE_DC, CH0, FLD_IRR, UNIT_PCT, CALC_IRR_CH, CH0, CMD_CALC, false, 3 },

{ TYPE_AC, CH0, FLD_UAC, UNIT_V, 26, 2, 10, false, 1 },
{ TYPE_AC, CH0, FLD_IAC, UNIT_A, 34, 2, 100, false, 2 },
{ TYPE_AC, CH0, FLD_PAC, UNIT_W, 30, 2, 10, false, 1 },
{ TYPE_AC, CH0, FLD_Q, UNIT_VAR, 20, 2, 10, false, 1 },
{ TYPE_AC, CH0, FLD_F, UNIT_HZ, 28, 2, 100, false, 2 },
{ TYPE_AC, CH0, FLD_PF, UNIT_NONE, 36, 2, 1000, false, 3 },

{ TYPE_INV, CH0, FLD_T, UNIT_C, 38, 2, 10, true, 1 },
{ TYPE_INV, CH0, FLD_EVT_LOG, UNIT_NONE, 18, 2, 1, false, 0 },

{ TYPE_AC, CH0, FLD_YD, UNIT_WH, CALC_YD_CH0, 0, CMD_CALC, false, 0 },
{ TYPE_AC, CH0, FLD_YT, UNIT_KWH, CALC_YT_CH0, 0, CMD_CALC, false, 3 },
{ TYPE_AC, CH0, FLD_PDC, UNIT_W, CALC_PDC_CH0, 0, CMD_CALC, false, 1 },
{ TYPE_AC, CH0, FLD_EFF, UNIT_PCT, CALC_EFF_CH0, 0, CMD_CALC, false, 3 }
};

HMS_1CHv2::HMS_1CHv2(HoymilesRadio* radio, uint64_t serial)
: HMS_Abstract(radio, serial) {};

bool HMS_1CHv2::isValidSerial(uint64_t serial)
{
// serial >= 0x112500000000 && serial <= 0x112599999999
uint16_t preSerial = (serial >> 32) & 0xffff;
return preSerial == 0x1125;
}

String HMS_1CHv2::typeName()
{
return "HMS-500 v2";
}

const byteAssign_t* HMS_1CHv2::getByteAssignment()
{
return byteAssignment;
}

uint8_t HMS_1CHv2::getByteAssignmentSize()
{
return sizeof(byteAssignment) / sizeof(byteAssignment[0]);
}
14 changes: 14 additions & 0 deletions lib/Hoymiles/src/inverters/HMS_1CHv2.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once

#include "HMS_Abstract.h"
#include <list>

class HMS_1CHv2 : public HMS_Abstract {
public:
explicit HMS_1CHv2(HoymilesRadio* radio, uint64_t serial);
static bool isValidSerial(uint64_t serial);
String typeName();
const byteAssign_t* getByteAssignment();
uint8_t getByteAssignmentSize();
};
1 change: 1 addition & 0 deletions lib/Hoymiles/src/parser/DevInfoParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const devInfo_t devInfo[] = {
{ { 0x10, 0x20, 0x41, ALL }, 400, "HMS-400" }, // 00
{ { 0x10, 0x10, 0x51, ALL }, 450, "HMS-450" }, // 01
{ { 0x10, 0x10, 0x71, ALL }, 500, "HMS-500" }, // 02
{ { 0x10, 0x20, 0x71, ALL }, 500, "HMS-500 v2" }, // 02
{ { 0x10, 0x21, 0x11, ALL }, 600, "HMS-600" }, // 01
{ { 0x10, 0x21, 0x41, ALL }, 800, "HMS-800" }, // 00
{ { 0x10, 0x11, 0x51, ALL }, 900, "HMS-900" }, // 01
Expand Down

0 comments on commit 21fb10f

Please sign in to comment.