Skip to content

Commit

Permalink
Add room_temperature_offset
Browse files Browse the repository at this point in the history
  • Loading branch information
lanwin committed Feb 19, 2024
1 parent c15589c commit 6d35cf1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
7 changes: 6 additions & 1 deletion components/samsung_ac/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 8 additions & 2 deletions components/samsung_ac/samsung_ac_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ namespace esphome
Samsung_AC_Mode_Select *mode{nullptr};
Samsung_AC_Climate *climate{nullptr};
std::vector<Samsung_AC_Sensor> custom_sensors;
float room_temperature_offset{0};

void set_room_temperature_sensor(sensor::Sensor *sensor)
{
Expand Down Expand Up @@ -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();
}
}
Expand Down Expand Up @@ -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};
Expand Down
6 changes: 5 additions & 1 deletion example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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"
Expand Down

0 comments on commit 6d35cf1

Please sign in to comment.