From 6d35cf1490e8ff534c467658dcb64f2bcc4ca05f Mon Sep 17 00:00:00 2001 From: Steve Wagner Date: Mon, 19 Feb 2024 16:36:27 +0100 Subject: [PATCH] Add room_temperature_offset --- components/samsung_ac/__init__.py | 7 ++++++- components/samsung_ac/samsung_ac_device.h | 10 ++++++++-- example.yaml | 6 +++++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/components/samsung_ac/__init__.py b/components/samsung_ac/__init__.py index b4e5d171..7b8a7918 100644 --- a/components/samsung_ac/__init__.py +++ b/components/samsung_ac/__init__.py @@ -51,6 +51,7 @@ CONF_DEVICE_ID = "samsung_ac_device_id" CONF_DEVICE_ADDRESS = "address" CONF_DEVICE_ROOM_TEMPERATURE = "room_temperature" +CONF_DEVICE_ROOM_TEMPERATURE_OFFSET = "room_temperature_offset" CONF_DEVICE_TARGET_TEMPERATURE = "target_temperature" CONF_DEVICE_OUTDOOR_TEMPERATURE = "outdoor_temperature" CONF_DEVICE_POWER = "power" @@ -168,13 +169,13 @@ def humidity_sensor_schema(message: int): device_class=DEVICE_CLASS_TEMPERATURE, state_class=STATE_CLASS_MEASUREMENT, ), + cv.Optional(CONF_DEVICE_ROOM_TEMPERATURE_OFFSET): cv.float_, cv.Optional(CONF_DEVICE_OUTDOOR_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_TARGET_TEMPERATURE): NUMBER_SCHEMA, cv.Optional(CONF_DEVICE_POWER): switch.switch_schema(Samsung_AC_Switch), cv.Optional(CONF_DEVICE_MODE): SELECT_MODE_SCHEMA, @@ -290,6 +291,10 @@ async def to_code(config): sens = await sensor.new_sensor(conf) cg.add(var_dev.set_room_temperature_sensor(sens)) + if CONF_DEVICE_ROOM_TEMPERATURE_OFFSET in device: + cg.add(var_dev.set_room_temperature_offset( + device[CONF_DEVICE_ROOM_TEMPERATURE_OFFSET])) + if CONF_DEVICE_OUTDOOR_TEMPERATURE in device: conf = device[CONF_DEVICE_OUTDOOR_TEMPERATURE] sens = await sensor.new_sensor(conf) diff --git a/components/samsung_ac/samsung_ac_device.h b/components/samsung_ac/samsung_ac_device.h index 08d3d390..bd1717df 100644 --- a/components/samsung_ac/samsung_ac_device.h +++ b/components/samsung_ac/samsung_ac_device.h @@ -94,6 +94,7 @@ namespace esphome Samsung_AC_Mode_Select *mode{nullptr}; Samsung_AC_Climate *climate{nullptr}; std::vector custom_sensors; + float room_temperature_offset{0}; void set_room_temperature_sensor(sensor::Sensor *sensor) { @@ -262,10 +263,10 @@ namespace esphome void update_room_temperature(float value) { if (room_temperature != nullptr) - room_temperature->publish_state(value); + room_temperature->publish_state(value + room_temperature_offset); if (climate != nullptr) { - climate->current_temperature = value; + climate->current_temperature = value + room_temperature_offset; climate->publish_state(); } } @@ -321,6 +322,11 @@ namespace esphome return &alt_modes; } + void set_room_temperature_offset(float value) + { + room_temperature_offset = value; + } + protected: bool supports_horizontal_swing_{true}; bool supports_vertical_swing_{true}; diff --git a/example.yaml b/example.yaml index b0b57e61..a9306eb5 100644 --- a/example.yaml +++ b/example.yaml @@ -79,7 +79,7 @@ samsung_ac: # Repeat everything below for each indoor device address you see in your logs - address: "20.00.00" # Indoor device address # Each property below is optional (climate, room_temperature etc.) - you can delete those which you dont need. - # For the names I suggest to choose a combination of room name and the thing it controls. + # For the names we suggest to choose a combination of room name and the thing it controls. # Configures/overrides the capabilites for this devices. # Look above for all options. @@ -100,6 +100,10 @@ samsung_ac: mode: name: "Kitchen mode" + # If your AC sits near or inside the ceiling, the reported room temperature is often a little bit heigher then whats + # measured below. This property can be used to correct that value. + room_temperature_offset: -1.4 + # Only supported on NASA devices room_humidity: name: "Kitchen humidity"