Skip to content

Commit

Permalink
Text sensor update
Browse files Browse the repository at this point in the history
  • Loading branch information
netmindz committed Oct 22, 2023
1 parent d4eba89 commit 77feba1
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 40 deletions.
23 changes: 23 additions & 0 deletions components/BalboaGL/sensor/BalboaGLSesnor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#pragma once

#include "esphom.h"

#include "balboaGL.h"

namespace esphome {
namespace balboa_sensor {

class BalboaGLStateSensor : public Component, public TextSensor {
public:
void setSpa(balboaGL* spa) {
this->spa = spa;
}
void update() override {
publish_state(status.state.c_ctr());
}
private:
balboaGL* spa;

};

}
48 changes: 48 additions & 0 deletions components/BalboaGL/sensor/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.components import text_sensor
from esphome.const import CONF_ID
from esphome.core import coroutine

from .. import balboagl_ns, CONF_BALBOA_ID, BalboaGL

AUTO_LOAD = ["text_sensor"]

DEPENDENCIES = ["BalboaGL"]

CONF_STATE = "state"
CONF_RAW = "raw"
CONF_LCD = "lcd"


balboa_sensor_ns = cg.esphome_ns.namespace('balboa_sensor')
StateInfo = balboa_sensor_ns.class_('BalboaGLStateSensor', text_sensor.TextSensor, cg.Component)
# RawInfo = balboa_sensor_ns.class_('BalboaGLRawSensor', text_sensor.TextSensor, cg.Component)
# LCDInfo = balboa_sensor_ns.class_('BalboaGLLCDSensor', text_sensor.TextSensor, cg.Component)

CONFIG_SCHEMA = text_sensor.TEXT_SENSOR_SCHEMA.extend(
{

cv.GenerateID(): cv.declare_id(StateInfo),
cv.GenerateID(CONF_BALBOA_ID): cv.use_id(BalboaGL),

# cv.Optional(CONF_RAW): text_sensor.TEXT_SENSOR_SCHEMA.extend({
# cv.GenerateID(): cv.declare_id(RawInfo),
# }),
# cv.Optional(CONF_LCD): text_sensor.TEXT_SENSOR_SCHEMA.extend({
# cv.GenerateID(): cv.declare_id(LCDInfo),
# }),
})

@coroutine
def setup_conf(config, key):
if key in config:
conf = config[key]
var = cg.new_Pvariable(conf[CONF_ID])
yield cg.register_component(var, conf)
yield text_sensor.register_text_sensor(var, conf)

def to_code(config):
yield setup_conf(config, CONF_STATE)
# yield setup_conf(config, CONF_RAW)
# yield setup_conf(config, CONF_LCD)
40 changes: 0 additions & 40 deletions components/BalboaGL/sensor/text_sensor.py

This file was deleted.

0 comments on commit 77feba1

Please sign in to comment.