mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-06-04 03:48:29 +02:00
Background calibration & ABC commands for SenseAir S8 (#1623)
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome import automation
|
||||
from esphome.automation import maybe_simple_id
|
||||
from esphome.components import sensor, uart
|
||||
from esphome.const import (
|
||||
CONF_CO2,
|
||||
@@ -15,6 +17,21 @@ senseair_ns = cg.esphome_ns.namespace("senseair")
|
||||
SenseAirComponent = senseair_ns.class_(
|
||||
"SenseAirComponent", cg.PollingComponent, uart.UARTDevice
|
||||
)
|
||||
SenseAirBackgroundCalibrationAction = senseair_ns.class_(
|
||||
"SenseAirBackgroundCalibrationAction", automation.Action
|
||||
)
|
||||
SenseAirBackgroundCalibrationResultAction = senseair_ns.class_(
|
||||
"SenseAirBackgroundCalibrationResultAction", automation.Action
|
||||
)
|
||||
SenseAirABCEnableAction = senseair_ns.class_(
|
||||
"SenseAirABCEnableAction", automation.Action
|
||||
)
|
||||
SenseAirABCDisableAction = senseair_ns.class_(
|
||||
"SenseAirABCDisableAction", automation.Action
|
||||
)
|
||||
SenseAirABCGetPeriodAction = senseair_ns.class_(
|
||||
"SenseAirABCGetPeriodAction", automation.Action
|
||||
)
|
||||
|
||||
CONFIG_SCHEMA = (
|
||||
cv.Schema(
|
||||
@@ -38,3 +55,34 @@ def to_code(config):
|
||||
if CONF_CO2 in config:
|
||||
sens = yield sensor.new_sensor(config[CONF_CO2])
|
||||
cg.add(var.set_co2_sensor(sens))
|
||||
|
||||
|
||||
CALIBRATION_ACTION_SCHEMA = maybe_simple_id(
|
||||
{
|
||||
cv.Required(CONF_ID): cv.use_id(SenseAirComponent),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
"senseair.background_calibration",
|
||||
SenseAirBackgroundCalibrationAction,
|
||||
CALIBRATION_ACTION_SCHEMA,
|
||||
)
|
||||
@automation.register_action(
|
||||
"senseair.background_calibration_result",
|
||||
SenseAirBackgroundCalibrationResultAction,
|
||||
CALIBRATION_ACTION_SCHEMA,
|
||||
)
|
||||
@automation.register_action(
|
||||
"senseair.abc_enable", SenseAirABCEnableAction, CALIBRATION_ACTION_SCHEMA
|
||||
)
|
||||
@automation.register_action(
|
||||
"senseair.abc_disable", SenseAirABCDisableAction, CALIBRATION_ACTION_SCHEMA
|
||||
)
|
||||
@automation.register_action(
|
||||
"senseair.abc_get_period", SenseAirABCGetPeriodAction, CALIBRATION_ACTION_SCHEMA
|
||||
)
|
||||
def senseair_action_to_code(config, action_id, template_arg, args):
|
||||
paren = yield cg.get_variable(config[CONF_ID])
|
||||
yield cg.new_Pvariable(action_id, template_arg, paren)
|
||||
|
||||
Reference in New Issue
Block a user