mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-30 22:53:59 +00:00 
			
		
		
		
	Housecleaning: Use walrus operator in text_sensor (#6559)
This commit is contained in:
		| @@ -186,8 +186,8 @@ async def build_filters(config): | |||||||
| async def setup_text_sensor_core_(var, config): | async def setup_text_sensor_core_(var, config): | ||||||
|     await setup_entity(var, config) |     await setup_entity(var, config) | ||||||
|  |  | ||||||
|     if CONF_DEVICE_CLASS in config: |     if (device_class := config.get(CONF_DEVICE_CLASS)) is not None: | ||||||
|         cg.add(var.set_device_class(config[CONF_DEVICE_CLASS])) |         cg.add(var.set_device_class(device_class)) | ||||||
|  |  | ||||||
|     if config.get(CONF_FILTERS):  # must exist and not be empty |     if config.get(CONF_FILTERS):  # must exist and not be empty | ||||||
|         filters = await build_filters(config[CONF_FILTERS]) |         filters = await build_filters(config[CONF_FILTERS]) | ||||||
| @@ -201,8 +201,8 @@ async def setup_text_sensor_core_(var, config): | |||||||
|         trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var) |         trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var) | ||||||
|         await automation.build_automation(trigger, [(cg.std_string, "x")], conf) |         await automation.build_automation(trigger, [(cg.std_string, "x")], conf) | ||||||
|  |  | ||||||
|     if CONF_MQTT_ID in config: |     if (mqtt_id := config.get(CONF_MQTT_ID)) is not None: | ||||||
|         mqtt_ = cg.new_Pvariable(config[CONF_MQTT_ID], var) |         mqtt_ = cg.new_Pvariable(mqtt_id, var) | ||||||
|         await mqtt.register_mqtt_component(mqtt_, config) |         await mqtt.register_mqtt_component(mqtt_, config) | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user