Solar/cbf_pylon.h
2025-09-03 22:38:18 +02:00

40 lines
2.1 KiB
C++

#ifndef __SOLAR_CBF_PYLON // include GUARD
#define __SOLAR_CBF_PYLON
#include "esphome.h"
#include <utility>
#include "common.h"
#include "cb_frame.h"
using namespace esphome;
namespace solar
{
class cbf_pylon : virtual public cb_frame {
public:
// Pylontech publish spec
// This is used to determine when to publish the battery data from the Pylontech battery
static const publish_spec_t publish_spec; // default publish spec for Pylontech battery messages
static const publish_spec_t rtr_publish_spec; // for remote transmission requests
// Pylontech battery CAN IDs
// https://domosimple.eu/en/documentation/manuels/pylontech-can-bus-protocole
// VERIFIED IDs have been confirmed by capturing actual CAN bus traffic from a Pylontech battery
static const int CB_BATTERY_LIMITS = 0x351; // VERIFIED: Pylontech battery max charging/discharging values message
static const int CB_BATTERY_STATE = 0x355; // VERIFIED: Pylontech battery state message
static const int CB_BATTERY_STATUS = 0x356; // VERIFIED: Pylontech battery status message
static const int CB_BATTERY_FAULT = 0x359; // VERIFIED: Pylontech battery fault message
static const int CB_BATTERY_REQUEST_FLAGS = 0x35C; // VERIFIED: Pylontech battery request flag message
static const int CB_BATTERY_MANUFACTURER = 0x35E; // VERIFIED: Pylontech battery manufacturer message
//Property<int, cbf_pylon> battery_charge_voltage_limit {this, &cbf_pylon::_set_battery_charge_voltage_limit, &cbf_pylon::_get_battery_charge_voltage_limit };
//Property<float, cbf_pylon> battery_charge_voltage_limit {this, &cbf_pylon::_get_battery_charge_voltage_limit};
cbf_pylon() = default;
cbf_pylon(int msg_id, uint32_t can_id, const byte_vector& frame, bool rtr);
void clear();
virtual std::string to_string() const override;
cbf_pylon& operator=(cbf_pylon&& src); // required due to double inheritance in cbf_store_pylon
// using default (compiler auto generated) copy and move constructors and assignment operators
};
} // namespace solar
#endif // __SOLAR_CBF_PYLON