Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

βœ… Outdoor Temperature and Energy Consumption - Home Assistant Sensor #215

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ src/
platformio.ini
sdkconfig.m5stack-atom
CMakeLists.txt
.gitignore
esp.yaml
esp-nasa.yaml
secrets.yaml
509 changes: 501 additions & 8 deletions .vscode/c_cpp_properties.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@
"iomanip": "cpp",
"ranges": "cpp",
"span": "cpp",
"stop_token": "cpp"
"stop_token": "cpp",
"unordered_set": "cpp",
"queue": "cpp"
},
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
Expand Down
4 changes: 4 additions & 0 deletions components/samsung_ac/protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ namespace esphome
{
// is logged within decoder
}
else if (result == DecodeResult::UnknownCommand)
{
// is logged within decoder
}
return DataResult::Clear;
}

Expand Down
3 changes: 2 additions & 1 deletion components/samsung_ac/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ namespace esphome
InvalidEndByte = 2,
SizeDidNotMatch = 3,
UnexpectedSize = 4,
CrcError = 5
CrcError = 5,
UnknownCommand = 6
};

enum class Mode
Expand Down
219 changes: 141 additions & 78 deletions components/samsung_ac/protocol_non_nasa.cpp

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion components/samsung_ac/protocol_non_nasa.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <optional>
#include "protocol.h"
#include "util.h"
#include "esphome/components/sensor/sensor.h"

namespace esphome
{
Expand Down Expand Up @@ -187,7 +188,7 @@ namespace esphome
std::vector<uint8_t> encode();
std::string to_string();

static NonNasaRequest create(std::string dst_address);
static NonNasaRequest create(const std::string &dst_address);
};

struct NonNasaRequestQueueItem
Expand All @@ -213,6 +214,9 @@ namespace esphome

void publish_request(MessageTarget *target, const std::string &address, ProtocolRequest &request) override;
void protocol_update(MessageTarget *target) override;

private:
uint32_t start_millis;
};
} // namespace samsung_ac
} // namespace esphome
6 changes: 3 additions & 3 deletions components/samsung_ac/samsung_ac_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ namespace esphome
fan.insert(climate::ClimateFanMode::CLIMATE_FAN_AUTO);
}

if (is_nasa_address(device->address))
{
//if (is_nasa_address(device->address))
//{
// fan.insert(climate::ClimateFanMode::CLIMATE_FAN_DIFFUSE);
}
//}

traits.set_supported_fan_modes(fan);

Expand Down
17 changes: 10 additions & 7 deletions example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,29 +126,34 @@ samsung_ac:
name: "Kitchen humidity"

- address: "10.00.00" # Outdoor device address as the following components are dependent on an outdoor unit.

# This sensor captures and monitors specific error codes returned by the HVAC system.
# When an error occurs, the sensor detects the error code and updates its value accordingly.
# Additionally, by using the blueprint available at https://github.com/omerfaruk-aran/esphome_samsung_ac_blueprint,
# you can automatically send detailed error messages to your mobile devices based on the captured error codes.
error_code:
name: error_code

# This sensor measures the instantaneous power consumption of the outdoor unit in Watts.

#[NASA or NonNASA]
outdoor_temperature: # Should be used with outdoor device address
name: "Outdoor temperature"

# [NASA or NonNASA] This sensor measures the instantaneous power consumption of the outdoor unit in Watts.
# The captured value represents the current power draw of the outdoor HVAC components, helping track energy usage patterns.
outdoor_instantaneous_power:
name: "Outdoor Instantaneous Power"

# This sensor records the cumulative energy consumption of the outdoor unit in kWh.
# [NASA or NonNASA] This sensor records the cumulative energy consumption of the outdoor unit in kWh.
# It calculates the total energy consumed over time, allowing users to monitor and analyze energy efficiency.
outdoor_cumulative_energy:
name: "Outdoor Cumulative Energy"

# This sensor measures the current drawn by the outdoor unit in Amperes.
# [NASA or NonNASA] This sensor measures the current drawn by the outdoor unit in Amperes.
# Monitoring current values helps identify electrical irregularities and ensure safe power levels in the system.
outdoor_current:
name: "Outdoor Current"

# This sensor tracks the voltage supplied to the outdoor unit in Volts.
# [NASA or NonNASA] This sensor tracks the voltage supplied to the outdoor unit in Volts.
# Consistent voltage readings indicate stable power delivery, while deviations can help detect electrical issues in the system.
outdoor_voltage:
name: "Outdoor Voltage"
Expand All @@ -160,5 +165,3 @@ samsung_ac:
name: "Hot Water Target Temperature"
water_heater_mode:
name: "Hotwater Mode"
outdoor_temperature: # Should be used with outdoor device address
name: "Outdoor temperature"
Loading