#pragma once
#include <cmath>
#include <vector>

#ifndef INIT_REQUEST_SIZE
#define INIT_REQUEST_SIZE 8
#endif
#ifndef INIT_RESPONSE_SIZE
#define INIT_RESPONSE_SIZE 51
#endif
#ifndef DATA_MESSAGE_SIZE
#define DATA_MESSAGE_SIZE 111
#endif
#ifndef OPTIONAL_MESSAGE_SIZE
#define OPTIONAL_MESSAGE_SIZE 20
#endif

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(int input);
  static uint8_t setMultiply4(int input);
  static uint8_t setPlus1Multiply4(int input);
  static uint8_t setPlus1Multiply8(int input);
  static uint8_t setPlus1Multiply16(int input);
  static uint8_t setPlus1Multiply64(int input);
  static uint8_t setPlus1(int input);
  static uint8_t setPlus128(int input);
  static uint8_t setOperationMode(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(size_t input);

  static const uint8_t InitialRequest[INIT_REQUEST_SIZE];
  static const uint8_t InitialResponse[INIT_RESPONSE_SIZE];
  static const uint8_t PollingMessage[DATA_MESSAGE_SIZE];
  static const uint8_t PollingExtraMessage[DATA_MESSAGE_SIZE];
  static const uint8_t CommandMessage[DATA_MESSAGE_SIZE];
};
}  // namespace panasonic_heatpump
}  // namespace esphome
