Skip to content

Commit f67f0bc

Browse files
committed
Fix: make tests compile
1 parent ed3e90b commit f67f0bc

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

components/samsung_ac/protocol_nasa.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -499,9 +499,9 @@ namespace esphome
499499
}
500500
}
501501

502-
if (custom.has_value() && custom.value().find((uint16_t) message.messageNumber) != custom.value().end())
502+
if (custom && custom.value().find((uint16_t)message.messageNumber) != custom.value().end())
503503
{
504-
target->set_custom_sensor(source, (uint16_t) message.messageNumber, (float) message.value);
504+
target->set_custom_sensor(source, (uint16_t)message.messageNumber, (float)message.value);
505505
}
506506

507507
switch (message.messageNumber)
@@ -586,7 +586,7 @@ namespace esphome
586586
}
587587
case MessageNumber::VAR_out_sensor_airout:
588588
{
589-
double temp = (double) ((int16_t)message.value) / (double)10;
589+
double temp = (double)((int16_t)message.value) / (double)10;
590590
ESP_LOGW(TAG, "s:%s d:%s VAR_out_sensor_airout %li", source.c_str(), dest.c_str(), message.value);
591591
target->set_outdoor_temperature(source, temp);
592592
return;

test/test_stuff.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <bitset>
44
#include <cassert>
55
#include <optional>
6-
#include <experimental/optional>
6+
#include "esphome/core/optional.h"
77

88
#include "../components/samsung_ac/util.h"
99
#include "../components/samsung_ac/protocol.h"
@@ -105,16 +105,31 @@ class DebugTarget : public MessageTarget
105105
last_set_fanmode_mode = fanmode;
106106
}
107107

108-
void set_altmode(const std::string address, AltMode fanmode)
108+
void set_altmode(const std::string address, AltMode altmode)
109109
{
110+
cout << "> " << address << " set_altmode=" << to_string((int)altmode) << endl;
110111
}
111112

112113
void set_swing_vertical(const std::string address, bool vertical)
113114
{
115+
cout << "> " << address << " set_swing_vertical=" << to_string((int)vertical) << endl;
114116
}
115117

116118
void set_swing_horizontal(const std::string address, bool horizontal)
117119
{
120+
cout << "> " << address << " set_swing_horizontal=" << to_string((int)horizontal) << endl;
121+
}
122+
123+
std::set<uint16_t> last_custom_sensors;
124+
125+
esphome::optional<std::set<uint16_t>> get_custom_sensors(const std::string address)
126+
{
127+
return last_custom_sensors;
128+
}
129+
130+
void set_custom_sensor(const std::string address, uint16_t message_number, float value)
131+
{
132+
last_custom_sensors.insert(message_number);
118133
}
119134

120135
void assert_only_address(const std::string address)

0 commit comments

Comments
 (0)