mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 07:03:55 +00:00 
			
		
		
		
	Fixes
This commit is contained in:
		
							
								
								
									
										38
									
								
								tests/custom.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								tests/custom.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,38 @@ | ||||
|  | ||||
| class CustomSensor : public Component, public Sensor { | ||||
|  public: | ||||
|   void loop() override { | ||||
|     publish_state(42.0); | ||||
|   } | ||||
| }; | ||||
|  | ||||
| class CustomTextSensor : public Component, public TextSensor { | ||||
|  public: | ||||
|   void loop() override { | ||||
|     publish_state("Hello World"); | ||||
|   } | ||||
| }; | ||||
|  | ||||
| class CustomBinarySensor : public Component, public BinarySensor { | ||||
|  public: | ||||
|   void loop() override { | ||||
|     publish_state(false); | ||||
|   } | ||||
| }; | ||||
|  | ||||
| class CustomSwitch : public Switch { | ||||
|  protected: | ||||
|   void write_state(bool state) override { | ||||
|     ESP_LOGD("custom_switch", "Setting %s", ONOFF(state)); | ||||
|   } | ||||
| }; | ||||
|  | ||||
| class CustomComponent : public PollingComponent { | ||||
|  public: | ||||
|   void setup() override { | ||||
|     ESP_LOGD("custom_component", "Setup"); | ||||
|   } | ||||
|   void update() override { | ||||
|     ESP_LOGD("custom_component", "Update"); | ||||
|   } | ||||
| }; | ||||
		Reference in New Issue
	
	Block a user