mirror of
https://github.com/syssi/esphome-votronic.git
synced 2025-07-23 12:33:01 +02:00
Some checks failed
CI / yamllint (push) Has been cancelled
CI / Bundle external component and ESPHome (push) Has been cancelled
CI / Create common environment (push) Has been cancelled
CI / Check ruff (push) Has been cancelled
CI / Check flake8 (push) Has been cancelled
CI / Check pylint (push) Has been cancelled
CI / Check pyupgrade (push) Has been cancelled
CI / Run script/ci-custom (push) Has been cancelled
CI / Check clang-format (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 1/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 2/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 3/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 4/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 IDF (push) Has been cancelled
CI / Run script/clang-tidy for ESP8266 (push) Has been cancelled
CI / Validate example configurations (push) Has been cancelled
CI / Build example configurations (push) Has been cancelled
45 lines
1.3 KiB
Python
45 lines
1.3 KiB
Python
import esphome.codegen as cg
|
|
from esphome.components import text_sensor
|
|
import esphome.config_validation as cv
|
|
from esphome.const import CONF_ID
|
|
|
|
from . import CONF_VOTRONIC_BLE_ID, VOTRONIC_BLE_SCHEMA
|
|
|
|
DEPENDENCIES = ["votronic_ble"]
|
|
|
|
CODEOWNERS = ["@syssi"]
|
|
|
|
CONF_BATTERY_STATUS = "battery_status"
|
|
CONF_PV_CONTROLLER_STATUS = "pv_controller_status"
|
|
|
|
ICON_BATTERY_STATUS = "mdi:alert-circle-outline"
|
|
ICON_PV_CONTROLLER_STATUS = "mdi:heart-pulse"
|
|
|
|
TEXT_SENSORS = [
|
|
CONF_BATTERY_STATUS,
|
|
CONF_PV_CONTROLLER_STATUS,
|
|
]
|
|
|
|
CONFIG_SCHEMA = VOTRONIC_BLE_SCHEMA.extend(
|
|
{
|
|
cv.Optional(CONF_BATTERY_STATUS): text_sensor.text_sensor_schema(
|
|
class_=text_sensor.TextSensor,
|
|
icon=ICON_BATTERY_STATUS,
|
|
),
|
|
cv.Optional(CONF_PV_CONTROLLER_STATUS): text_sensor.text_sensor_schema(
|
|
class_=text_sensor.TextSensor,
|
|
icon=ICON_PV_CONTROLLER_STATUS,
|
|
),
|
|
}
|
|
)
|
|
|
|
|
|
async def to_code(config):
|
|
hub = await cg.get_variable(config[CONF_VOTRONIC_BLE_ID])
|
|
for key in TEXT_SENSORS:
|
|
if key in config:
|
|
conf = config[key]
|
|
sens = cg.new_Pvariable(conf[CONF_ID])
|
|
await text_sensor.register_text_sensor(sens, conf)
|
|
cg.add(getattr(hub, f"set_{key}_text_sensor")(sens))
|