ESPHome 2026.3.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 {
6namespace vbus {
7
8static const char *const TAG = "vbus.binary_sensor";
9
11 ESP_LOGCONFIG(TAG, "Deltasol BS Plus:");
12 LOG_BINARY_SENSOR(" ", "Relay 1 On", this->relay1_bsensor_);
13 LOG_BINARY_SENSOR(" ", "Relay 2 On", this->relay2_bsensor_);
14 LOG_BINARY_SENSOR(" ", "Sensor 1 Error", this->s1_error_bsensor_);
15 LOG_BINARY_SENSOR(" ", "Sensor 2 Error", this->s2_error_bsensor_);
16 LOG_BINARY_SENSOR(" ", "Sensor 3 Error", this->s3_error_bsensor_);
17 LOG_BINARY_SENSOR(" ", "Sensor 4 Error", this->s4_error_bsensor_);
18 LOG_BINARY_SENSOR(" ", "Option Collector Max", this->collector_max_bsensor_);
19 LOG_BINARY_SENSOR(" ", "Option Collector Min", this->collector_min_bsensor_);
20 LOG_BINARY_SENSOR(" ", "Option Collector Frost", this->collector_frost_bsensor_);
21 LOG_BINARY_SENSOR(" ", "Option Tube Collector", this->tube_collector_bsensor_);
22 LOG_BINARY_SENSOR(" ", "Option Recooling", this->recooling_bsensor_);
23 LOG_BINARY_SENSOR(" ", "Option Heat Quantity Measurement", this->hqm_bsensor_);
24}
25
27 if (this->relay1_bsensor_ != nullptr)
28 this->relay1_bsensor_->publish_state(message[10] & 1);
29 if (this->relay2_bsensor_ != nullptr)
30 this->relay2_bsensor_->publish_state(message[10] & 2);
31 if (this->s1_error_bsensor_ != nullptr)
32 this->s1_error_bsensor_->publish_state(message[11] & 1);
33 if (this->s2_error_bsensor_ != nullptr)
34 this->s2_error_bsensor_->publish_state(message[11] & 2);
35 if (this->s3_error_bsensor_ != nullptr)
36 this->s3_error_bsensor_->publish_state(message[11] & 4);
37 if (this->s4_error_bsensor_ != nullptr)
38 this->s4_error_bsensor_->publish_state(message[11] & 8);
39 if (this->collector_max_bsensor_ != nullptr)
40 this->collector_max_bsensor_->publish_state(message[15] & 1);
41 if (this->collector_min_bsensor_ != nullptr)
42 this->collector_min_bsensor_->publish_state(message[15] & 2);
43 if (this->collector_frost_bsensor_ != nullptr)
44 this->collector_frost_bsensor_->publish_state(message[15] & 4);
45 if (this->tube_collector_bsensor_ != nullptr)
46 this->tube_collector_bsensor_->publish_state(message[15] & 8);
47 if (this->recooling_bsensor_ != nullptr)
48 this->recooling_bsensor_->publish_state(message[15] & 0x10);
49 if (this->hqm_bsensor_ != nullptr)
50 this->hqm_bsensor_->publish_state(message[15] & 0x20);
51}
52
54 ESP_LOGCONFIG(TAG, "Deltasol BS 2009:");
55 LOG_BINARY_SENSOR(" ", "Sensor 1 Error", this->s1_error_bsensor_);
56 LOG_BINARY_SENSOR(" ", "Sensor 2 Error", this->s2_error_bsensor_);
57 LOG_BINARY_SENSOR(" ", "Sensor 3 Error", this->s3_error_bsensor_);
58 LOG_BINARY_SENSOR(" ", "Sensor 4 Error", this->s4_error_bsensor_);
59 LOG_BINARY_SENSOR(" ", "Frost Protection Active", this->frost_protection_active_bsensor_);
60}
61
63 if (this->s1_error_bsensor_ != nullptr)
64 this->s1_error_bsensor_->publish_state(message[20] & 1);
65 if (this->s2_error_bsensor_ != nullptr)
66 this->s2_error_bsensor_->publish_state(message[20] & 2);
67 if (this->s3_error_bsensor_ != nullptr)
68 this->s3_error_bsensor_->publish_state(message[20] & 4);
69 if (this->s4_error_bsensor_ != nullptr)
70 this->s4_error_bsensor_->publish_state(message[20] & 8);
71 if (this->frost_protection_active_bsensor_ != nullptr)
72 this->frost_protection_active_bsensor_->publish_state(message[25] & 1);
73}
74
76 ESP_LOGCONFIG(TAG, "Deltasol C:");
77 LOG_BINARY_SENSOR(" ", "Sensor 1 Error", this->s1_error_bsensor_);
78 LOG_BINARY_SENSOR(" ", "Sensor 2 Error", this->s2_error_bsensor_);
79 LOG_BINARY_SENSOR(" ", "Sensor 3 Error", this->s3_error_bsensor_);
80 LOG_BINARY_SENSOR(" ", "Sensor 4 Error", this->s4_error_bsensor_);
81}
82
83void DeltaSolCBSensor::handle_message(std::vector<uint8_t> &message) {
84 if (this->s1_error_bsensor_ != nullptr)
85 this->s1_error_bsensor_->publish_state(message[10] & 1);
86 if (this->s2_error_bsensor_ != nullptr)
87 this->s2_error_bsensor_->publish_state(message[10] & 2);
88 if (this->s3_error_bsensor_ != nullptr)
89 this->s3_error_bsensor_->publish_state(message[10] & 4);
90 if (this->s4_error_bsensor_ != nullptr)
91 this->s4_error_bsensor_->publish_state(message[10] & 8);
92}
93
95 ESP_LOGCONFIG(TAG, "Deltasol CS2:");
96 LOG_BINARY_SENSOR(" ", "Sensor 1 Error", this->s1_error_bsensor_);
97 LOG_BINARY_SENSOR(" ", "Sensor 2 Error", this->s2_error_bsensor_);
98 LOG_BINARY_SENSOR(" ", "Sensor 3 Error", this->s3_error_bsensor_);
99 LOG_BINARY_SENSOR(" ", "Sensor 4 Error", this->s4_error_bsensor_);
100}
101
102void DeltaSolCS2BSensor::handle_message(std::vector<uint8_t> &message) {
103 if (this->s1_error_bsensor_ != nullptr)
104 this->s1_error_bsensor_->publish_state(message[18] & 1);
105 if (this->s2_error_bsensor_ != nullptr)
106 this->s2_error_bsensor_->publish_state(message[18] & 2);
107 if (this->s3_error_bsensor_ != nullptr)
108 this->s3_error_bsensor_->publish_state(message[18] & 4);
109 if (this->s4_error_bsensor_ != nullptr)
110 this->s4_error_bsensor_->publish_state(message[18] & 8);
111}
112
114 ESP_LOGCONFIG(TAG, "Deltasol CS Plus:");
115 LOG_BINARY_SENSOR(" ", "Sensor 1 Error", this->s1_error_bsensor_);
116 LOG_BINARY_SENSOR(" ", "Sensor 2 Error", this->s2_error_bsensor_);
117 LOG_BINARY_SENSOR(" ", "Sensor 3 Error", this->s3_error_bsensor_);
118 LOG_BINARY_SENSOR(" ", "Sensor 4 Error", this->s4_error_bsensor_);
119}
120
122 if (this->s1_error_bsensor_ != nullptr)
123 this->s1_error_bsensor_->publish_state(message[20] & 1);
124 if (this->s2_error_bsensor_ != nullptr)
125 this->s2_error_bsensor_->publish_state(message[20] & 2);
126 if (this->s3_error_bsensor_ != nullptr)
127 this->s3_error_bsensor_->publish_state(message[20] & 4);
128 if (this->s4_error_bsensor_ != nullptr)
129 this->s4_error_bsensor_->publish_state(message[20] & 8);
130}
131
133 ESP_LOGCONFIG(TAG, "DeltaSol BS/2 (DrainBack):");
134 LOG_BINARY_SENSOR(" ", "Sensor 1 Error", this->s1_error_bsensor_);
135 LOG_BINARY_SENSOR(" ", "Sensor 2 Error", this->s2_error_bsensor_);
136 LOG_BINARY_SENSOR(" ", "Sensor 3 Error", this->s3_error_bsensor_);
137 LOG_BINARY_SENSOR(" ", "Sensor 4 Error", this->s4_error_bsensor_);
138}
139
140void DeltaSolBS2BSensor::handle_message(std::vector<uint8_t> &message) {
141 if (this->s1_error_bsensor_ != nullptr)
142 this->s1_error_bsensor_->publish_state(message[10] & 1);
143 if (this->s2_error_bsensor_ != nullptr)
144 this->s2_error_bsensor_->publish_state(message[10] & 2);
145 if (this->s3_error_bsensor_ != nullptr)
146 this->s3_error_bsensor_->publish_state(message[10] & 4);
147 if (this->s4_error_bsensor_ != nullptr)
148 this->s4_error_bsensor_->publish_state(message[10] & 8);
149}
150
152 ESP_LOGCONFIG(TAG, "VBus Custom Binary Sensor:");
153 if (this->source_ == 0xffff) {
154 ESP_LOGCONFIG(TAG, " Source address: ANY");
155 } else {
156 ESP_LOGCONFIG(TAG, " Source address: 0x%04x", this->source_);
157 }
158 if (this->dest_ == 0xffff) {
159 ESP_LOGCONFIG(TAG, " Dest address: ANY");
160 } else {
161 ESP_LOGCONFIG(TAG, " Dest address: 0x%04x", this->dest_);
162 }
163 if (this->command_ == 0xffff) {
164 ESP_LOGCONFIG(TAG, " Command: ANY");
165 } else {
166 ESP_LOGCONFIG(TAG, " Command: 0x%04x", this->command_);
167 }
168 ESP_LOGCONFIG(TAG, " Binary Sensors:");
169 for (VBusCustomSubBSensor *bsensor : this->bsensors_) {
170 LOG_BINARY_SENSOR(" ", "-", bsensor);
171 }
172}
173
174void VBusCustomBSensor::handle_message(std::vector<uint8_t> &message) {
175 for (VBusCustomSubBSensor *bsensor : this->bsensors_)
176 bsensor->parse_message(message);
177}
178
179void VBusCustomSubBSensor::parse_message(std::vector<uint8_t> &message) {
180 this->publish_state(this->message_parser_(message));
181}
182
183} // namespace vbus
184} // namespace esphome
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 * 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 char * message
Definition component.cpp:38
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7