mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 07:03:55 +00:00 
			
		
		
		
	[logger] fix on_message (#9642)
Co-authored-by: Samuel Sieb <samuel@sieb.net> Co-authored-by: J. Nick Koston <nick@koston.org> Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
		| @@ -193,7 +193,7 @@ def validate_local_no_higher_than_global(value): | |||||||
| Logger = logger_ns.class_("Logger", cg.Component) | Logger = logger_ns.class_("Logger", cg.Component) | ||||||
| LoggerMessageTrigger = logger_ns.class_( | LoggerMessageTrigger = logger_ns.class_( | ||||||
|     "LoggerMessageTrigger", |     "LoggerMessageTrigger", | ||||||
|     automation.Trigger.template(cg.int_, cg.const_char_ptr, cg.const_char_ptr), |     automation.Trigger.template(cg.uint8, cg.const_char_ptr, cg.const_char_ptr), | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -390,7 +390,7 @@ async def to_code(config): | |||||||
|         await automation.build_automation( |         await automation.build_automation( | ||||||
|             trigger, |             trigger, | ||||||
|             [ |             [ | ||||||
|                 (cg.int_, "level"), |                 (cg.uint8, "level"), | ||||||
|                 (cg.const_char_ptr, "tag"), |                 (cg.const_char_ptr, "tag"), | ||||||
|                 (cg.const_char_ptr, "message"), |                 (cg.const_char_ptr, "message"), | ||||||
|             ], |             ], | ||||||
|   | |||||||
							
								
								
									
										18
									
								
								tests/components/logger/test-on_message.host.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								tests/components/logger/test-on_message.host.yaml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,18 @@ | |||||||
|  | logger: | ||||||
|  |   id: logger_id | ||||||
|  |   level: DEBUG | ||||||
|  |   on_message: | ||||||
|  |     - level: DEBUG | ||||||
|  |       then: | ||||||
|  |         - lambda: |- | ||||||
|  |             ESP_LOGD("test", "Got message level %d: %s - %s", level, tag, message); | ||||||
|  |     - level: WARN | ||||||
|  |       then: | ||||||
|  |         - lambda: |- | ||||||
|  |             ESP_LOGW("test", "Warning level %d from %s", level, tag); | ||||||
|  |     - level: ERROR | ||||||
|  |       then: | ||||||
|  |         - lambda: |- | ||||||
|  |             // Test that level is uint8_t by using it in calculations | ||||||
|  |             uint8_t adjusted_level = level + 1; | ||||||
|  |             ESP_LOGE("test", "Error with adjusted level %d", adjusted_level); | ||||||
		Reference in New Issue
	
	Block a user