ESPHome 2026.6.0-dev
Loading...
Searching...
No Matches
vbus_binary_sensor.cpp
Go to the documentation of this file.
3#include "esphome/core/log.h"
4
5namespace esphome::vbus {
6
7static const char *const TAG = "vbus.binary_sensor";
8
10 ESP_LOGCONFIG(TAG, "Deltasol BS Plus:");
11 LOG_BINARY_SENSOR(" ", "Relay 1 On", this->relay1_bsensor_);
12 LOG_BINARY_SENSOR(" ", "Relay 2 On", this->relay2_bsensor_);
13 LOG_BINARY_SENSOR(" ", "Sensor 1 Error", this->s1_error_bsensor_);
14 LOG_BINARY_SENSOR(" ", "Sensor 2 Error", this->s2_error_bsensor_);
15 LOG_BINARY_SENSOR(" ", "Sensor 3 Error", this->s3_error_bsensor_);
16 LOG_BINARY_SENSOR(" ", "Sensor 4 Error", this->s4_error_bsensor_);
17 LOG_BINARY_SENSOR(" ", "Option Collector Max", this->collector_max_bsensor_);
18 LOG_BINARY_SENSOR(" ", "Option Collector Min", this->collector_min_bsensor_);
19 LOG_BINARY_SENSOR(" ", "Option Collector Frost", this->collector_frost_bsensor_);
20 LOG_BINARY_SENSOR(" ", "Option Tube Collector", this->tube_collector_bsensor_);
21 LOG_BINARY_SENSOR(" ", "Option Recooling", this->recooling_bsensor_);
22 LOG_BINARY_SENSOR(" ", "Option Heat Quantity Measurement", this->hqm_bsensor_);
23}
24
26 if (this->relay1_bsensor_ != nullptr)
27 this->relay1_bsensor_->publish_state(message[10] & 1);
28 if (this->relay2_bsensor_ != nullptr)
29 this->relay2_bsensor_->publish_state(message[10] & 2);
30 if (this->s1_error_bsensor_ != nullptr)
31 this->s1_error_bsensor_->publish_state(message[11] & 1);
32 if (this->s2_error_bsensor_ != nullptr)
33 this->s2_error_bsensor_->publish_state(message[11] & 2);
34 if (this->s3_error_bsensor_ != nullptr)
35 this->s3_error_bsensor_->publish_state(message[11] & 4);
36 if (this->s4_error_bsensor_ != nullptr)
37 this->s4_error_bsensor_->publish_state(message[11] & 8);
38 if (this->collector_max_bsensor_ != nullptr)
39 this->collector_max_bsensor_->publish_state(message[15] & 1);
40 if (this->collector_min_bsensor_ != nullptr)
41 this->collector_min_bsensor_->publish_state(message[15] & 2);
42 if (this->collector_frost_bsensor_ != nullptr)
43 this->collector_frost_bsensor_->publish_state(message[15] & 4);
44 if (this->tube_collector_bsensor_ != nullptr)
45 this->tube_collector_bsensor_->publish_state(message[15] & 8);
46 if (this->recooling_bsensor_ != nullptr)
47 this->recooling_bsensor_->publish_state(message[15] & 0x10);
48 if (this->hqm_bsensor_ != nullptr)
49 this->hqm_bsensor_->publish_state(message[15] & 0x20);
50}
51
53 ESP_LOGCONFIG(TAG, "Deltasol BS 2009:");
54 LOG_BINARY_SENSOR(" ", "Sensor 1 Error", this->s1_error_bsensor_);
55 LOG_BINARY_SENSOR(" ", "Sensor 2 Error", this->s2_error_bsensor_);
56 LOG_BINARY_SENSOR(" ", "Sensor 3 Error", this->s3_error_bsensor_);
57 LOG_BINARY_SENSOR(" ", "Sensor 4 Error", this->s4_error_bsensor_);
58 LOG_BINARY_SENSOR(" ", "Frost Protection Active", this->frost_protection_active_bsensor_);
59}
60
62 if (this->s1_error_bsensor_ != nullptr)
63 this->s1_error_bsensor_->publish_state(message[20] & 1);
64 if (this->s2_error_bsensor_ != nullptr)
65 this->s2_error_bsensor_->publish_state(message[20] & 2);
66 if (this->s3_error_bsensor_ != nullptr)
67 this->s3_error_bsensor_->publish_state(message[20] & 4);
68 if (this->s4_error_bsensor_ != nullptr)
69 this->s4_error_bsensor_->publish_state(message[20] & 8);
70 if (this->frost_protection_active_bsensor_ != nullptr)
71 this->frost_protection_active_bsensor_->publish_state(message[25] & 1);
72}
73
75 ESP_LOGCONFIG(TAG, "Deltasol C:");
76 LOG_BINARY_SENSOR(" ", "Sensor 1 Error", this->s1_error_bsensor_);
77 LOG_BINARY_SENSOR(" ", "Sensor 2 Error", this->s2_error_bsensor_);
78 LOG_BINARY_SENSOR(" ", "Sensor 3 Error", this->s3_error_bsensor_);
79 LOG_BINARY_SENSOR(" ", "Sensor 4 Error", this->s4_error_bsensor_);
80}
81
82void DeltaSolCBSensor::handle_message(std::vector<uint8_t> &message) {
83 if (this->s1_error_bsensor_ != nullptr)
84 this->s1_error_bsensor_->publish_state(message[10] & 1);
85 if (this->s2_error_bsensor_ != nullptr)
86 this->s2_error_bsensor_->publish_state(message[10] & 2);
87 if (this->s3_error_bsensor_ != nullptr)
88 this->s3_error_bsensor_->publish_state(message[10] & 4);
89 if (this->s4_error_bsensor_ != nullptr)
90 this->s4_error_bsensor_->publish_state(message[10] & 8);
91}
92
94 ESP_LOGCONFIG(TAG, "Deltasol CS2:");
95 LOG_BINARY_SENSOR(" ", "Sensor 1 Error", this->s1_error_bsensor_);
96 LOG_BINARY_SENSOR(" ", "Sensor 2 Error", this->s2_error_bsensor_);
97 LOG_BINARY_SENSOR(" ", "Sensor 3 Error", this->s3_error_bsensor_);
98 LOG_BINARY_SENSOR(" ", "Sensor 4 Error", this->s4_error_bsensor_);
99}
100
101void DeltaSolCS2BSensor::handle_message(std::vector<uint8_t> &message) {
102 if (this->s1_error_bsensor_ != nullptr)
103 this->s1_error_bsensor_->publish_state(message[18] & 1);
104 if (this->s2_error_bsensor_ != nullptr)
105 this->s2_error_bsensor_->publish_state(message[18] & 2);
106 if (this->s3_error_bsensor_ != nullptr)
107 this->s3_error_bsensor_->publish_state(message[18] & 4);
108 if (this->s4_error_bsensor_ != nullptr)
109 this->s4_error_bsensor_->publish_state(message[18] & 8);
110}
111
113 ESP_LOGCONFIG(TAG, "Deltasol CS4:");
114 LOG_BINARY_SENSOR(" ", "Sensor 1 Error", this->s1_error_bsensor_);
115 LOG_BINARY_SENSOR(" ", "Sensor 2 Error", this->s2_error_bsensor_);
116 LOG_BINARY_SENSOR(" ", "Sensor 3 Error", this->s3_error_bsensor_);
117 LOG_BINARY_SENSOR(" ", "Sensor 4 Error", this->s4_error_bsensor_);
118}
119
120void DeltaSolCS4BSensor::handle_message(std::vector<uint8_t> &message) {
121 if (this->s1_error_bsensor_ != nullptr)
122 this->s1_error_bsensor_->publish_state(message[20] & 1);
123 if (this->s2_error_bsensor_ != nullptr)
124 this->s2_error_bsensor_->publish_state(message[20] & 2);
125 if (this->s3_error_bsensor_ != nullptr)
126 this->s3_error_bsensor_->publish_state(message[20] & 4);
127 if (this->s4_error_bsensor_ != nullptr)
128 this->s4_error_bsensor_->publish_state(message[20] & 8);
129}
130
132 ESP_LOGCONFIG(TAG, "Deltasol CS Plus:");
133 LOG_BINARY_SENSOR(" ", "Sensor 1 Error", this->s1_error_bsensor_);
134 LOG_BINARY_SENSOR(" ", "Sensor 2 Error", this->s2_error_bsensor_);
135 LOG_BINARY_SENSOR(" ", "Sensor 3 Error", this->s3_error_bsensor_);
136 LOG_BINARY_SENSOR(" ", "Sensor 4 Error", this->s4_error_bsensor_);
137}
138
140 if (this->s1_error_bsensor_ != nullptr)
141 this->s1_error_bsensor_->publish_state(message[20] & 1);
142 if (this->s2_error_bsensor_ != nullptr)
143 this->s2_error_bsensor_->publish_state(message[20] & 2);
144 if (this->s3_error_bsensor_ != nullptr)
145 this->s3_error_bsensor_->publish_state(message[20] & 4);
146 if (this->s4_error_bsensor_ != nullptr)
147 this->s4_error_bsensor_->publish_state(message[20] & 8);
148}
149
151 ESP_LOGCONFIG(TAG, "DeltaSol BS/2 (DrainBack):");
152 LOG_BINARY_SENSOR(" ", "Sensor 1 Error", this->s1_error_bsensor_);
153 LOG_BINARY_SENSOR(" ", "Sensor 2 Error", this->s2_error_bsensor_);
154 LOG_BINARY_SENSOR(" ", "Sensor 3 Error", this->s3_error_bsensor_);
155 LOG_BINARY_SENSOR(" ", "Sensor 4 Error", this->s4_error_bsensor_);
156}
157
158void DeltaSolBS2BSensor::handle_message(std::vector<uint8_t> &message) {
159 if (this->s1_error_bsensor_ != nullptr)
160 this->s1_error_bsensor_->publish_state(message[10] & 1);
161 if (this->s2_error_bsensor_ != nullptr)
162 this->s2_error_bsensor_->publish_state(message[10] & 2);
163 if (this->s3_error_bsensor_ != nullptr)
164 this->s3_error_bsensor_->publish_state(message[10] & 4);
165 if (this->s4_error_bsensor_ != nullptr)
166 this->s4_error_bsensor_->publish_state(message[10] & 8);
167}
168
170 ESP_LOGCONFIG(TAG, "VBus Custom Binary Sensor:");
171 if (this->source_ == 0xffff) {
172 ESP_LOGCONFIG(TAG, " Source address: ANY");
173 } else {
174 ESP_LOGCONFIG(TAG, " Source address: 0x%04x", this->source_);
175 }
176 if (this->dest_ == 0xffff) {
177 ESP_LOGCONFIG(TAG, " Dest address: ANY");
178 } else {
179 ESP_LOGCONFIG(TAG, " Dest address: 0x%04x", this->dest_);
180 }
181 if (this->command_ == 0xffff) {
182 ESP_LOGCONFIG(TAG, " Command: ANY");
183 } else {
184 ESP_LOGCONFIG(TAG, " Command: 0x%04x", this->command_);
185 }
186 ESP_LOGCONFIG(TAG, " Binary Sensors:");
187 for (VBusCustomSubBSensor *bsensor : this->bsensors_) {
188 LOG_BINARY_SENSOR(" ", "-", bsensor);
189 }
190}
191
192void VBusCustomBSensor::handle_message(std::vector<uint8_t> &message) {
193 for (VBusCustomSubBSensor *bsensor : this->bsensors_)
194 bsensor->parse_message(message);
195}
196
197void VBusCustomSubBSensor::parse_message(std::vector<uint8_t> &message) {
198 this->publish_state(this->message_parser_(message));
199}
200
201} // namespace esphome::vbus
void publish_state(bool new_state)
Publish a new state to the front-end.
binary_sensor::BinarySensor * frost_protection_active_bsensor_
void handle_message(std::vector< uint8_t > &message) override
binary_sensor::BinarySensor * s4_error_bsensor_
binary_sensor::BinarySensor * s3_error_bsensor_
binary_sensor::BinarySensor * s1_error_bsensor_
binary_sensor::BinarySensor * s2_error_bsensor_
binary_sensor::BinarySensor * s4_error_bsensor_
binary_sensor::BinarySensor * s3_error_bsensor_
void handle_message(std::vector< uint8_t > &message) override
binary_sensor::BinarySensor * s2_error_bsensor_
binary_sensor::BinarySensor * s1_error_bsensor_
binary_sensor::BinarySensor * collector_max_bsensor_
binary_sensor::BinarySensor * hqm_bsensor_
binary_sensor::BinarySensor * s3_error_bsensor_
binary_sensor::BinarySensor * relay1_bsensor_
binary_sensor::BinarySensor * s1_error_bsensor_
binary_sensor::BinarySensor * collector_frost_bsensor_
binary_sensor::BinarySensor * s4_error_bsensor_
binary_sensor::BinarySensor * s2_error_bsensor_
binary_sensor::BinarySensor * tube_collector_bsensor_
binary_sensor::BinarySensor * relay2_bsensor_
binary_sensor::BinarySensor * collector_min_bsensor_
binary_sensor::BinarySensor * recooling_bsensor_
void handle_message(std::vector< uint8_t > &message) override
binary_sensor::BinarySensor * s1_error_bsensor_
binary_sensor::BinarySensor * s3_error_bsensor_
binary_sensor::BinarySensor * s4_error_bsensor_
void handle_message(std::vector< uint8_t > &message) override
binary_sensor::BinarySensor * s2_error_bsensor_
void handle_message(std::vector< uint8_t > &message) override
binary_sensor::BinarySensor * s2_error_bsensor_
binary_sensor::BinarySensor * s1_error_bsensor_
binary_sensor::BinarySensor * s4_error_bsensor_
binary_sensor::BinarySensor * s3_error_bsensor_
binary_sensor::BinarySensor * s4_error_bsensor_
void handle_message(std::vector< uint8_t > &message) override
binary_sensor::BinarySensor * s3_error_bsensor_
binary_sensor::BinarySensor * s2_error_bsensor_
binary_sensor::BinarySensor * s1_error_bsensor_
binary_sensor::BinarySensor * s1_error_bsensor_
binary_sensor::BinarySensor * s2_error_bsensor_
void handle_message(std::vector< uint8_t > &message) override
binary_sensor::BinarySensor * s3_error_bsensor_
binary_sensor::BinarySensor * s4_error_bsensor_
std::vector< VBusCustomSubBSensor * > bsensors_
void handle_message(std::vector< uint8_t > &message) override
void parse_message(std::vector< uint8_t > &message)
const LogString * message
Definition component.cpp:35