def to_code(config): rhs = App.make_uptime_sensor(config[CONF_NAME], config.get(CONF_UPDATE_INTERVAL)) make = variable(config[CONF_MAKE_ID], rhs) uptime = make.Puptime sensor.setup_sensor(uptime, make.Pmqtt, config) setup_component(uptime, config)
def to_code(config): rhs = App.make_wifi_signal_sensor(config[CONF_NAME], config.get(CONF_UPDATE_INTERVAL)) make = variable(config[CONF_MAKE_ID], rhs) wifi = make.Pwifi sensor.setup_sensor(wifi, make.Pmqtt, config) setup_component(wifi, config)
def to_code(config): rhs = App.make_fast_led_light(config[CONF_NAME]) make = variable(config[CONF_MAKE_ID], rhs) fast_led = make.Pfast_led rgb_order = None if CONF_RGB_ORDER in config: rgb_order = RawExpression(config[CONF_RGB_ORDER]) template_args = TemplateArguments(RawExpression(config[CONF_CHIPSET]), config[CONF_DATA_PIN], config[CONF_CLOCK_PIN], rgb_order) add(fast_led.add_leds(template_args, config[CONF_NUM_LEDS])) if CONF_MAX_REFRESH_RATE in config: add(fast_led.set_max_refresh_rate(config[CONF_MAX_REFRESH_RATE])) if CONF_POWER_SUPPLY in config: for power_supply in get_variable(config[CONF_POWER_SUPPLY]): yield add(fast_led.set_power_supply(power_supply)) if CONF_COLOR_CORRECT in config: r, g, b = config[CONF_COLOR_CORRECT] add(fast_led.set_correction(r, g, b)) light.setup_light(make.Pstate, make.Pmqtt, config) setup_component(fast_led, config)
def to_code(config): pin = None for pin in gpio_input_pin_expression(config[CONF_PIN]): yield rhs = App.make_gpio_binary_sensor(config[CONF_NAME], pin) gpio = variable(config[CONF_MAKE_ID], rhs) binary_sensor.setup_binary_sensor(gpio.Pgpio, gpio.Pmqtt, config)
def to_code(config): output = None for output in get_variable(config[CONF_OUTPUT]): yield rhs = App.make_monochromatic_light(config[CONF_NAME], output) light_struct = variable(config[CONF_MAKE_ID], rhs) light.setup_light(light_struct.Pstate, light_struct.Pmqtt, config)
def to_code(config): rhs = App.make_template_switch(config[CONF_NAME]) make = variable(config[CONF_MAKE_ID], rhs) if CONF_LAMBDA in config: template_ = None for template_ in process_lambda(config[CONF_LAMBDA], [], return_type=optional.template(bool_)): yield add(make.Ptemplate_.set_state_lambda(template_)) if CONF_TURN_OFF_ACTION in config: actions = None for actions in automation.build_actions(config[CONF_TURN_OFF_ACTION], NoArg): yield add(make.Ptemplate_.add_turn_off_actions(actions)) if CONF_TURN_ON_ACTION in config: actions = None for actions in automation.build_actions(config[CONF_TURN_ON_ACTION], NoArg): yield add(make.Ptemplate_.add_turn_on_actions(actions)) if CONF_OPTIMISTIC in config: add(make.Ptemplate_.set_optimistic(config[CONF_OPTIMISTIC])) switch.setup_switch(make.Ptemplate_, make.Pmqtt, config)
def to_code(config): output = None for output in get_variable(config[CONF_OUTPUT]): yield rhs = App.make_simple_switch(config[CONF_NAME], output) gpio = variable(config[CONF_MAKE_ID], rhs) switch.setup_switch(gpio.Pswitch_, gpio.Pmqtt, config)
def to_code(config): pin = None for pin in gpio_output_pin_expression(config[CONF_PIN]): yield rhs = App.make_gpio_switch(config[CONF_NAME], pin) gpio = variable(config[CONF_MAKE_ID], rhs) switch.setup_switch(gpio.Pswitch_, gpio.Pmqtt, config)
def to_code(config): red = get_variable(config[CONF_RED]) green = get_variable(config[CONF_GREEN]) blue = get_variable(config[CONF_BLUE]) rhs = App.make_rgb_light(config[CONF_NAME], red, green, blue) light_struct = variable(light.MakeLight, config[CONF_MAKE_ID], rhs) light.setup_light(light_struct.Pstate, light_struct.Pmqtt, config)
def to_code(config): rhs = App.make_bme280_sensor(config[CONF_TEMPERATURE][CONF_NAME], config[CONF_PRESSURE][CONF_NAME], config[CONF_HUMIDITY][CONF_NAME], config[CONF_ADDRESS], config.get(CONF_UPDATE_INTERVAL)) make = variable(config[CONF_MAKE_ID], rhs) bme280 = make.Pbme280 if CONF_OVERSAMPLING in config[CONF_TEMPERATURE]: constant = OVERSAMPLING_OPTIONS[config[CONF_TEMPERATURE][CONF_OVERSAMPLING]] add(bme280.set_temperature_oversampling(constant)) if CONF_OVERSAMPLING in config[CONF_PRESSURE]: constant = OVERSAMPLING_OPTIONS[config[CONF_PRESSURE][CONF_OVERSAMPLING]] add(bme280.set_pressure_oversampling(constant)) if CONF_OVERSAMPLING in config[CONF_HUMIDITY]: constant = OVERSAMPLING_OPTIONS[config[CONF_HUMIDITY][CONF_OVERSAMPLING]] add(bme280.set_humidity_oversampling(constant)) if CONF_IIR_FILTER in config: constant = IIR_FILTER_OPTIONS[config[CONF_IIR_FILTER]] add(bme280.set_iir_filter(constant)) sensor.setup_sensor(bme280.Pget_temperature_sensor(), make.Pmqtt_temperature, config[CONF_TEMPERATURE]) sensor.setup_sensor(bme280.Pget_pressure_sensor(), make.Pmqtt_pressure, config[CONF_PRESSURE]) sensor.setup_sensor(bme280.Pget_humidity_sensor(), make.Pmqtt_humidity, config[CONF_HUMIDITY])
def to_code(config): rhs = App.make_template_cover(config[CONF_NAME]) make = variable(config[CONF_MAKE_ID], rhs) if CONF_LAMBDA in config: template_ = None for template_ in process_lambda(config[CONF_LAMBDA], [], return_type=optional.template( cover.CoverState)): yield add(make.Ptemplate_.set_state_lambda(template_)) if CONF_OPEN_ACTION in config: actions = None for actions in automation.build_actions(config[CONF_OPEN_ACTION], NoArg): yield add(make.Ptemplate_.add_open_actions(actions)) if CONF_CLOSE_ACTION in config: actions = None for actions in automation.build_actions(config[CONF_CLOSE_ACTION], NoArg): yield add(make.Ptemplate_.add_close_actions(actions)) if CONF_STOP_ACTION in config: actions = None for actions in automation.build_actions(config[CONF_STOP_ACTION], NoArg): yield add(make.Ptemplate_.add_stop_actions(actions)) if CONF_OPTIMISTIC in config: add(make.Ptemplate_.set_optimistic(config[CONF_OPTIMISTIC])) cover.setup_cover(make.Ptemplate_, make.Pmqtt, config)
def to_code(config): rhs = App.make_template_switch(config[CONF_NAME]) make = variable(config[CONF_MAKE_ID], rhs) template = make.Ptemplate_ switch.setup_switch(template, make.Pmqtt, config) if CONF_LAMBDA in config: for template_ in process_lambda(config[CONF_LAMBDA], [], return_type=optional.template(bool_)): yield add(template.set_state_lambda(template_)) if CONF_TURN_OFF_ACTION in config: automation.build_automation(template.get_turn_off_trigger(), NoArg, config[CONF_TURN_OFF_ACTION]) if CONF_TURN_ON_ACTION in config: automation.build_automation(template.get_turn_on_trigger(), NoArg, config[CONF_TURN_ON_ACTION]) if CONF_OPTIMISTIC in config: add(template.set_optimistic(config[CONF_OPTIMISTIC])) if CONF_RESTORE_STATE in config: add(template.set_restore_state(config[CONF_RESTORE_STATE])) setup_component(template, config)
def to_code(config): for output_ in get_variable(config[CONF_OUTPUT]): yield rhs = App.make_binary_light(config[CONF_NAME], output_) light_struct = variable(config[CONF_MAKE_ID], rhs) light.setup_light(light_struct.Pstate, light_struct.Pmqtt, config) setup_component(light_struct.Pstate, config)
def to_code(config): rhs = App.make_mqtt_subscribe_sensor(config[CONF_NAME], config[CONF_TOPIC]) make = variable(config[CONF_MAKE_ID], rhs) if CONF_QOS in config: add(make.Psensor.set_qos(config[CONF_QOS])) sensor.setup_sensor(make.Psensor, make.Pmqtt, config)
def to_code(config): pin = None for pin in gpio_input_pin_expression(config[CONF_PIN]): yield rhs = App.make_duty_cycle_sensor(config[CONF_NAME], pin, config.get(CONF_UPDATE_INTERVAL)) make = variable(config[CONF_MAKE_ID], rhs) sensor.setup_sensor(make.Pduty, make.Pmqtt, config)
def to_code(config): rhs = App.make_bh1750_sensor(config[CONF_NAME], config[CONF_ADDRESS], config.get(CONF_UPDATE_INTERVAL)) make_bh1750 = variable(config[CONF_MAKE_ID], rhs) bh1750 = make_bh1750.Pbh1750 if CONF_RESOLUTION in config: add(bh1750.set_resolution(BH1750_RESOLUTIONS[config[CONF_RESOLUTION]])) sensor.setup_sensor(bh1750, make_bh1750.Pmqtt, config)
def to_code(config): pin_cs = gpio_output_pin_expression(config[CONF_PIN_CS]) pin_clock = gpio_output_pin_expression(config[CONF_PIN_CLOCK]) pin_miso = gpio_input_pin_expression(config[CONF_PIN_MISO]) rhs = App.make_max6675_sensor(config[CONF_NAME], pin_cs, pin_clock, pin_miso, config.get(CONF_UPDATE_INTERVAL)) make = variable(MakeMAX6675Sensor, config[CONF_MAKE_ID], rhs) sensor.setup_sensor(make.Pmax6675, make.Pmqtt, config)
def to_code(config): template_ = None for template_ in process_lambda(config[CONF_LAMBDA], [], return_type=optional.template(bool_)): yield rhs = App.make_template_binary_sensor(config[CONF_NAME], template_) make = variable(config[CONF_MAKE_ID], rhs) binary_sensor.setup_binary_sensor(make.Ptemplate_, make.Pmqtt, config)
def to_code(config): rhs = App.make_gpio_binary_sensor(config[CONF_NAME], exp_gpio_input_pin(config[CONF_PIN])) gpio = variable('Application::MakeGPIOBinarySensor', config[CONF_ID], rhs) if CONF_INVERTED in config: add(gpio.Pgpio.set_inverted(config[CONF_INVERTED])) binary_sensor.setup_binary_sensor(gpio.Pgpio, config) binary_sensor.setup_mqtt_binary_sensor(gpio.Pmqtt, config)
def to_code(config): rhs = App.make_adc_sensor(config[CONF_NAME], config[CONF_PIN], config.get(CONF_UPDATE_INTERVAL)) make = variable(MakeADCSensor, config[CONF_MAKE_ID], rhs) adc = make.Padc if CONF_ATTENUATION in config: add(adc.set_attenuation(ATTENUATION_MODES[config[CONF_ATTENUATION]])) sensor.setup_sensor(make.Padc, make.Pmqtt, config)
def to_code(config): template_ = None for template_ in process_lambda(config[CONF_LAMBDA], [], return_type=optional.template(float_)): yield rhs = App.make_template_sensor(config[CONF_NAME], template_, config.get(CONF_UPDATE_INTERVAL)) make = variable(config[CONF_MAKE_ID], rhs) sensor.setup_sensor(make.Ptemplate_, make.Pmqtt, config)
def to_code(config): output = get_variable(config[CONF_OUTPUT]) rhs = App.make_fan(config[CONF_NAME]) fan_struct = variable('Application::MakeFan', config[CONF_ID], rhs) add(fan_struct.Poutput.set_binary(output)) if CONF_OSCILLATION_OUTPUT in config: oscillation_output = get_variable(config[CONF_OSCILLATION_OUTPUT]) add(fan_struct.Poutput.set_oscillation(oscillation_output)) fan.setup_mqtt_fan(fan_struct.Pmqtt, config)
def to_code(config): for pin in gpio_output_pin_expression(config[CONF_PIN]): yield rhs = App.make_gpio_switch(config[CONF_NAME], pin) make = variable(config[CONF_MAKE_ID], rhs) gpio = make.Pswitch_ switch.setup_switch(gpio, make.Pmqtt, config) setup_component(gpio, config)
def to_code(config): rhs = App.make_htu21d_sensor(config[CONF_TEMPERATURE][CONF_NAME], config[CONF_HUMIDITY][CONF_NAME], config.get(CONF_UPDATE_INTERVAL)) htu21d = variable(config[CONF_MAKE_ID], rhs) sensor.setup_sensor(htu21d.Phtu21d.Pget_temperature_sensor(), htu21d.Pmqtt_temperature, config[CONF_TEMPERATURE]) sensor.setup_sensor(htu21d.Phtu21d.Pget_humidity_sensor(), htu21d.Pmqtt_humidity, config[CONF_HUMIDITY])
def to_code(config): for output_ in get_variable(config[CONF_OUTPUT]): yield rhs = App.make_output_switch(config[CONF_NAME], output_) make = variable(config[CONF_MAKE_ID], rhs) switch_ = make.Pswitch_ switch.setup_switch(switch_, make.Pmqtt, config) setup_component(switch, config)
def to_code(config): rhs = App.make_hdc1080_sensor(config[CONF_TEMPERATURE][CONF_NAME], config[CONF_HUMIDITY][CONF_NAME], config.get(CONF_UPDATE_INTERVAL)) hdc1080 = variable(MakeHDC1080Sensor, config[CONF_MAKE_ID], rhs) sensor.setup_sensor(hdc1080.Phdc1080.Pget_temperature_sensor(), hdc1080.Pmqtt_temperature, config[CONF_TEMPERATURE]) sensor.setup_sensor(hdc1080.Phdc1080.Pget_humidity_sensor(), hdc1080.Pmqtt_humidity, config[CONF_HUMIDITY])
def to_code(config): red = get_variable(config[CONF_RED]) green = get_variable(config[CONF_GREEN]) blue = get_variable(config[CONF_BLUE]) rhs = App.make_rgb_light(config[CONF_NAME], red, green, blue) light_struct = variable('Application::MakeLight', config[CONF_ID], rhs) if CONF_GAMMA_CORRECT in config: add(light_struct.Poutput.set_gamma_correct(config[CONF_GAMMA_CORRECT])) setup_mqtt_component(light_struct.Pmqtt, config) light.setup_light_component(light_struct.Pstate, config)
def to_code(config): rhs = App.make_adc_sensor(config[CONF_NAME], config[CONF_PIN], config.get(CONF_UPDATE_INTERVAL)) make = variable('Application::MakeADCSensor', config[CONF_ID], rhs) adc = make.Padc if CONF_ATTENUATION in config: attenuation = ATTENUATION_MODES[config[CONF_ATTENUATION]] add(adc.set_attenuation(RawExpression(attenuation))) sensor.setup_sensor(adc, config) sensor.setup_mqtt_sensor_component(make.Pmqtt, config)
def to_code(config): rhs = App.make_dht12_sensor(config[CONF_TEMPERATURE][CONF_NAME], config[CONF_HUMIDITY][CONF_NAME], config.get(CONF_UPDATE_INTERVAL)) dht = variable(MakeDHT12Sensor, config[CONF_MAKE_ID], rhs) sensor.setup_sensor(dht.Pdht.Pget_temperature_sensor(), dht.Pmqtt_temperature, config[CONF_TEMPERATURE]) sensor.setup_sensor(dht.Pdht.Pget_humidity_sensor(), dht.Pmqtt_humidity, config[CONF_HUMIDITY])
def to_code(config): for uart_ in get_variable(config[CONF_UART_ID]): yield data = config[CONF_DATA] if isinstance(data, str): data = [HexInt(ord(x)) for x in data] rhs = App.make_uart_switch(uart_, config[CONF_NAME], ArrayInitializer(*data, multiline=False)) restart = variable(config[CONF_MAKE_ID], rhs) switch.setup_switch(restart.Puart, restart.Pmqtt, config)