diff --git a/esphome/components/si4713_i2c/__init__.py b/esphome/components/si4713_i2c/__init__.py index fd20c751fc..5e58a63b7d 100644 --- a/esphome/components/si4713_i2c/__init__.py +++ b/esphome/components/si4713_i2c/__init__.py @@ -475,13 +475,12 @@ async def to_code(config): async def new_sensor(c, args, setter): s = None - match args[1]: - case "sensor": - s = await sensor.new_sensor(c) - case "binary_sensor": - s = await binary_sensor.new_binary_sensor(c) - case "text_sensor": - s = await text_sensor.new_text_sensor(c) + if args[1] == "sensor": + s = await sensor.new_sensor(c) + elif args[1] == "binary_sensor": + s = await binary_sensor.new_binary_sensor(c) + elif args[1] == "text_sensor": + s = await text_sensor.new_text_sensor(c) cg.add(getattr(var, setter + "_" + args[1])(s)) await for_each_conf(config, SENSORS, new_sensor) diff --git a/esphome/components/si4713_i2c/si4713sub.h b/esphome/components/si4713_i2c/si4713sub.h index 71a66dfbb9..5d9844b257 100644 --- a/esphome/components/si4713_i2c/si4713sub.h +++ b/esphome/components/si4713_i2c/si4713sub.h @@ -1,5 +1,8 @@ #pragma once +namespace esphome { +namespace si4713 { + #ifndef SUB_TEXT #define SUB_TEXT(name) \ protected: \ @@ -50,3 +53,5 @@ void publish_##name##_text_sensor() { this->publish(this->name##_text_sensor_, this->get_##name##_text_sensor()); } \ std::string get_##name##_text_sensor(); +} // namespace si4713 +} // namespace esphome