ESPHome  2024.11.0
bedjet_sensor.cpp
Go to the documentation of this file.
1 #include "bedjet_sensor.h"
2 #include "esphome/core/log.h"
3 
4 namespace esphome {
5 namespace bedjet {
6 
7 std::string BedjetSensor::describe() { return "BedJet Sensor"; }
8 
10  ESP_LOGCONFIG(TAG, "BedJet Sensor:");
11  LOG_SENSOR(" ", "Outlet Temperature", this->outlet_temperature_sensor_);
12  LOG_SENSOR(" ", "Ambient Temperature", this->ambient_temperature_sensor_);
13 }
14 
16 
18  if (this->outlet_temperature_sensor_ != nullptr) {
19  float converted_temp = bedjet_temp_to_c(data->actual_temp_step);
20  if (converted_temp > 0) {
21  this->outlet_temperature_sensor_->publish_state(converted_temp);
22  }
23  }
24 
25  if (this->ambient_temperature_sensor_ != nullptr) {
26  float converted_temp = bedjet_temp_to_c(data->ambient_temp_step);
27  if (converted_temp > 0) {
28  this->ambient_temperature_sensor_->publish_state(converted_temp);
29  }
30  }
31 }
32 
33 } // namespace bedjet
34 } // namespace esphome
sensor::Sensor * outlet_temperature_sensor_
Definition: bedjet_sensor.h:27
void on_bedjet_state(bool is_ready) override
uint8_t ambient_temp_step
Current ambient air temp.
Definition: bedjet_codec.h:73
The format of a BedJet V3 status packet.
Definition: bedjet_codec.h:39
float bedjet_temp_to_c(uint8_t temp)
Converts a BedJet temp step into degrees Celsius.
bool is_ready() const
Definition: component.cpp:144
void publish_state(float state)
Publish a new state to the front-end.
Definition: sensor.cpp:39
sensor::Sensor * ambient_temperature_sensor_
Definition: bedjet_sensor.h:28
void on_status(const BedjetStatusPacket *data) override
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
std::string describe() override
uint8_t actual_temp_step
Actual temp of the air blown by the BedJet fan; value represents 2 * degrees_celsius.
Definition: bedjet_codec.h:54