New iobroker
This commit is contained in:
@@ -15,7 +15,8 @@
|
||||
|
||||
const char* ssid = "wf-home";
|
||||
const char* password = "0ndthnrf";
|
||||
const char* mqtt_server = "192.168.1.250";
|
||||
const char* mqtt_server = "192.168.1.111";
|
||||
#define TOPIC "home/"
|
||||
|
||||
Bounce but1 = Bounce();
|
||||
Bounce but2 = Bounce();
|
||||
@@ -123,14 +124,14 @@ void loop(){
|
||||
digitalWrite(SOCK1, stat1);
|
||||
EEPROM.write(0, stat1);
|
||||
EEPROM.commit();
|
||||
pubBool("/home/roz1/on1", stat1);
|
||||
pubBool(TOPIC"roz1/on1", stat1);
|
||||
}
|
||||
if(stat2 != oldstat2){
|
||||
oldstat2 = stat2;
|
||||
digitalWrite(SOCK2, stat2);
|
||||
EEPROM.write(1, stat2);
|
||||
EEPROM.commit();
|
||||
pubBool("/home/roz1/on2", stat2);
|
||||
pubBool(TOPIC"roz1/on2", stat2);
|
||||
}
|
||||
if(cRun + 999 < millis()){
|
||||
cRun = millis();
|
||||
@@ -139,7 +140,7 @@ void loop(){
|
||||
nSec = 0;
|
||||
char v[15];
|
||||
ultoa(millis()/1000, v, 10);
|
||||
mqttClient.publish("/home/roz1/millis", 1, false, v);
|
||||
mqttClient.publish(TOPIC"roz1/millis", 1, false, v);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -175,12 +176,12 @@ void onMqttConnect(bool sessionPresent) {
|
||||
Serial.println("Connected to MQTT.");
|
||||
Serial.print("Session present: ");
|
||||
Serial.println(sessionPresent);
|
||||
mqttClient.publish("/home/roz1/on1", 1, false, stat1 == 0 ? "false" : "true");
|
||||
mqttClient.publish("/home/roz1/on1_set", 1, false, stat1 == 0 ? "false" : "true");
|
||||
mqttClient.publish("/home/roz1/on2", 1, false, stat2 == 0 ? "false" : "true");
|
||||
mqttClient.publish("/home/roz1/on2_set", 1, false, stat2 == 0 ? "false" : "true");
|
||||
mqttClient.subscribe("/home/roz1/on1_set", 1);
|
||||
mqttClient.subscribe("/home/roz1/on2_set", 1);
|
||||
mqttClient.publish(TOPIC"roz1/on1", 1, false, stat1 == 0 ? "false" : "true");
|
||||
mqttClient.publish(TOPIC"roz1/on1_set", 1, false, stat1 == 0 ? "false" : "true");
|
||||
mqttClient.publish(TOPIC"roz1/on2", 1, false, stat2 == 0 ? "false" : "true");
|
||||
mqttClient.publish(TOPIC"roz1/on2_set", 1, false, stat2 == 0 ? "false" : "true");
|
||||
mqttClient.subscribe(TOPIC"roz1/on1_set", 1);
|
||||
mqttClient.subscribe(TOPIC"roz1/on2_set", 1);
|
||||
nSec = 59;
|
||||
digitalWrite(LED_MQ, LOW);
|
||||
}
|
||||
@@ -200,7 +201,7 @@ void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties
|
||||
pl[len] = 0;
|
||||
Serial.println(topic);
|
||||
Serial.println(pl);
|
||||
if(strcmp(topic, "/home/roz1/on1_set") == 0){
|
||||
if(strcmp(topic, TOPIC"roz1/on1_set") == 0){
|
||||
if(strcmp(pl, "true") == 0){
|
||||
stat1 = 1;
|
||||
}
|
||||
@@ -209,7 +210,7 @@ void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(strcmp(topic, "/home/roz1/on2_set") == 0){
|
||||
if(strcmp(topic, TOPIC"roz1/on2_set") == 0){
|
||||
if(strcmp(pl, "true") == 0){
|
||||
stat2 = 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user