This commit is contained in:
Otto Winter 2019-05-24 16:34:01 +02:00
parent bd45f6bd8e
commit aa7389432e
No known key found for this signature in database
GPG key ID: DB66C0BE6013F97E
3 changed files with 5 additions and 10 deletions

View file

@ -67,7 +67,7 @@ CONFIG_SCHEMA = cv.All(cv.Schema({
cv.Optional(CONF_USE_ADDRESS): cv.string_strict,
cv.Optional('hostname'): cv.invalid("The hostname option has been removed in 1.11.0"),
}), validate)
}).extend(cv.COMPONENT_SCHEMA), validate)
def manual_ip(config):
@ -84,6 +84,7 @@ def manual_ip(config):
@coroutine_with_priority(60.0)
def to_code(config):
var = cg.new_Pvariable(config[CONF_ID])
yield cg.register_component(var, config)
cg.add(var.set_phy_addr(config[CONF_PHY_ADDR]))
cg.add(var.set_mdc_pin(config[CONF_MDC_PIN]))

View file

@ -18,19 +18,16 @@ void StatusBinarySensor::loop() {
bool status = network_is_connected();
#ifdef USE_MQTT
if (mqtt::global_mqtt_client != nullptr) {
status = mqtt::global_mqtt_client->is_connected();
status = status && mqtt::global_mqtt_client->is_connected();
}
#endif
#ifdef USE_API
if (api::global_api_server != nullptr) {
status = api::global_api_server->is_connected();
status = status && api::global_api_server->is_connected();
}
#endif
if (this->last_status_ != status) {
this->publish_state(status);
this->last_status_ = status;
}
}
void StatusBinarySensor::setup() { this->publish_state(false); }
void StatusBinarySensor::dump_config() { LOG_BINARY_SENSOR("", "Status Binary Sensor", this); }

View file

@ -16,9 +16,6 @@ class StatusBinarySensor : public binary_sensor::BinarySensor, public Component
float get_setup_priority() const override { return setup_priority::DATA; }
bool is_status_binary_sensor() const override { return true; }
protected:
bool last_status_{false};
};
} // namespace status