What is the code to export state from .h include file to dashboard ?
I made a blinking LED with h file, which works but don’t know how to import Pin state. Here my code:
ESP8266 H code:
#include “esphome.h”
class Blink : public Component {
public:
void setup() override {
// This will be called once to set up the component
// think of it as the setup() call in Arduino
pinMode(2, OUTPUT);
//pinMode(21, INPUT);
//pinMode(7, OUTPUT);
//pinMode(16, INPUT);
}
void loop() override {
digitalWrite(2, HIGH);
delay(500);
digitalWrite(2, LOW);
delay(500);
}
};
ESPHOME YALM code:
substitutions:
name: esphome-web-73afe6
friendly_name: Heat_Pump_GTW-08
esphome:
name: ${name}
friendly_name: ${friendly_name}
min_version: 2024.6.0
name_add_mac_suffix: false
project:
name: esphome.web
version: dev
includes:
- blink.h
esp8266:
board: esp01_1m
# Enable logging
logger:
# Enable Home Assistant API
api:
# Allow Over-The-Air updates
ota:
- platform: esphome
# Allow provisioning Wi-Fi via serial
improv_serial:
wifi:
# Set up a wifi access point
ap: {}
# In combination with the `ap` this allows the user
# to provision wifi credentials to the device via WiFi AP.
captive_portal:
dashboard_import:
package_import_url: github://esphome/example-configs/esphome-web/esp8266.yaml@main
import_full_config: true
# To have a "next url" for improv serial
web_server:
port: 80
custom_component:
- lambda: |-
auto blink = new Blink();
return {blink};
components:
- id: my_custom_blink