NEWS
ESP8266-wifi-light- AC 230V Dimmer benötige Hilfe…
-
MOD-Edit by eric2906; 01.07.2017 / 15:50; Spoiler-Tags gesetzt
****Hallo Leute,
ich versuche mich gerade an einem AC Dimmer und benötige Hilfe.****
Eingekauft wurde dieses Model hier:
https://de.aliexpress.com/item/AC-Light … 0.0.sxPBJR
****Das ganze soll an einem ESP8266 angeschlossen sein.
Link zum Github: https://github.com/Theb-1/ESP8266-wifi-light-dimmer****
Sketch sieht so aus:
! ````
#include <esp8266wifi.h>
#include <pubsubclient.h>
#include <esp8266webserver.h>
#include "hw_timer.h"
#include "OneButton.h"
#include "html_pages.h"
! // WIFI SETTINGS
const char* ssid = "SSID";
const char* password = "PASSWORD";
! // MQTT Settings
const char* mqtt_server = "";
const int mqtt_port = 1883;
const char* mqtt_user = "";
const char* mqtt_password = "";
const char* mqtt_state_topic = "office/light1/state";
const char* mqtt_brightness_topic = "office/light1/brightness";
const char* mqtt_fade_topic = "office/light1/fade";
const char* pir_state_topic = "office/light1/motion";
! // PIN SETTINGS
const byte switchPin = 5;
const byte zcPin = 12;
const byte outPin = 13;
const byte pirPin = 0;
! // BUTTON SETTINGS
const byte buttonType = 1; // 0 = toggle; 1 = momentary;
const byte buttonActiveOn = 0; // 0 = high; 1 = low;
! // OTHER SETTINGS
const byte mqttDebug = 1;
! byte fade = 0;
byte state = 1;
byte tarBrightness = 255;
byte curBrightness = 0;
byte zcState = 0; // 0 = ready; 1 = processing;
! ESP8266WebServer server(80);
WiFiClient espClient;
PubSubClient mqttClient(espClient);
OneButton button(switchPin, buttonActiveOn);
! void setup(void) {
pinMode(zcPin, INPUT_PULLUP);
pinMode(switchPin, INPUT_PULLUP);
pinMode(outPin, OUTPUT);
if (pirPin) pinMode(pirPin, INPUT_PULLUP);
! digitalWrite(outPin, 0);Serial.begin(115200);
Serial.println("");! WiFi.begin(ssid, password);
! while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
! Serial.print("\nConnected: ");
Serial.println(WiFi.localIP());
! server.on("/", {
// server args for state
if (server.arg("s") != "") {
if (server.arg("s") == "1" || server.arg("s") == "on" || server.arg("s") == "true") {
updateState(1);
}
else if (server.arg("s") == "t") {
updateState(!state);
}
else {
updateState(0);
}
}// server args for brightness if (server.arg("b") != "") { updateBrightness((byte) server.arg("b").toInt()); } // server args for fade if (server.arg("f") != "") { if (server.arg("f") == "1" || server.arg("f") == "on" || server.arg("f") == "true") { updateFade(1); } else if (server.arg("f") == "t") { updateFade(!fade); } else { updateFade(0); } } // json output String s = "{\n \"s\":"; s += state; s += ",\n \"b\":"; s += tarBrightness; s += ",\n \"f\":"; s += fade; s += "\n}"; server.send(200, "text/plain", s);
});
! server.on("/webupdate", {
server.send(200, "text/html", updateHTTP);
});server.onFileUpload( {
if(server.uri() != "/update") return;
detachInterrupt(zcPin);
detachInterrupt(switchPin);
hw_timer_set_func(0);
digitalWrite(outPin, 0);
HTTPUpload& upload = server.upload();
if(upload.status == UPLOAD_FILE_START){
state = 0;
//Serial.setDebugOutput(true);
Serial.printf("Update: %s\n", upload.filename.c_str());
uint32_t maxSketchSpace = (ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000;
if(!Update.begin(maxSketchSpace)){//start with max available size
Update.printError(Serial);
}
} else if(upload.status == UPLOAD_FILE_WRITE){
if(Update.write(upload.buf, upload.currentSize) != upload.currentSize){
Update.printError(Serial);
}
} else if(upload.status == UPLOAD_FILE_END){
if(Update.end(true)){ //true to set the size to the current progress
Serial.printf("Update Success: %u\nRebooting...\n", upload.totalSize);
} else {
Update.printError(Serial);
}
//Serial.setDebugOutput(false);
}
yield();
});server.on("/update", HTTP_POST, {
server.sendHeader("Connection", "close");
server.send(200, "text/plain", (Update.hasError())?"UPDATE FAIL":"UPDATE SUCCESS");
ESP.restart();
});server.begin();
Serial.println("HTTP server: Started");setupMQTTClient();
switch (buttonType) {
case 0: // toggle switch
attachInterrupt(switchPin, toggleSwitchDetect, CHANGE);
break;
case 1: // momentary
button.attachDuringLongPress(longPressTick, 10);
button.attachPatternEnd(clickPatternEnd);
break;
}! hw_timer_init(NMI_SOURCE, 0);
hw_timer_set_func(dimTimerISR);if (pirPin) attachInterrupt(pirPin, pirDetect, CHANGE);
attachInterrupt(zcPin, zcDetectISR, RISING);
}void setupMQTTClient() {
int connectResult;if (mqtt_server != "") {
Serial.print("MQTT client: ");
mqttClient.setServer(mqtt_server, mqtt_port);
mqttClient.setCallback(mqttCallback);if (mqtt_user == "") { connectResult = mqttClient.connect("ESP" + ESP.getChipId()); } else { connectResult = mqttClient.connect("ESP" + ESP.getChipId(), mqtt_user, mqtt_password); } if (connectResult) { Serial.println("Connected"); } else { Serial.print("Failed ("); Serial.print(mqttClient.state()); Serial.println(")"); } if (mqttClient.connected()) { Serial.print("MQTT topic '"); Serial.print(mqtt_state_topic); if (mqttClient.subscribe(mqtt_state_topic)) { Serial.println("': Subscribed"); } else { Serial.print("': Failed"); } Serial.print("MQTT topic '"); Serial.print(mqtt_brightness_topic); if (mqttClient.subscribe(mqtt_brightness_topic)) { Serial.println("': Subscribed"); } else { Serial.print("': Failed"); } Serial.print("MQTT topic '"); Serial.print(mqtt_fade_topic); if (mqttClient.subscribe(mqtt_fade_topic)) { Serial.println("': Subscribed"); } else { Serial.print("': Failed"); } }
}
}! void loop(void)
{
// handle button:
button.tick();// handle http:
server.handleClient();// handle MQTT:
//if (mqttClient.connected()) {
mqttClient.loop();
//}
//else {
// TODO: reconnect logic
//}
}! void updateState(bool newState) {
state = newState;if (mqttClient.connected()) {
String payload = (state)?"ON":"OFF";if (mqttDebug) { Serial.print("MQTT out: "); Serial.print(mqtt_state_topic); Serial.print(" = "); Serial.println(payload); } mqttClient.publish(mqtt_state_topic, payload.c_str(), true);
}
}! void updateFade(bool newFade) {
fade = newFade;if (mqttClient.connected()) {
String payload = (fade)?"ON":"OFF";if (mqttDebug) { Serial.print("MQTT out: "); Serial.print(mqtt_fade_topic); Serial.print(" = "); Serial.println(payload); } mqttClient.publish(mqtt_fade_topic, (fade) ?"ON":"OFF", true);
}
}! void updateBrightness(int newBrightness) {
tarBrightness = newBrightness;if (mqttClient.connected()) {
String payload = String(tarBrightness);if (mqttDebug) { Serial.print("MQTT out: "); Serial.print(mqtt_brightness_topic); Serial.print(" = "); Serial.println(payload); }
! mqttClient.publish(mqtt_brightness_topic, payload.c_str(), true);
}
}
! void clickPatternEnd() {
if (button.getPattern() == "C") {
updateState(!state);
}
else if (button.getPattern() == "CCC") {
updateFade(!fade);
}
else if (button.getPattern() == "L" || button.getPattern() == "CL") {
updateBrightness(tarBrightness);
}
}
! void longPressTick() {
if (button.getPattern() == "L") {
state = 1;
if (tarBrightness < 255) { ++tarBrightness; }
}
else if (button.getPattern() == "CL") {
if (state = 1) {
if (tarBrightness > 0) { --tarBrightness; }
}
}
}
! void toggleSwitchDetect() {
static byte toggleButtonState = 0;if (toggleButtonState == 0) {
toggleButtonState = 1;
updateState(!state);delay(20); // debounce toggleButtonState = 0;
}
}! void pirDetect() {
if (mqttClient.connected()) {
if (digitalRead(pirPin)) {
Serial.print('R');
mqttClient.publish(pir_state_topic, "ON");
}
else {
Serial.print('F');
mqttClient.publish(pir_state_topic, "OFF");
}
}
}
! void mqttCallback(char* topic, byte* payload, unsigned int length) {
char c_payload[length];
memcpy(c_payload, payload, length);
c_payload[length] = '\0';String s_topic = String(topic);
String s_payload = String(c_payload);if (mqttDebug) {
Serial.print("MQTT in: ");
Serial.print(s_topic);
Serial.print(" = ");
Serial.print(s_payload);
}! if (s_topic == mqtt_state_topic) {
if (mqttDebug) { Serial.println(""); }if (s_payload == "ON") { if (state != 1) { updateState(1); } } else if (s_payload == "OFF") { if (state != 0) { updateState(0); } }
}
else if (s_topic == mqtt_fade_topic) {
if (mqttDebug) { Serial.println(""); }if (s_payload == "ON") { if (fade != 1) { updateFade(1); } } else if (s_payload == "OFF") { if (fade != 0) { updateFade(0); } }
}
else if (s_topic == mqtt_brightness_topic) {
if (mqttDebug) { Serial.println(""); }if (s_payload.toInt() != tarBrightness) { updateBrightness((byte) s_payload.toInt()); }
}
else {
if (mqttDebug) { Serial.println(" [unknown message]"); }
}
}! void dimTimerISR() {
if (fade == 1) {
if (curBrightness > tarBrightness || (state == 0 && curBrightness > 0)) {
--curBrightness;
}
else if (curBrightness < tarBrightness && state == 1 && curBrightness < 255) {
++curBrightness;
}
}
else {
if (state == 1) {
curBrightness = tarBrightness;
}
else {
curBrightness = 0;
}
}if (curBrightness == 0) { state = 0; digitalWrite(outPin, 0); } else if (curBrightness == 255) { state = 1; digitalWrite(outPin, 1); } else { digitalWrite(outPin, 1); } zcState = 0;
}
! void zcDetectISR() {
if (zcState == 0) {
zcState = 1;if (curBrightness < 255 && curBrightness > 0) { digitalWrite(outPin, 0); int dimDelay = 30 * (255 - curBrightness) + 400; hw_timer_arm(dimDelay); }
}
}</esp8266webserver.h></pubsubclient.h></esp8266wifi.h>****Control**** Browse to IP of ESP. Use GET variables to configure settings: s = state (0 or 1) b = brightness (0-255) f = fade (0 or 1) ex1: View current settings (json): [http://ip.of.esp/](http://ip.of.esp/) ex2: Set brightness to 50% and set state to on: [http://ip.of.esp/?s=1&b=128](http://ip.of.esp/?s=1&b=128) ex3: Set brightness to 100% and enable fade: [http://ip.of.esp/?b=255&f=1](http://ip.of.esp/?b=255&f=1) ex4: Toggle state (on->off or off->on): [http://ip.of.esp/?s=t](http://ip.of.esp/?s=t) ****Hierbei erst die erste Frage. Ich sehe im Sketch volgende Zeilen:**** // MQTT Settings const char* mqtt_server = ""; const int mqtt_port = 1883; const char* mqtt_user = ""; const char* mqtt_password = ""; const char* mqtt_state_topic = "office/light1/state"; const char* mqtt_brightness_topic = "office/light1/brightness"; const char* mqtt_fade_topic = "office/light1/fade"; const char* pir_state_topic = "office/light1/motion"; ****Werde ich hiermit den Dimmer über den MQTT-Adapter steueren können ??? Ich würde gerne dazu denhqwidget für Dimmer benutzen wollen! Geht es??? Sonst bleibt nur der Weg über die Http Seite:**** Browse to IP of ESP. Use GET variables to configure settings: s = state (0 or 1) b = brightness (0-255) f = fade (0 or 1) ex1: View current settings (json): [http://ip.of.esp/](http://ip.of.esp/) ex2: Set brightness to 50% and set state to on: ****[http://ip.of.esp/?s=1&b=128](http://ip.of.esp/?s=1&b=128)**** ex3: Set brightness to 100% and enable fade: ****[http://ip.of.esp/?b=255&f=1](http://ip.of.esp/?b=255&f=1)**** ex4: Toggle state (on->off or off->on): ****[http://ip.of.esp/?s=t](http://ip.of.esp/?s=t)**** ****Da habe ich aber keine Idee wie ich das Widget konfigurieren müsste, damit man die Werte in der Zeile ändern könnte…**** [http://ip.of.esp/?b=](http://ip.of.esp/?b=)255&f=1 ****Kann jemand Helfen?**** [1526_ac-light-dimmer-module-for-pwm-control-1-channel-3-3v-5v-logic-ac-50-60hz.jpg](/assets/uploads/files/1526_ac-light-dimmer-module-for-pwm-control-1-channel-3-3v-5v-logic-ac-50-60hz.jpg)
-
MOD-Edit by eric2905; 02.07.2016 / 09:05; Code- und Spoiler-Tags hinzugefügt
Sketch funktioniert :D, es gibt aber Probleme
Ich bekomme keine Verbindung zum MQTT-Server, der Adapter bleibt auf gelb.
Ich sehe keine Fehler und habe keine Ahnung weshalb es nicht funktionieren möchte… Beim kompilieren fehlte diese Datei <pubsubclient.h>DarauF hin habe ich das hier bei IDE installiert:
http://s6z.de/cms/index.php/homeautomat ... tt-example
Stüch weiter unten im Text stehen noch weitere Hinweise
****Abhängig von der Version des installierten MQTT-Brokers muss der zu verwendende MQTT-Protkoll-Standard in der "PubSubClient" Library umgestellt werden.
Aktuell ist die Version V3.1.1, ältere Broker können aber auch noch die Versioin V3.1 als Standard nutzen.
https://www.dinotools.de/2015/04/11/mos … tt-broker/
Ein V3.1.1 Client kann sich nicht mit einem V3.1 Server Verbinden, da die Initialisierungs-Strings nicht kompatibel sind!
Bei der Verwendung eines älteren Linux-Mosquitto-Brokers (< V1.3.5) auf einem Raspberry Pi muss der ältere V3.1 Standard eingestellt werden,anderen Falls kommt es zu Probleme mit der Initialisierung.****
Mit welcher Version läuft unser MQTT-Adapte, jemand eine Ahnung? Kann man die Ursache für die fehlende Verbindung zum MQTT Adapter etwas einkreisen ???
Evtl. könnte jemand eine funktionierende lib <pubsubclient.h>zukommen lassen?
! ````
#include <pubsubclient.h>#include <esp8266webserver.h>#include "hw_timer.h"
#include "OneButton.h"
#include "html_pages.h"
! // WIFI SETTINGS
const char* ssid = "o2 DSL";
const char* password = "xxxxxx";
! // MQTT Settings
const char* mqtt_server = "192,168,1,100";
const int mqtt_port = 1883;
const char* mqtt_user = "mqtt_user";
const char* mqtt_password = "xxxxx";
const char* mqtt_state_topic = "office/light1/state";
const char* mqtt_brightness_topic = "office/light1/brightness";
const char* mqtt_fade_topic = "office/light1/fade";
const char* pir_state_topic = "office/light1/motion";
! // PIN SETTINGS
const byte switchPin = 5;
const byte zcPin = 12;
const byte outPin = 13;
const byte pirPin = 0;
! // BUTTON SETTINGS
const byte buttonType = 1; // 0 = toggle; 1 = momentary;
const byte buttonActiveOn = 0; // 0 = high; 1 = low;
! // OTHER SETTINGS
const byte mqttDebug = 1;
! byte fade = 0;
byte state = 1;
byte tarBrightness = 255;
byte curBrightness = 0;
byte zcState = 0; // 0 = ready; 1 = processing;
! ESP8266WebServer server(80);
WiFiClient espClient;
PubSubClient mqttClient(espClient);
OneButton button(switchPin, buttonActiveOn);</esp8266webserver.h></pubsubclient.h> -
ich komme nicht wirklich weiter….
Der MQTT Adapter ist ständig gelb. Manchmal aber werden die Daten angenommen.
Meistens wenn ich den Wemo reboote... Habt Ihr eine Idee?
Laut Sketch sollten aber 4 Sachen auftauchen:
// MQTT Settings
const char* mqtt_state_topic = "office/light1/state";
const char* mqtt_brightness_topic = "office/light1/brightness";
const char* mqtt_fade_topic = "office/light1/fade";
const char* pir_state_topic = "office/light1/motion";
Die Zeile mit der Bewegung ist nicht da… Ist es evtl.der Grund dafür?
Im Log kommt das hier:
mqtt.0 2017-07-02 02:40:20.484 info Client [] subscribes on topic "office/light1/fade" mqtt.0 2017-07-02 02:40:20.481 info Client [] subscribes on topic "office/light1/brightness" mqtt.0 2017-07-02 02:40:20.470 info Client [] subscribes on topic "office/light1/state" mqtt.0 2017-07-02 02:40:20.412 info Client [] connected mqtt.0 2017-07-02 02:39:45.887 info Starting MQTT authenticated server on port 1883 mqtt.0 2017-07-02 02:39:43.945 info starting. Version 1.3.2 in /opt/iobroker/node_modules/iobroker.mqtt, node: v6.11.0 host.orangepiplus2e 2017-07-02 02:39:40.906 info instance system.adapter.mqtt.0 started with pid 9953
EDIT:
ich habe noch etwas herausgefunden. Das Schalten wird ja angenommen.
http://192.168.1.150/?s=1 oder http://192.168.1.150/?s=0 bringt dem MQTT Adapter ON und OFF!
Der Adapter bleibr aber trotdem gelb.
1526_unbenannt.png
1526_unbenannt1.png
1526_unbenannt2.png -
> const char* mqtt_server = "192,168,1,100";
Dumme Frage, IP mit Komma anstatt mit Punkten getrennt, funktioniert das ? -
Hi, habe beides versucht, mit Punkt und Komma… Die IP wird meistens mit dem Punkt getrennt. Habe aber einige Sketche, wo eine Komma dazwischen ist.
Ich kann Dir echt nicht sagen wieso das so ist. Anderes funktioniert es einfach nicht....
****Der MQTT Adapter scheint ein Problem zu haben sobald ich den Wemo einschalte..
Im LOG kommen ganz viele Warnungen jetzt. Grundsätzlich läuft das Teil, nur eben nicht mit MQTT-Server.
Gibt es noch eine möglichkeit die Werte mit dem Widget zu verstellen ohne den MQTT Adapter ???****
! host.orangepiplus2e 2017-07-02 12:10:02.316 info instance system.adapter.mqtt.0 terminated with code 0 (OK)
! mqtt.0 2017-07-02 12:10:02.223 info Adapter is disabled => stop
! mqtt.0 2017-07-02 12:10:02.210 info Client [] closed
! host.orangepiplus2e 2017-07-02 12:10:02.120 info stopInstance system.adapter.mqtt.0 killing pid 4985
! host.orangepiplus2e 2017-07-02 12:10:02.117 info stopInstance system.adapter.mqtt.0
! host.orangepiplus2e 2017-07-02 12:10:02.089 info object change system.adapter.mqtt.0
! mqtt.0 2017-07-02 12:10:01.774 warn Cannot resolve topic name for ID: system.adapter.rflink.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:10:01.772 warn Cannot resolve topic name for ID: system.adapter.rflink.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:10:00.410 warn Cannot resolve topic name for ID: system.adapter.fritzbox.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:10:00.406 warn Cannot resolve topic name for ID: system.adapter.fritzbox.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:59.872 warn Cannot resolve topic name for ID: ping.0.orangepiplus2e.192_168_1_48.ms (object not found)
! mqtt.0 2017-07-02 12:09:59.834 warn Cannot resolve topic name for ID: ping.0.orangepiplus2e.192_168_1_58.ms (object not found)
! mqtt.0 2017-07-02 12:09:58.764 warn Cannot resolve topic name for ID: system.adapter.admin.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:58.761 warn Cannot resolve topic name for ID: system.adapter.admin.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:58.749 warn Cannot resolve topic name for ID: system.adapter.javascript.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:58.747 warn Cannot resolve topic name for ID: system.adapter.javascript.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:57.796 warn Cannot resolve topic name for ID: ping.0.orangepiplus2e.192_168_1_68.ms (object not found)
! mqtt.0 2017-07-02 12:09:57.758 warn Cannot resolve topic name for ID: ping.0.orangepiplus2e.192_168_1_55.ms (object not found)
! mqtt.0 2017-07-02 12:09:55.965 warn Cannot resolve topic name for ID: system.adapter.hm-rpc.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:55.956 warn Cannot resolve topic name for ID: system.adapter.hm-rpc.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:55.073 warn Cannot resolve topic name for ID: system.adapter.ping.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:55.067 warn Cannot resolve topic name for ID: system.adapter.ping.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:55.059 warn Cannot resolve topic name for ID: system.adapter.cloud.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:55.057 warn Cannot resolve topic name for ID: system.adapter.cloud.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:54.727 warn Cannot resolve topic name for ID: ping.0.orangepiplus2e.192_168_1_36.ms (object not found)
! mqtt.0 2017-07-02 12:09:54.307 warn Cannot resolve topic name for ID: system.adapter.web.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:54.305 warn Cannot resolve topic name for ID: system.adapter.web.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:53.864 warn Cannot resolve topic name for ID: system.adapter.hm-rega.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:53.862 warn Cannot resolve topic name for ID: system.adapter.hm-rega.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:50.385 warn Cannot resolve topic name for ID: hm-rpc.0.CENTRAL.PONG (object not found)
! mqtt.0 2017-07-02 12:09:50.366 warn Cannot resolve topic name for ID: ping.0.orangepiplus2e.192_168_1_48.ms (object not found)
! mqtt.0 2017-07-02 12:09:50.336 warn Cannot resolve topic name for ID: ping.0.orangepiplus2e.192_168_1_58.ms (object not found)
! mqtt.0 2017-07-02 12:09:50.316 warn Cannot resolve topic name for ID: system.adapter.yr.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:50.294 warn Cannot resolve topic name for ID: system.adapter.yr.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:50.274 warn Cannot resolve topic name for ID: system.adapter.history.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:50.254 warn Cannot resolve topic name for ID: system.adapter.history.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:50.234 warn Cannot resolve topic name for ID: ping.0.orangepiplus2e.192_168_1_68.ms (object not found)
! mqtt.0 2017-07-02 12:09:50.214 warn Cannot resolve topic name for ID: ping.0.orangepiplus2e.192_168_1_55.ms (object not found)
! mqtt.0 2017-07-02 12:09:50.192 warn Cannot resolve topic name for ID: ping.0.orangepiplus2e.192_168_1_36.ms (object not found)
! mqtt.0 2017-07-02 12:09:50.172 warn Cannot resolve topic name for ID: system.adapter.rflink.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:50.153 warn Cannot resolve topic name for ID: system.adapter.rflink.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:50.133 warn Cannot resolve topic name for ID: system.adapter.fritzbox.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:50.114 warn Cannot resolve topic name for ID: system.adapter.fritzbox.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:50.093 warn Cannot resolve topic name for ID: system.adapter.admin.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:50.073 warn Cannot resolve topic name for ID: system.adapter.admin.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:50.054 warn Cannot resolve topic name for ID: system.adapter.javascript.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:50.035 warn Cannot resolve topic name for ID: system.adapter.javascript.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:50.015 warn Cannot resolve topic name for ID: system.adapter.hm-rpc.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:49.993 warn Cannot resolve topic name for ID: system.adapter.hm-rpc.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:49.974 warn Cannot resolve topic name for ID: system.adapter.ping.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:49.955 warn Cannot resolve topic name for ID: system.adapter.ping.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:49.936 warn Cannot resolve topic name for ID: system.adapter.cloud.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:49.916 warn Cannot resolve topic name for ID: system.adapter.cloud.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:49.897 warn Cannot resolve topic name for ID: system.adapter.web.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:49.877 warn Cannot resolve topic name for ID: system.adapter.web.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:49.858 warn Cannot resolve topic name for ID: system.adapter.hm-rega.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:49.838 warn Cannot resolve topic name for ID: system.adapter.hm-rega.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:48.881 warn Cannot resolve topic name for ID: system.adapter.history.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:48.880 warn Cannot resolve topic name for ID: system.adapter.history.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:46.736 warn Cannot resolve topic name for ID: system.adapter.rflink.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:46.734 warn Cannot resolve topic name for ID: system.adapter.rflink.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:45.386 warn Cannot resolve topic name for ID: system.adapter.fritzbox.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:45.382 warn Cannot resolve topic name for ID: system.adapter.fritzbox.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:43.763 warn Cannot resolve topic name for ID: system.adapter.admin.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:43.749 warn Cannot resolve topic name for ID: system.adapter.admin.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:43.739 warn Cannot resolve topic name for ID: system.adapter.javascript.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:43.737 warn Cannot resolve topic name for ID: system.adapter.javascript.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:40.932 warn Cannot resolve topic name for ID: system.adapter.hm-rpc.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:40.930 warn Cannot resolve topic name for ID: system.adapter.hm-rpc.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:40.067 warn Cannot resolve topic name for ID: system.adapter.ping.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:40.059 warn Cannot resolve topic name for ID: system.adapter.ping.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:40.051 warn Cannot resolve topic name for ID: system.adapter.cloud.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:40.049 warn Cannot resolve topic name for ID: system.adapter.cloud.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:39.299 warn Cannot resolve topic name for ID: system.adapter.web.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:39.294 warn Cannot resolve topic name for ID: system.adapter.web.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:39.164 warn Cannot resolve topic name for ID: ping.0.orangepiplus2e.192_168_1_48.ms (object not found)
! mqtt.0 2017-07-02 12:09:39.147 warn Cannot resolve topic name for ID: ping.0.orangepiplus2e.192_168_1_58.ms (object not found)
! mqtt.0 2017-07-02 12:09:38.853 warn Cannot resolve topic name for ID: system.adapter.hm-rega.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:38.850 warn Cannot resolve topic name for ID: system.adapter.hm-rega.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:37.120 warn Cannot resolve topic name for ID: ping.0.orangepiplus2e.192_168_1_68.ms (object not found)
! mqtt.0 2017-07-02 12:09:37.091 warn Cannot resolve topic name for ID: ping.0.orangepiplus2e.192_168_1_55.ms (object not found)
! mqtt.0 2017-07-02 12:09:36.151 warn Cannot resolve topic name for ID: hm-rpc.0.CENTRAL.PONG (object not found)
! mqtt.0 2017-07-02 12:09:35.054 warn Cannot resolve topic name for ID: ping.0.orangepiplus2e.192_168_1_36.ms (object not found)
! mqtt.0 2017-07-02 12:09:33.870 warn Cannot resolve topic name for ID: system.adapter.history.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:33.866 warn Cannot resolve topic name for ID: system.adapter.history.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:31.749 warn Cannot resolve topic name for ID: system.adapter.rflink.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:31.746 warn Cannot resolve topic name for ID: system.adapter.rflink.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:30.376 warn Cannot resolve topic name for ID: system.adapter.fritzbox.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:30.372 warn Cannot resolve topic name for ID: system.adapter.fritzbox.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:28.705 warn Cannot resolve topic name for ID: system.adapter.admin.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:28.697 warn Cannot resolve topic name for ID: system.adapter.admin.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:28.687 warn Cannot resolve topic name for ID: system.adapter.javascript.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:28.684 warn Cannot resolve topic name for ID: system.adapter.javascript.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:25.921 warn Cannot resolve topic name for ID: system.adapter.hm-rpc.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:25.917 warn Cannot resolve topic name for ID: system.adapter.hm-rpc.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:25.069 warn Cannot resolve topic name for ID: system.adapter.ping.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:25.067 warn Cannot resolve topic name for ID: system.adapter.ping.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:25.059 warn Cannot resolve topic name for ID: system.adapter.cloud.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:25.058 warn Cannot resolve topic name for ID: system.adapter.cloud.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:24.316 warn Cannot resolve topic name for ID: system.adapter.web.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:24.312 warn Cannot resolve topic name for ID: system.adapter.web.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:23.843 warn Cannot resolve topic name for ID: system.adapter.hm-rega.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:23.840 warn Cannot resolve topic name for ID: system.adapter.hm-rega.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:19.854 warn Cannot resolve topic name for ID: ping.0.orangepiplus2e.192_168_1_48.ms (object not found)
! mqtt.0 2017-07-02 12:09:19.812 warn Cannot resolve topic name for ID: ping.0.orangepiplus2e.192_168_1_58.ms (object not found)
! mqtt.0 2017-07-02 12:09:18.802 warn Cannot resolve topic name for ID: system.adapter.history.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:18.798 warn Cannot resolve topic name for ID: system.adapter.history.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:17.786 warn Cannot resolve topic name for ID: ping.0.orangepiplus2e.192_168_1_68.ms (object not found)
! mqtt.0 2017-07-02 12:09:17.765 warn Cannot resolve topic name for ID: ping.0.orangepiplus2e.192_168_1_55.ms (object not found)
! mqtt.0 2017-07-02 12:09:16.745 warn Cannot resolve topic name for ID: system.adapter.rflink.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:16.742 warn Cannot resolve topic name for ID: system.adapter.rflink.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:15.711 warn Cannot resolve topic name for ID: ping.0.orangepiplus2e.192_168_1_36.ms (object not found)
! mqtt.0 2017-07-02 12:09:15.398 warn Cannot resolve topic name for ID: system.adapter.fritzbox.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:15.396 warn Cannot resolve topic name for ID: system.adapter.fritzbox.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:13.701 warn Cannot resolve topic name for ID: system.adapter.admin.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:13.685 warn Cannot resolve topic name for ID: system.adapter.admin.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:13.682 warn Cannot resolve topic name for ID: system.adapter.javascript.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:13.679 warn Cannot resolve topic name for ID: system.adapter.javascript.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:10.915 warn Cannot resolve topic name for ID: system.adapter.hm-rpc.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:10.913 warn Cannot resolve topic name for ID: system.adapter.hm-rpc.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:10.090 warn Cannot resolve topic name for ID: system.adapter.ping.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:10.089 warn Cannot resolve topic name for ID: system.adapter.ping.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:10.076 warn Cannot resolve topic name for ID: system.adapter.cloud.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:10.074 warn Cannot resolve topic name for ID: system.adapter.cloud.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:09.333 warn Cannot resolve topic name for ID: system.adapter.web.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:09.330 warn Cannot resolve topic name for ID: system.adapter.web.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:08.832 warn Cannot resolve topic name for ID: system.adapter.hm-rega.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:08.830 warn Cannot resolve topic name for ID: system.adapter.hm-rega.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:03.808 warn Cannot resolve topic name for ID: system.adapter.history.0.outputCount (object not found)
! mqtt.0 2017-07-02 12:09:03.806 warn Cannot resolve topic name for ID: system.adapter.history.0.inputCount (object not found)
! mqtt.0 2017-07-02 12:09:02.227 info Client [] subscribes on topic "office/light1/fade"
! mqtt.0 2017-07-02 12:09:02.225 info Client [] subscribes on topic "office/light1/brightness"
! mqtt.0 2017-07-02 12:09:02.211 info Client [] subscribes on topic "office/light1/state"
! mqtt.0 2017-07-02 12:09:02.159 info Client [] connected[/spoiler] -
Versuch erst einmal ein Minimalprogramm mit dem MQTT-Client/Server-Plugin:
`#include <esp8266wifi.h> #include <pubsubclient.h> const char* ssid = "deine_ssid"; const char* wpakey = "dein_key"; const char* mqtt_server = "deine_server_ip"; const char* login = "dein_loginname"; const char* password = "dein_passwort"; WiFiClient espClient; PubSubClient client(espClient); long lastMsg = 0; char msg[50]; int counter; String clientName; uint8_t mac[6]; String macToStr(const uint8_t* mac){ String result; for (int i = 0; i < 6; ++i) { result += String(mac[i], 16); if (i < 5){ result += ':'; } } return result; } void setup_wifi() { delay(5); WiFi.begin(ssid, wpakey); clientName += "wemos_"; WiFi.macAddress(mac); clientName += macToStr(mac); while (WiFi.status() != WL_CONNECTED) { delay(500); } } void callback(char* topic, byte* payload, unsigned int length) { } void reconnect() { while (!client.connected()) { if (client.connect((char*) clientName.c_str(), login, password)) { } else { delay(5000); } } } void setup() { setup_wifi(); client.setServer(mqtt_server, 1883); client.setCallback(callback); } void loop() { if (!client.connected()) { reconnect(); } client.loop(); long now = millis(); if (now - lastMsg > 6000) { lastMsg = now; sprintf(msg,"%02x:%02x:%02x:%02x:%02x:%02x/sensor",mac[0],mac[1],mac[2],mac[3],mac[4],mac[5]); if (client.connected()){ client.publish(msg,"test"); } } }</pubsubclient.h></esp8266wifi.h>` die Led muß grün sein und das Ganze sieht so aus, wie auf dem Bild. Wegen PubSubClient siehe [http://forum.iobroker.net/viewtopic.php ... 064#p73692](http://forum.iobroker.net/viewtopic.php?f=35&t=7064#p73692) [2551_mqtt1.jpg](/assets/uploads/files/2551_mqtt1.jpg) [2551_mqtt2.jpg](/assets/uploads/files/2551_mqtt2.jpg) [2551_mqtt3.jpg](/assets/uploads/files/2551_mqtt3.jpg) [/i]
-
ok, danke …
versuche mal und berichte...
-
ok,
das Testprogram funktoniert. Der Server verbindet auch und nimmt die grüne LED an.
Testsensor ist auch sichtbar….
Dann scheint mein Sketch nicht komaptibel zu sein...
-
Ich habe den Sketch geladen und ohne Hardware (weil nicht vorhanden) getestet, die MQTT-LED leuchtet grün und die Devices werden erstellt. Ich denke der Sketch funktioniert.
-
puhh, danke WAL
dann bin ich jetzt total verwirrt.. Sketch ist i.o (zumindest bei Dir), und der MQTT Adapter scheint bei mir auch normal zu Arbeiten. (habe dein Testsketch erforgreich getestet)
Trotzdem bekomme ich beides nicht zusammen zu laufen, bei Dir geht es. Zum kotzen :?
-
ich habe nur auch zur Zeit den Wemo ohne Hardware dran… Ich vermute trotzdem nen Fehler im Sketch.
Serieller Momitor spuckt nur noch die Meldung vom bridgness aus (siehe Bild)
Das Ende vom Lied ist, dass der ganze Adapter träger wird, bis sogar der ganze Admin nicht zu bedienen ist.
Unter Objekte/mqtt.0 werden die Daten mehrmalls in der sek. aktualisiert. Der ganze Adapter wird mit den Datensätzen bombardiert.... Man sieht schön in der seriellen Konsole wie schnell die Daten ausgespuckt werden. Ist es bei dir nicht der Fall? Hast Du versucht einen Wert zu ändern und beobachtet ob der Wert in MQTT Adapter aktualisiert wird?
Versuche zB. damit: (nur die IP passend Umstellen)
-
Habe es getestet und rufe den Webserver vom Wemos mit deinem Befehl auf und es kommt aber immer nur eine Antwort.
Du pollst wahrscheinlich den Befehl und der Wemos antwortet andauernd bis er sich oder iobrocker aufhängt.
-
Danke Walter,
was meinst Du mit pollen ???
Kannst Du mir sagen welche WEMO Version Du hast???
Evtl. liegt es dadran…. ich habe ein D1 mini... Nicht dass es nur mit einem LolIn funktioniert. Die Teile haben auch die Bezeichnung 8266.... :?
Ich setze nur ein Befehl ab (z.B Befehl aus der firefox http://192.168.1.150/?s=1&b=170), der Wemo ist noch ohne Hardware mit dem mini USB Kabel an dem Laptop dran angeschlossen, wovon die Befehle abgesetzt werden.
Hast Du eine Idee was ich falsch machen kann?
Bei Dir scheint es zu laufen.
1526_htb1hkwqmpxxxxb9xxxxq6xxfxxxv.jpg
1526_nodemculolin.jpg -
Ich nutze einen Wemos Bild unten, siehe http://forum.iobroker.net/viewtopic.php … 064#p73637
Pollen nennt man Timer gesteuerte Anfragen, um eine Antwort zu bekommen.
Zum Bleistift: Automatisch alle 5 sec. deine Url absetzen, um die Werte vom Wemos zu bekommen.
Du siehst in deinem Log MQTT In Anfragen die dauernd vom Wemos empfangen und mit MQTT Out beantwortet werden.
In meinem Log siehst du nur MQTT Out's, was bedeutet, das eine Url Anfrage kein MQTT In ist.
MQTT In's werden nur von einem MQTT-Server gesendet, um eine Antwort vom MQTT-Client zu bekommen.
Evtl. hast du ein Skript in ioBroker laufen, die die Anfragen sendet oder du hast einen MQTT-Server wie z.B. mosquitto auf einem Raspberry zusätzlich laufen ?
-
Danke Walter,
bin jetzt Stück weiter… und zwar: :mrgreen:
Habe mit der Einstellung unter MQTT-Adapter gespielt (verändert) und die IN Anfragen kommen nicht mehr..
Um deine Frage oben zu beantworten, nein, ich habe keine Scripte, oder zwei installierte mosquitto auf der OrangePi.
Die Komplikationen kommen von der Einstellung des MQTT-Adapters...
Nachdem ich es verstellt habe,(weis allerdings mitlerweile nicht mehr was dort vorher eingehakt war), werden die Daten ohne Probleme richtung MQTT übertragen.
Die IN Anfragen kommen nicht mehr. Siehe Bilder!
Allerdings laut LED Status des Adapters, bin ich noch nicht verbunden. Die LED leuchtet GELB.
Weiss Du wie ich den Adapter gescheit einstellen kann?
EDIT2: Der Parameter: Sende auch Zustände (ack=true): in den Einstellungen des Adapters bringt die IN Meldungen, was den ganzen Adapter lahm legt.
Es funktioniert alles, bis auf die gelbe LED die leuchtet. Idee en ?
1526_unbenannt1.jpg
1526_unbenannt2.jpg
1526_unbenannt3.jpg
1526_unbenannt4.jpg -
Meine MQTT-Einstellungen siehst du weiter oben, mit diesen funktioniert es bei mir ohne Probleme.
-
Danke Walter,
obwohl der Adapter immer noch gelb ist, werden alle Daten an den MQTT übertragen. Scheint wohl am Sketch zu liegen.
Bin momentan noch parallel an einem RGB Kontroller dran, und dort keine Probleme… Dort nimmt der Adapter sofort die grüne LED an.
Jetzt warte ich noch auf die AC Dimmer Schaltung aus China und werde weitermachen sobald alle Teile da sind.
Danke vorerst.
-
Hi knopers1,
wollte fragen ob du nun deine AC Dimmer Schaltung bekommen hast und diese mit dem ESP8266 testen konntest,
da ich gerne auch sowas machen würde
Gruß,
Bobberle
-
habe das Projekt aufs Eis gelegt da die Null-Linien-Erkennung an der Schaltung nicht sauber funktionierte.
AC Dimmer zu bauen ist nicht einfach! Du mußt die Schaltung so aufbauen dass der Null-Durchgang der AC Spg. sauber erkannt wird, sonst kannst Du den Triac nicht einmal zünden, oder Du trennst nicht sauber die Halbwellen ab.
Ohne Oszi ist es schwierig….