-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from echavet/echavet/issue70
UART unavailable on D1 Mini (ESP8226) after ~12hrs
- Loading branch information
Showing
12 changed files
with
219 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include "esphome/core/log.h" | ||
#include "esphome/core/helpers.h" | ||
#include "esphome/core/hal.h" | ||
#include "uptime_connection_sensor.h" | ||
|
||
namespace esphome { | ||
namespace uptime { | ||
|
||
static const char* const TAG = "uptime.connection.sensor"; | ||
void HpUpTimeConnectionSensor::update() { | ||
if (connected_) { | ||
UptimeSensor::update(); | ||
} else { | ||
this->uptime_ = 0; | ||
this->publish_state(0); | ||
} | ||
} | ||
|
||
void HpUpTimeConnectionSensor::start() { | ||
this->uptime_ = 0; | ||
this->connected_ = true; | ||
this->update(); | ||
} | ||
|
||
void HpUpTimeConnectionSensor::stop() { | ||
this->connected_ = false; | ||
this->update(); | ||
} | ||
|
||
std::string HpUpTimeConnectionSensor::unique_id() { return get_mac_address() + "-uptime-hp_connection"; } | ||
void HpUpTimeConnectionSensor::dump_config() { LOG_SENSOR("", "Uptime Connection Sensor", this); } | ||
|
||
} // namespace uptime | ||
} // namespace esphome |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#pragma once | ||
#include "esphome/components/uptime/uptime_sensor.h" | ||
|
||
namespace esphome { | ||
namespace uptime { | ||
|
||
class HpUpTimeConnectionSensor : public UptimeSensor { | ||
public: | ||
void update() override; | ||
std::string unique_id() override; | ||
void dump_config() override; | ||
|
||
void start(); // connection established | ||
void stop(); // connection lost | ||
protected: | ||
bool connected_{ false }; | ||
}; | ||
} // namespace uptime | ||
} // namespace esphome |
Oops, something went wrong.