-
Notifications
You must be signed in to change notification settings - Fork 44
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
Fixes millis errors #116
base: master
Are you sure you want to change the base?
Fixes millis errors #116
Conversation
Why is the diff so big, did indentation change as well? Is there a way to minimise the diff? |
The class needs to be wrapped in a esphome namespace, else it won't work. So most of the indentation changed hence the number of changed lines. |
It's somewhat uncommon in C++ to introduce extra indentation when adding a namespace. Makes diff harder to read, too. |
Sorry, I'm no c++ Dev 🤫🥺 |
I mean, take a look at what e.g. esphome source code itself looks like in such cases: https://github.com/esphome/esphome/blob/dev/esphome/components/climate_ir/climate_ir.cpp ;) |
changed indentaiton
Updated. |
@@ -39,7 +39,9 @@ static const std::vector<std::string> protection_states = { | |||
|
|||
static const char* TAG = "mhi_ac_ctrl"; | |||
|
|||
unsigned long room_temp_api_timeout_ms = millis(); | |||
unsigned long room_temp_api_timeout_ms = esphome::millis(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose you could move this line within the esphome namespace block, so it's defined within the proper scope. Also, no need for the esphome::
prefix on millis()
here if you do that.
@@ -150,9 +152,9 @@ class MhiAcCtrl : public climate::Climate, | |||
} | |||
void loop() override | |||
{ | |||
if(millis() - room_temp_api_timeout_ms >= room_temp_api_timeout*1000) { | |||
if(esphome::millis() - room_temp_api_timeout_ms >= room_temp_api_timeout*1000) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should not have to prefix every call to millis()
with the esphome::
prefix while already within the esphome namespace.
That post seems to come from 2021, and I'm seeing 0 compilation or runtime errors. Are we sure this is still relevant? Or are our compile options hiding warnings? (I'm using the docker container, so who knows :p) |
I had problems compiling the project locally with esphome run example.yaml
This PR fixes the problem.
resource: https://community.home-assistant.io/t/esphome-version-2021-10-0-breaks-my-project/348906