Skip to content

Commit

Permalink
Merge pull request #160 from omerfaruk-aran/new_test
Browse files Browse the repository at this point in the history
Add Automatic Cleaning Mode and Logging Features to Samsung AC Integration
  • Loading branch information
lanwin authored Aug 22, 2024
2 parents f8e00b5 + 2dc2554 commit 0e3463e
Show file tree
Hide file tree
Showing 10 changed files with 393 additions and 280 deletions.
38 changes: 38 additions & 0 deletions components/samsung_ac/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,12 @@
CONF_DEVICE_TARGET_TEMPERATURE = "target_temperature"
CONF_DEVICE_WATER_OUTLET_TARGET = "water_outlet_target"
CONF_DEVICE_OUTDOOR_TEMPERATURE = "outdoor_temperature"
CONF_DEVICE_INDOOR_EVA_IN_TEMPERATURE = "indoor_eva_in_temperature"
CONF_DEVICE_INDOOR_EVA_OUT_TEMPERATURE = "indoor_eva_out_temperature"
CONF_DEVICE_WATER_TEMPERATURE = "water_temperature"
CONF_DEVICE_WATER_TARGET_TEMPERATURE = "water_target_temperature"
CONF_DEVICE_POWER = "power"
CONF_DEVICE_AUTOMATIC_CLEANING = "automatic_cleaning"
CONF_DEVICE_WATER_HEATER_POWER = "water_heater_power"
CONF_DEVICE_MODE = "mode"
CONF_DEVICE_WATER_HEATER_MODE = "water_heater_mode"
Expand Down Expand Up @@ -182,11 +185,24 @@ def humidity_sensor_schema(message: int):
accuracy_decimals=1,
device_class=DEVICE_CLASS_TEMPERATURE,
state_class=STATE_CLASS_MEASUREMENT,
),
cv.Optional(CONF_DEVICE_INDOOR_EVA_IN_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_INDOOR_EVA_OUT_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_WATER_OUTLET_TARGET): NUMBER_SCHEMA,
cv.Optional(CONF_DEVICE_WATER_TARGET_TEMPERATURE): NUMBER_SCHEMA,
cv.Optional(CONF_DEVICE_POWER): switch.switch_schema(Samsung_AC_Switch),
cv.Optional(CONF_DEVICE_AUTOMATIC_CLEANING): switch.switch_schema(Samsung_AC_Switch),
cv.Optional(CONF_DEVICE_WATER_HEATER_POWER): switch.switch_schema(Samsung_AC_Switch),
cv.Optional(CONF_DEVICE_MODE): SELECT_MODE_SCHEMA,
cv.Optional(CONF_DEVICE_WATER_HEATER_MODE): SELECT_WATER_HEATER_MODE_SCHEMA,
Expand Down Expand Up @@ -217,6 +233,9 @@ def humidity_sensor_schema(message: int):

CONF_NON_NASA_KEEPALIVE = "non_nasa_keepalive"

CONF_DEBUG_LOG_UNDEFINED_MESSAGES = "debug_log_undefined_messages"


