diff --git a/components/samsung_ac/__init__.py b/components/samsung_ac/__init__.py index 7a4c16e8..ddef7842 100644 --- a/components/samsung_ac/__init__.py +++ b/components/samsung_ac/__init__.py @@ -49,6 +49,7 @@ CONF_DEVICE_ROOM_TEMPERATURE = "room_temperature" CONF_DEVICE_ROOM_HUMIDITY = "room_humidity" CONF_DEVICE_TARGET_TEMPERATURE = "target_temperature" +CONF_DEVICE_WATER_TEMPERATURE = "water_temperature" CONF_DEVICE_POWER = "power" CONF_DEVICE_MODE = "mode" CONF_DEVICE_CLIMATE = "climate" @@ -64,6 +65,12 @@ device_class=DEVICE_CLASS_TEMPERATURE, state_class=STATE_CLASS_MEASUREMENT, ), + cv.Optional(CONF_DEVICE_WATER_TEMPERATURE): sensor.sensor_schema( + unit_of_measurement=UNIT_CELSIUS, + accuracy_decimals=1, + device_class=DEVICE_CLASS_TEMPERATURE, + state_class=STATE_CLASS_MEASUREMENT, + ), cv.Optional(CONF_DEVICE_ROOM_HUMIDITY): sensor.sensor_schema( unit_of_measurement=UNIT_PERCENT, accuracy_decimals=0, @@ -127,6 +134,11 @@ async def to_code(config): sens = await sensor.new_sensor(conf) cg.add(var_dev.set_room_temperature_sensor(sens)) + if CONF_DEVICE_WATER_TEMPERATURE in device: + conf = device[CONF_DEVICE_WATER_TEMPERATURE] + sens = await sensor.new_sensor(conf) + cg.add(var_dev.set_water_temperature_sensor(sens)) + if CONF_DEVICE_ROOM_HUMIDITY in device: conf = device[CONF_DEVICE_ROOM_HUMIDITY] sens = await sensor.new_sensor(conf) diff --git a/components/samsung_ac/protocol.h b/components/samsung_ac/protocol.h index 779be9c8..9ee42f39 100644 --- a/components/samsung_ac/protocol.h +++ b/components/samsung_ac/protocol.h @@ -68,6 +68,7 @@ namespace esphome virtual void register_address(const std::string address) = 0; virtual void set_power(const std::string address, bool value) = 0; virtual void set_room_temperature(const std::string address, float value) = 0; + virtual void set_water_temperature(const std::string address, float value) = 0; virtual void set_room_humidity(const std::string address, float value) = 0; virtual void set_target_temperature(const std::string address, float value) = 0; virtual void set_mode(const std::string address, Mode mode) = 0; diff --git a/components/samsung_ac/protocol_nasa.cpp b/components/samsung_ac/protocol_nasa.cpp index fd3f4ec5..89aed10f 100644 --- a/components/samsung_ac/protocol_nasa.cpp +++ b/components/samsung_ac/protocol_nasa.cpp @@ -623,6 +623,8 @@ namespace esphome // VAR_IN_TEMP_WATER_TANK_F double temp = (double)message.value / (double)10; ESP_LOGW(TAG, "s:%s d:%s VAR_IN_TEMP_WATER_TANK_F %f", source.c_str(), dest.c_str(), temp); + target->set_water_temperature(source, temp); + return; } if ((uint16_t)message.messageNumber == 0x4065) diff --git a/components/samsung_ac/samsung_ac.h b/components/samsung_ac/samsung_ac.h index c7bcbdd5..cb9a18f5 100644 --- a/components/samsung_ac/samsung_ac.h +++ b/components/samsung_ac/samsung_ac.h @@ -68,6 +68,13 @@ namespace esphome dev->update_room_temperature(value); } + void /*MessageTarget::*/ set_water_temperature(const std::string address, float value) override + { + Samsung_AC_Device *dev = find_device(address); + if (dev != nullptr) + dev->update_water_temperature(value); + } + void /*MessageTarget::*/ set_room_humidity(const std::string address, float value) override { Samsung_AC_Device *dev = find_device(address); diff --git a/components/samsung_ac/samsung_ac_device.h b/components/samsung_ac/samsung_ac_device.h index eac3a178..fb62648e 100644 --- a/components/samsung_ac/samsung_ac_device.h +++ b/components/samsung_ac/samsung_ac_device.h @@ -77,6 +77,7 @@ namespace esphome std::string address; sensor::Sensor *room_temperature{nullptr}; + sensor::Sensor *water_temperature{nullptr}; sensor::Sensor *room_humidity{nullptr}; Samsung_AC_Number *target_temperature{nullptr}; Samsung_AC_Switch *power{nullptr}; @@ -88,6 +89,11 @@ namespace esphome room_temperature = sensor; } + void set_water_temperature_sensor(sensor::Sensor *sensor) + { + water_temperature = sensor; + } + void set_room_humidity_sensor(sensor::Sensor *sensor) { room_humidity = sensor; @@ -233,6 +239,12 @@ namespace esphome } } + void update_water_temperature(float value) + { + if (water_temperature != nullptr) + water_temperature->publish_state(value); + } + void update_room_humidity(float value) { if (room_humidity != nullptr) diff --git a/test/test_stuff.h b/test/test_stuff.h index cd1d0bff..f59bb92f 100644 --- a/test/test_stuff.h +++ b/test/test_stuff.h @@ -51,6 +51,15 @@ class DebugTarget : public MessageTarget last_set_room_temperature_value = value; } + std::string last_set_water_temperature_address; + float last_set_water_temperature_value; + void set_water_temperature(const std::string address, float value) + { + cout << "> " << address << " set_water_temperature=" << to_string(value) << endl; + last_set_water_temperature_address = address; + last_set_water_temperature_value = value; + } + std::string last_set_target_temperature_address; float last_set_target_temperature_value; void set_target_temperature(const std::string address, float value)