Trying a simple set up

This commit is contained in:
Jordan Zucker 2024-10-28 10:08:41 -07:00
parent 1e2497748d
commit 7736d36f6c
4 changed files with 57 additions and 0 deletions

View file

@ -0,0 +1,20 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.const import CONF_ID, CONF_LOKI_HOST
DEPENDENCIES = ["network"]
loki_component_ns = cg.esphome_ns.namespace("loki")
LokiComponent = loki_component_ns.class_("LokiComponent", cg.Component)
CONFIG_SCHEMA = cv.Schema(
{
cv.GenerateID(): cv.declare_id(LokiComponent),
cv.Optional(CONF_LOKI_HOST): cv.url,
}
).extend(cv.COMPONENT_SCHEMA)
async def to_code(config):
var = cg.new_Pvariable(config[CONF_ID])
await cg.register_component(var, config)

View file

@ -0,0 +1,17 @@
#include "loki.h"
#ifdef USE_NETWORK
#include "esphome/core/log.h"
namespace esphome {
namespace loki {
static const char *TAG = "loki.component";
void LokiComponent::setup() {}
void LokiComponent::loop() {}
void LokiComponent::dump_config() { ESP_LOGCONFIG(TAG, "Loki component"); }
} // namespace loki
} // namespace esphome

View file

@ -0,0 +1,19 @@
#pragma once
#include "esphome/core/defines.h"
#ifdef USE_NETWORK
#include "esphome/core/component.h"
namespace esphome {
namespace loki {
class LokiComponent : public Component {
public:
void setup() override;
void loop() override;
void dump_config() override;
};
} // namespace loki
} // namespace esphome
#endif

View file

@ -453,6 +453,7 @@ CONF_LOG = "log"
CONF_LOG_TOPIC = "log_topic"
CONF_LOGGER = "logger"
CONF_LOGS = "logs"
CONF_LOKI_HOST = "loki_host"
CONF_LONGITUDE = "longitude"
CONF_LOOP_TIME = "loop_time"
CONF_LOW = "low"