mirror of
https://github.com/esphome/esphome.git
synced 2024-11-23 15:38:11 +01:00
commit
7fa4a68a27
5 changed files with 18 additions and 9 deletions
|
@ -44,10 +44,11 @@ from esphome.const import (
|
||||||
DEVICE_CLASS_POWER,
|
DEVICE_CLASS_POWER,
|
||||||
DEVICE_CLASS_PRESENCE,
|
DEVICE_CLASS_PRESENCE,
|
||||||
DEVICE_CLASS_PROBLEM,
|
DEVICE_CLASS_PROBLEM,
|
||||||
|
DEVICE_CLASS_RUNNING,
|
||||||
DEVICE_CLASS_SAFETY,
|
DEVICE_CLASS_SAFETY,
|
||||||
DEVICE_CLASS_SMOKE,
|
DEVICE_CLASS_SMOKE,
|
||||||
DEVICE_CLASS_SOUND,
|
DEVICE_CLASS_SOUND,
|
||||||
DEVICE_CLASS_UPDATE,
|
DEVICE_CLASS_TAMPER,
|
||||||
DEVICE_CLASS_VIBRATION,
|
DEVICE_CLASS_VIBRATION,
|
||||||
DEVICE_CLASS_WINDOW,
|
DEVICE_CLASS_WINDOW,
|
||||||
)
|
)
|
||||||
|
@ -76,10 +77,11 @@ DEVICE_CLASSES = [
|
||||||
DEVICE_CLASS_POWER,
|
DEVICE_CLASS_POWER,
|
||||||
DEVICE_CLASS_PRESENCE,
|
DEVICE_CLASS_PRESENCE,
|
||||||
DEVICE_CLASS_PROBLEM,
|
DEVICE_CLASS_PROBLEM,
|
||||||
|
DEVICE_CLASS_RUNNING,
|
||||||
DEVICE_CLASS_SAFETY,
|
DEVICE_CLASS_SAFETY,
|
||||||
DEVICE_CLASS_SMOKE,
|
DEVICE_CLASS_SMOKE,
|
||||||
DEVICE_CLASS_SOUND,
|
DEVICE_CLASS_SOUND,
|
||||||
DEVICE_CLASS_UPDATE,
|
DEVICE_CLASS_TAMPER,
|
||||||
DEVICE_CLASS_VIBRATION,
|
DEVICE_CLASS_VIBRATION,
|
||||||
DEVICE_CLASS_WINDOW,
|
DEVICE_CLASS_WINDOW,
|
||||||
]
|
]
|
||||||
|
|
|
@ -11,6 +11,7 @@ namespace esphome {
|
||||||
namespace esp32_improv {
|
namespace esp32_improv {
|
||||||
|
|
||||||
static const char *const TAG = "esp32_improv.component";
|
static const char *const TAG = "esp32_improv.component";
|
||||||
|
static const char *const ESPHOME_MY_LINK = "https://my.home-assistant.io/redirect/config_flow_start?domain=esphome";
|
||||||
|
|
||||||
ESP32ImprovComponent::ESP32ImprovComponent() { global_improv_component = this; }
|
ESP32ImprovComponent::ESP32ImprovComponent() { global_improv_component = this; }
|
||||||
|
|
||||||
|
@ -124,8 +125,13 @@ void ESP32ImprovComponent::loop() {
|
||||||
this->cancel_timeout("wifi-connect-timeout");
|
this->cancel_timeout("wifi-connect-timeout");
|
||||||
this->set_state_(improv::STATE_PROVISIONED);
|
this->set_state_(improv::STATE_PROVISIONED);
|
||||||
|
|
||||||
std::string url = "https://my.home-assistant.io/redirect/config_flow_start?domain=esphome";
|
std::vector<std::string> urls = {ESPHOME_MY_LINK};
|
||||||
std::vector<uint8_t> data = improv::build_rpc_response(improv::WIFI_SETTINGS, {url});
|
#ifdef USE_WEBSERVER
|
||||||
|
auto ip = wifi::global_wifi_component->wifi_sta_ip();
|
||||||
|
std::string webserver_url = "http://" + ip.str() + ":" + to_string(WEBSERVER_PORT);
|
||||||
|
urls.push_back(webserver_url);
|
||||||
|
#endif
|
||||||
|
std::vector<uint8_t> data = improv::build_rpc_response(improv::WIFI_SETTINGS, urls);
|
||||||
this->send_response_(data);
|
this->send_response_(data);
|
||||||
this->set_timeout("end-service", 1000, [this] {
|
this->set_timeout("end-service", 1000, [this] {
|
||||||
this->service_->stop();
|
this->service_->stop();
|
||||||
|
|
|
@ -92,8 +92,7 @@ void ImprovSerialComponent::loop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<uint8_t> ImprovSerialComponent::build_rpc_settings_response_(improv::Command command) {
|
std::vector<uint8_t> ImprovSerialComponent::build_rpc_settings_response_(improv::Command command) {
|
||||||
std::string url = "https://my.home-assistant.io/redirect/config_flow_start?domain=esphome";
|
std::vector<std::string> urls;
|
||||||
std::vector<std::string> urls = {url};
|
|
||||||
#ifdef USE_WEBSERVER
|
#ifdef USE_WEBSERVER
|
||||||
auto ip = wifi::global_wifi_component->wifi_sta_ip();
|
auto ip = wifi::global_wifi_component->wifi_sta_ip();
|
||||||
std::string webserver_url = "http://" + ip.str() + ":" + to_string(WEBSERVER_PORT);
|
std::string webserver_url = "http://" + ip.str() + ":" + to_string(WEBSERVER_PORT);
|
||||||
|
|
|
@ -15,7 +15,8 @@ CONFIG_SCHEMA = cv.Schema(
|
||||||
cv.GenerateID(CONF_WEB_SERVER_BASE_ID): cv.use_id(
|
cv.GenerateID(CONF_WEB_SERVER_BASE_ID): cv.use_id(
|
||||||
web_server_base.WebServerBase
|
web_server_base.WebServerBase
|
||||||
),
|
),
|
||||||
}
|
},
|
||||||
|
cv.only_with_arduino,
|
||||||
).extend(cv.COMPONENT_SCHEMA)
|
).extend(cv.COMPONENT_SCHEMA)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""Constants used by esphome."""
|
"""Constants used by esphome."""
|
||||||
|
|
||||||
__version__ = "2021.11.0b2"
|
__version__ = "2021.11.0b3"
|
||||||
|
|
||||||
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
||||||
|
|
||||||
|
@ -878,10 +878,11 @@ DEVICE_CLASS_OPENING = "opening"
|
||||||
DEVICE_CLASS_PLUG = "plug"
|
DEVICE_CLASS_PLUG = "plug"
|
||||||
DEVICE_CLASS_PRESENCE = "presence"
|
DEVICE_CLASS_PRESENCE = "presence"
|
||||||
DEVICE_CLASS_PROBLEM = "problem"
|
DEVICE_CLASS_PROBLEM = "problem"
|
||||||
|
DEVICE_CLASS_RUNNING = "running"
|
||||||
DEVICE_CLASS_SAFETY = "safety"
|
DEVICE_CLASS_SAFETY = "safety"
|
||||||
DEVICE_CLASS_SMOKE = "smoke"
|
DEVICE_CLASS_SMOKE = "smoke"
|
||||||
DEVICE_CLASS_SOUND = "sound"
|
DEVICE_CLASS_SOUND = "sound"
|
||||||
DEVICE_CLASS_UPDATE = "update"
|
DEVICE_CLASS_TAMPER = "tamper"
|
||||||
DEVICE_CLASS_VIBRATION = "vibration"
|
DEVICE_CLASS_VIBRATION = "vibration"
|
||||||
DEVICE_CLASS_WINDOW = "window"
|
DEVICE_CLASS_WINDOW = "window"
|
||||||
# device classes of both binary_sensor and sensor component
|
# device classes of both binary_sensor and sensor component
|
||||||
|
|
Loading…
Reference in a new issue