Esp8266 as a switch in vera


I quite good at programming, but never really done it with luup, plugins etc… But i have a small thing i want my Vera to do…

I want esp8266 with a relay to be controlled as a switch in Vera… Because then i can use homekit/homebridge to control with my I-devices… I know Mysensors and have worked with it a lot, but cant really to get it to work as a switch/light device i Vera… I have googled for 2 month now, and now i have to ask you guys for help… I code the esp’s with arduino, its what i have coded in before :slight_smile:

Im very interested in espeasy, because its so easy to work with, sensors etc, so the perfect match would to let espeasy and vera work together :slight_smile:

Hope someone can help me with my little project



i also started to use NodeMCU / ESP8266 with Vera. there is standard code in Arduino IDE to let the ESP8266 switch outputs via VERA interface or Vera app.

i also shared my experience on wiring the doorbell into Vera via ESP8266,38880.0.html

i can post the code to drive a switch via Vera? or did you already make progres…

Can you please post the code?

Thanks in advance.

Here is another way to program ESP8266.

I can develop how to interact with Vera if needed


sorry for delay, i was abroad.

i wired the doorbell to the ESPmodule and i used Arduino to program the ESP. i will show the code below.
I made a scene in VERA to send an email in case some one presses the front door bell and i attach a snapshot picture from a IP camera as well. i use a virtual switch in Vera to get it triggered but i guess it could also work without, you can call a scene directly from ESP, thats up to you.
it works fine, it works always, i never have to reboot this ESP. it is great

Arduino / ESP code:

#include <ESP8266WiFi.h>

const char* ssid = “my_network”;
const char* password = “my_password”;
const char* host = “192.168.0.xx”; //this is the IP adress of our VERA
int buttonState = 0;

void setup() {
pinMode(2, INPUT); //the doorswitch is connected to GPIO 2
// We start by connecting to a WiFi network
Serial.print(“Connecting to “);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
Serial.println(“WiFi connected”);
Serial.println("IP address: ");

void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(2);

// check if doorbell is pressed
// if not then status is HIGH:
if (buttonState == HIGH) {
//Serial.println("Doorbell is not activated ");

} else {
// the doorbell is pressed:
Serial.println("Doorbell activated ");
Serial.print("connecting to ");

// Use WiFiClient class to create TCP connections
WiFiClient client;
const int httpPort = 3480;
if (!client.connect(host, httpPort)) {
Serial.println(“connection failed”);
// We now create a URI for the request
String url = “/data_request?id=lu_action&DeviceNum=182&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=1”;

Serial.print("Requesting URL: ");

// This will send the request to the server
client.print(String("GET “) + url + " HTTP/1.1\r\n” +
"Host: " + host + “\r\n” +
“Connection: close\r\n\r\n”);
Serial.println(“closing connection”);


1 Like

Thanks for posting the code. I’m going to do some experimenting with it.

You have some “” quotes different that Compiler doesn’t recognize. Had to copy and paste it in notepad and replace your quotes with mines and it worked !. Thanks anyway for posting !!!

1 Like

Hi, thats strange, as it worked in my arduino compiler but thanks anyway and hope it all works out for you