mirror of
https://github.com/tjhorner/upsy-desky.git
synced 2026-01-09 23:47:53 -05:00
Switch to using second repository for project_version component
This commit is contained in:
1
components/.gitignore
vendored
1
components/.gitignore
vendored
@@ -1 +0,0 @@
|
|||||||
**/__pycache__
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
#include "project_version_text_sensor.h"
|
|
||||||
#include "esphome/core/log.h"
|
|
||||||
#include "esphome/core/application.h"
|
|
||||||
#include "esphome/core/version.h"
|
|
||||||
|
|
||||||
namespace esphome {
|
|
||||||
namespace project_version {
|
|
||||||
|
|
||||||
static const char *const TAG = "project_version.text_sensor";
|
|
||||||
|
|
||||||
void ProjectVersionTextSensor::setup() {
|
|
||||||
this->publish_state(ESPHOME_PROJECT_VERSION);
|
|
||||||
}
|
|
||||||
float ProjectVersionTextSensor::get_setup_priority() const { return setup_priority::DATA; }
|
|
||||||
std::string ProjectVersionTextSensor::unique_id() { return get_mac_address() + "-project-version"; }
|
|
||||||
void ProjectVersionTextSensor::dump_config() { LOG_TEXT_SENSOR("", "Project Version Text Sensor", this); }
|
|
||||||
|
|
||||||
} // namespace version
|
|
||||||
} // namespace esphome
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "esphome/core/component.h"
|
|
||||||
#include "esphome/components/text_sensor/text_sensor.h"
|
|
||||||
|
|
||||||
namespace esphome {
|
|
||||||
namespace project_version {
|
|
||||||
|
|
||||||
class ProjectVersionTextSensor : public text_sensor::TextSensor, public Component {
|
|
||||||
public:
|
|
||||||
void setup() override;
|
|
||||||
void dump_config() override;
|
|
||||||
float get_setup_priority() const override;
|
|
||||||
std::string unique_id() override;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace version
|
|
||||||
} // namespace esphome
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
import esphome.codegen as cg
|
|
||||||
import esphome.config_validation as cv
|
|
||||||
from esphome.components import text_sensor
|
|
||||||
from esphome.const import (
|
|
||||||
ENTITY_CATEGORY_DIAGNOSTIC,
|
|
||||||
ICON_NEW_BOX,
|
|
||||||
)
|
|
||||||
|
|
||||||
project_version = cg.esphome_ns.namespace("project_version")
|
|
||||||
ProjectVersionTextSensor = project_version.class_(
|
|
||||||
"ProjectVersionTextSensor", text_sensor.TextSensor, cg.Component
|
|
||||||
)
|
|
||||||
|
|
||||||
CONFIG_SCHEMA = (
|
|
||||||
text_sensor.text_sensor_schema(
|
|
||||||
icon=ICON_NEW_BOX,
|
|
||||||
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
|
|
||||||
)
|
|
||||||
.extend(
|
|
||||||
{
|
|
||||||
cv.GenerateID(): cv.declare_id(ProjectVersionTextSensor),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.extend(cv.COMPONENT_SCHEMA)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
async def to_code(config):
|
|
||||||
var = await text_sensor.new_text_sensor(config)
|
|
||||||
await cg.register_component(var, config)
|
|
||||||
|
|
||||||
@@ -2,7 +2,7 @@ packages:
|
|||||||
base: !include base.yaml
|
base: !include base.yaml
|
||||||
|
|
||||||
external_components:
|
external_components:
|
||||||
- source: github://tjhorner/upsy-desky@v1.1.1
|
- source: github://tjhorner/esphome-custom-components
|
||||||
components: [ project_version ]
|
components: [ project_version ]
|
||||||
|
|
||||||
text_sensor:
|
text_sensor:
|
||||||
|
|||||||
Reference in New Issue
Block a user