ElVit-esphome_components/components/panasonic_heatpump/commands.h

61 lines
2.9 KiB
C++

#pragma once
#include <cmath>
#include <vector>
#define REQUEST_INITIAL_SIZE 8
#define REQUEST_DATA_SIZE 111
#define REQUEST_OPTIONAL_SIZE 20
namespace esphome
{
namespace panasonic_heatpump
{
class PanasonicCommand
{
public:
PanasonicCommand() = delete;
static uint8_t calcChecksum(std::vector<uint8_t>& data, int length);
static uint8_t setMultiply2(unsigned int input);
static uint8_t setMultiply4(unsigned int input);
static uint8_t setPlus1Multiply4(unsigned int input);
static uint8_t setPlus1Multiply8(unsigned int input);
static uint8_t setPlus1Multiply16(unsigned int input);
static uint8_t setPlus1Multiply64(unsigned int input);
static uint8_t setPlus1(unsigned int input);
static uint8_t setPlus73(unsigned int input);
static uint8_t setPlus128(unsigned int input);
static uint8_t setOperationMode(unsigned int input);
static uint8_t setBivalentMode(unsigned int input);
static uint8_t temp2hex(float temp);
static uint8_t setByte6(uint8_t byte6, int val, int base, int bit);
static uint8_t setDemandControl(unsigned int input);
static constexpr uint8_t InitialMessage[REQUEST_INITIAL_SIZE] = {
0x31, 0x05, 0x10, 0x01, 0x00, 0x00, 0x00, 0xB9
};
static constexpr uint8_t PeriodicalMessage[REQUEST_DATA_SIZE] = {
0x71, 0x6C, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x12
};
static constexpr uint8_t CommandMessage[REQUEST_DATA_SIZE] = {
0xF1, 0x6C, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x92
};
};
} // namespace panasonic_heatpump
} // namespace esphome