CONFIG_SCHEMA = (
cv.Schema(
{
Expand All @@ -229,6 +248,7 @@ def humidity_sensor_schema(message: int):
cv.Optional(CONF_DEBUG_LOG_MESSAGES, default=False): cv.boolean,
cv.Optional(CONF_DEBUG_LOG_MESSAGES_RAW, default=False): cv.boolean,
cv.Optional(CONF_NON_NASA_KEEPALIVE, default=False): cv.boolean,
cv.Optional(CONF_DEBUG_LOG_UNDEFINED_MESSAGES, default=False): cv.boolean,
cv.Optional(CONF_CAPABILITIES): CAPABILITIES_SCHEMA,
cv.Required(CONF_DEVICES): cv.ensure_list(DEVICE_SCHEMA),
}
Expand Down Expand Up @@ -300,6 +320,11 @@ async def to_code(config):
sens = await switch.new_switch(conf)
cg.add(var_dev.set_power_switch(sens))

if CONF_DEVICE_AUTOMATIC_CLEANING in device:
conf = device[CONF_DEVICE_AUTOMATIC_CLEANING]
sens = await switch.new_switch(conf)
cg.add(var_dev.set_automatic_cleaning_switch(sens))

if CONF_DEVICE_WATER_HEATER_POWER in device:
conf = device[CONF_DEVICE_WATER_HEATER_POWER]
sens = await switch.new_switch(conf)
Expand All @@ -318,6 +343,16 @@ async def to_code(config):
conf = device[CONF_DEVICE_OUTDOOR_TEMPERATURE]
sens = await sensor.new_sensor(conf)
cg.add(var_dev.set_outdoor_temperature_sensor(sens))

if CONF_DEVICE_INDOOR_EVA_IN_TEMPERATURE in device:
conf = device[CONF_DEVICE_INDOOR_EVA_IN_TEMPERATURE]
sens = await sensor.new_sensor(conf)
cg.add(var_dev.set_indoor_eva_in_temperature_sensor(sens))

if CONF_DEVICE_INDOOR_EVA_OUT_TEMPERATURE in device:
conf = device[CONF_DEVICE_INDOOR_EVA_OUT_TEMPERATURE]
sens = await sensor.new_sensor(conf)
cg.add(var_dev.set_indoor_eva_out_temperature_sensor(sens))

if CONF_DEVICE_WATER_TARGET_TEMPERATURE in device:
conf = device[CONF_DEVICE_WATER_TARGET_TEMPERATURE]
Expand Down Expand Up @@ -398,6 +433,9 @@ async def to_code(config):

if (CONF_NON_NASA_KEEPALIVE in config):
cg.add(var.set_non_nasa_keepalive(config[CONF_NON_NASA_KEEPALIVE]))

if (CONF_DEBUG_LOG_UNDEFINED_MESSAGES in config):
cg.add(var.set_debug_log_undefined_messages(config[CONF_DEBUG_LOG_UNDEFINED_MESSAGES]))

await cg.register_component(var, config)
await uart.register_uart_device(var, config)
4 changes: 3 additions & 1 deletion components/samsung_ac/protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ namespace esphome
{
namespace samsung_ac
{
bool debug_log_packets = false;
bool debug_log_raw_bytes = false;
bool non_nasa_keepalive = false;
bool debug_log_undefined_messages = false;
bool debug_log_messages = false;

ProtocolProcessing protocol_processing = ProtocolProcessing::Auto;

// This functions is designed to run after a new value was added
Expand Down
7 changes: 6 additions & 1 deletion components/samsung_ac/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ namespace esphome
{
namespace samsung_ac
{
extern bool debug_log_packets;
extern bool debug_log_raw_bytes;
extern bool non_nasa_keepalive;
extern bool debug_log_undefined_messages;
extern bool debug_log_messages;

enum class DecodeResult
{
Expand Down Expand Up @@ -76,11 +77,14 @@ namespace esphome
virtual void publish_data(std::vector<uint8_t> &data) = 0;
virtual void register_address(const std::string address) = 0;
virtual void set_power(const std::string address, bool value) = 0;
virtual void set_automatic_cleaning(const std::string address, bool value) = 0;
virtual void set_water_heater_power(const std::string address, bool value) = 0;
virtual void set_room_temperature(const std::string address, float value) = 0;
virtual void set_target_temperature(const std::string address, float value) = 0;
virtual void set_water_outlet_target(const std::string address, float value) = 0;
virtual void set_outdoor_temperature(const std::string address, float value) = 0;
virtual void set_indoor_eva_in_temperature(const std::string address, float value) = 0;
virtual void set_indoor_eva_out_temperature(const std::string address, float value) = 0;
virtual void set_target_water_temperature(const std::string address, float value) = 0;
virtual void set_mode(const std::string address, Mode mode) = 0;
virtual void set_water_heater_mode(const std::string address, WaterHeaterMode waterheatermode) = 0;
Expand All @@ -96,6 +100,7 @@ namespace esphome
{
public:
optional<bool> power;
optional<bool> automatic_cleaning;
optional<bool> water_heater_power;
optional<Mode> mode;
optional<WaterHeaterMode> waterheatermode;
Expand Down
Loading

0 comments on commit 0e3463e

Please sign in to comment.