mirror of
https://github.com/esphome/esphome.git
synced 2024-12-19 16:07:47 +01:00
Convert more code to async-def syntax (#2095)
This commit is contained in:
parent
2966a62429
commit
34e8979d40
@ -18,8 +18,8 @@ CONFIG_SCHEMA = (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def to_code(config):
|
async def to_code(config):
|
||||||
var = cg.new_Pvariable(config[CONF_ID])
|
var = cg.new_Pvariable(config[CONF_ID])
|
||||||
yield cg.register_component(var, config)
|
await cg.register_component(var, config)
|
||||||
yield climate.register_climate(var, config)
|
await climate.register_climate(var, config)
|
||||||
yield ble_client.register_ble_node(var, config)
|
await ble_client.register_ble_node(var, config)
|
||||||
|
@ -51,22 +51,22 @@ CONFIG_SCHEMA = (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def to_code(config):
|
async def to_code(config):
|
||||||
var = cg.new_Pvariable(config[CONF_ID])
|
var = cg.new_Pvariable(config[CONF_ID])
|
||||||
yield cg.register_component(var, config)
|
await cg.register_component(var, config)
|
||||||
yield esp32_ble_tracker.register_ble_device(var, config)
|
await esp32_ble_tracker.register_ble_device(var, config)
|
||||||
|
|
||||||
cg.add(var.set_address(config[CONF_MAC_ADDRESS].as_hex))
|
cg.add(var.set_address(config[CONF_MAC_ADDRESS].as_hex))
|
||||||
|
|
||||||
if CONF_TEMPERATURE in config:
|
if CONF_TEMPERATURE in config:
|
||||||
sens = yield sensor.new_sensor(config[CONF_TEMPERATURE])
|
sens = await sensor.new_sensor(config[CONF_TEMPERATURE])
|
||||||
cg.add(var.set_temperature(sens))
|
cg.add(var.set_temperature(sens))
|
||||||
if CONF_HUMIDITY in config:
|
if CONF_HUMIDITY in config:
|
||||||
sens = yield sensor.new_sensor(config[CONF_HUMIDITY])
|
sens = await sensor.new_sensor(config[CONF_HUMIDITY])
|
||||||
cg.add(var.set_humidity(sens))
|
cg.add(var.set_humidity(sens))
|
||||||
if CONF_BATTERY_LEVEL in config:
|
if CONF_BATTERY_LEVEL in config:
|
||||||
sens = yield sensor.new_sensor(config[CONF_BATTERY_LEVEL])
|
sens = await sensor.new_sensor(config[CONF_BATTERY_LEVEL])
|
||||||
cg.add(var.set_battery_level(sens))
|
cg.add(var.set_battery_level(sens))
|
||||||
if CONF_BATTERY_VOLTAGE in config:
|
if CONF_BATTERY_VOLTAGE in config:
|
||||||
sens = yield sensor.new_sensor(config[CONF_BATTERY_VOLTAGE])
|
sens = await sensor.new_sensor(config[CONF_BATTERY_VOLTAGE])
|
||||||
cg.add(var.set_battery_voltage(sens))
|
cg.add(var.set_battery_voltage(sens))
|
||||||
|
@ -22,7 +22,7 @@ CONFIG_SCHEMA = (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def to_code(config):
|
async def to_code(config):
|
||||||
var = cg.new_Pvariable(config[CONF_ID], config[CONF_HISTORICAL_MODE])
|
var = cg.new_Pvariable(config[CONF_ID], config[CONF_HISTORICAL_MODE])
|
||||||
yield cg.register_component(var, config)
|
await cg.register_component(var, config)
|
||||||
yield uart.register_uart_device(var, config)
|
await uart.register_uart_device(var, config)
|
||||||
|
@ -18,9 +18,9 @@ CONFIG_SCHEMA = sensor.sensor_schema(UNIT_WATT_HOURS, ICON_FLASH, 0).extend(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def to_code(config):
|
async def to_code(config):
|
||||||
var = cg.new_Pvariable(config[CONF_ID], config[CONF_TAG_NAME])
|
var = cg.new_Pvariable(config[CONF_ID], config[CONF_TAG_NAME])
|
||||||
yield cg.register_component(var, config)
|
await cg.register_component(var, config)
|
||||||
yield sensor.register_sensor(var, config)
|
await sensor.register_sensor(var, config)
|
||||||
teleinfo = yield cg.get_variable(config[CONF_TELEINFO_ID])
|
teleinfo = await cg.get_variable(config[CONF_TELEINFO_ID])
|
||||||
cg.add(teleinfo.register_teleinfo_listener(var))
|
cg.add(teleinfo.register_teleinfo_listener(var))
|
||||||
|
@ -20,9 +20,9 @@ CONFIG_SCHEMA = text_sensor.TEXT_SENSOR_SCHEMA.extend(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def to_code(config):
|
async def to_code(config):
|
||||||
var = cg.new_Pvariable(config[CONF_ID], config[CONF_TAG_NAME])
|
var = cg.new_Pvariable(config[CONF_ID], config[CONF_TAG_NAME])
|
||||||
yield cg.register_component(var, config)
|
await cg.register_component(var, config)
|
||||||
yield text_sensor.register_text_sensor(var, config)
|
await text_sensor.register_text_sensor(var, config)
|
||||||
teleinfo = yield cg.get_variable(config[CONF_TELEINFO_ID])
|
teleinfo = await cg.get_variable(config[CONF_TELEINFO_ID])
|
||||||
cg.add(teleinfo.register_teleinfo_listener(var))
|
cg.add(teleinfo.register_teleinfo_listener(var))
|
||||||
|
Loading…
Reference in New Issue
Block a user