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
118 lines
4.0 KiB
Python
118 lines
4.0 KiB
Python
import esphome.codegen as cg
|
|
from esphome.components import binary_sensor
|
|
import esphome.config_validation as cv
|
|
from esphome.const import CONF_ID
|
|
|
|
from . import CONF_VOTRONIC_ID, VOTRONIC_COMPONENT_SCHEMA
|
|
|
|
DEPENDENCIES = ["votronic"]
|
|
|
|
CODEOWNERS = ["@syssi"]
|
|
|
|
CONF_CHARGING = "charging"
|
|
CONF_DISCHARGING = "discharging"
|
|
|
|
CONF_CHARGER_CHARGING = "charger_charging"
|
|
CONF_CHARGER_DISCHARGING = "charger_discharging"
|
|
CONF_CHARGER_CONTROLLER_ACTIVE = "charger_controller_active"
|
|
CONF_CHARGER_CURRENT_REDUCTION = "charger_current_reduction"
|
|
CONF_CHARGER_AES_ACTIVE = "charger_aes_active"
|
|
|
|
CONF_CHARGING_CONVERTER_CHARGING = "charging_converter_charging"
|
|
CONF_CHARGING_CONVERTER_DISCHARGING = "charging_converter_discharging"
|
|
CONF_CHARGING_CONVERTER_CONTROLLER_ACTIVE = "charging_converter_controller_active"
|
|
CONF_CHARGING_CONVERTER_CURRENT_REDUCTION = "charging_converter_current_reduction"
|
|
CONF_CHARGING_CONVERTER_AES_ACTIVE = "charging_converter_aes_active"
|
|
|
|
CONF_PV_CONTROLLER_ACTIVE = "pv_controller_active"
|
|
CONF_PV_CURRENT_REDUCTION = "pv_current_reduction"
|
|
CONF_PV_AES_ACTIVE = "pv_aes_active"
|
|
|
|
BINARY_SENSORS = [
|
|
CONF_CHARGING,
|
|
CONF_DISCHARGING,
|
|
CONF_CHARGER_CHARGING,
|
|
CONF_CHARGER_DISCHARGING,
|
|
CONF_CHARGER_CONTROLLER_ACTIVE,
|
|
CONF_CHARGER_CURRENT_REDUCTION,
|
|
CONF_CHARGER_AES_ACTIVE,
|
|
CONF_CHARGING_CONVERTER_CHARGING,
|
|
CONF_CHARGING_CONVERTER_DISCHARGING,
|
|
CONF_CHARGING_CONVERTER_CONTROLLER_ACTIVE,
|
|
CONF_CHARGING_CONVERTER_CURRENT_REDUCTION,
|
|
CONF_CHARGING_CONVERTER_AES_ACTIVE,
|
|
CONF_PV_CONTROLLER_ACTIVE,
|
|
CONF_PV_CURRENT_REDUCTION,
|
|
CONF_PV_AES_ACTIVE,
|
|
]
|
|
|
|
CONFIG_SCHEMA = VOTRONIC_COMPONENT_SCHEMA.extend(
|
|
{
|
|
cv.Optional(CONF_CHARGING): binary_sensor.binary_sensor_schema(
|
|
icon="mdi:battery-charging",
|
|
),
|
|
cv.Optional(CONF_DISCHARGING): binary_sensor.binary_sensor_schema(
|
|
icon="mdi:power-plug",
|
|
),
|
|
cv.Optional(CONF_CHARGER_CHARGING): binary_sensor.binary_sensor_schema(
|
|
icon="mdi:battery-charging",
|
|
),
|
|
cv.Optional(CONF_CHARGER_DISCHARGING): binary_sensor.binary_sensor_schema(
|
|
icon="mdi:power-plug",
|
|
),
|
|
cv.Optional(CONF_CHARGER_CONTROLLER_ACTIVE): binary_sensor.binary_sensor_schema(
|
|
icon="mdi:power",
|
|
),
|
|
cv.Optional(CONF_CHARGER_CURRENT_REDUCTION): binary_sensor.binary_sensor_schema(
|
|
icon="mdi:car-speed-limiter",
|
|
),
|
|
cv.Optional(CONF_CHARGER_AES_ACTIVE): binary_sensor.binary_sensor_schema(
|
|
icon="mdi:export",
|
|
),
|
|
cv.Optional(
|
|
CONF_CHARGING_CONVERTER_CHARGING
|
|
): binary_sensor.binary_sensor_schema(
|
|
icon="mdi:battery-charging",
|
|
),
|
|
cv.Optional(
|
|
CONF_CHARGING_CONVERTER_DISCHARGING
|
|
): binary_sensor.binary_sensor_schema(
|
|
icon="mdi:power-plug",
|
|
),
|
|
cv.Optional(
|
|
CONF_CHARGING_CONVERTER_CONTROLLER_ACTIVE
|
|
): binary_sensor.binary_sensor_schema(
|
|
icon="mdi:power",
|
|
),
|
|
cv.Optional(
|
|
CONF_CHARGING_CONVERTER_CURRENT_REDUCTION
|
|
): binary_sensor.binary_sensor_schema(
|
|
icon="mdi:car-speed-limiter",
|
|
),
|
|
cv.Optional(
|
|
CONF_CHARGING_CONVERTER_AES_ACTIVE
|
|
): binary_sensor.binary_sensor_schema(
|
|
icon="mdi:export",
|
|
),
|
|
cv.Optional(CONF_PV_CONTROLLER_ACTIVE): binary_sensor.binary_sensor_schema(
|
|
icon="mdi:power",
|
|
),
|
|
cv.Optional(CONF_PV_CURRENT_REDUCTION): binary_sensor.binary_sensor_schema(
|
|
icon="mdi:car-speed-limiter",
|
|
),
|
|
cv.Optional(CONF_PV_AES_ACTIVE): binary_sensor.binary_sensor_schema(
|
|
icon="mdi:export",
|
|
),
|
|
}
|
|
)
|
|
|
|
|
|
async def to_code(config):
|
|
hub = await cg.get_variable(config[CONF_VOTRONIC_ID])
|
|
for key in BINARY_SENSORS:
|
|
if key in config:
|
|
conf = config[key]
|
|
sens = cg.new_Pvariable(conf[CONF_ID])
|
|
await binary_sensor.register_binary_sensor(sens, conf)
|
|
cg.add(getattr(hub, f"set_{key}_binary_sensor")(sens))
|