New iobroker
This commit is contained in:
@@ -36,7 +36,8 @@ uint16_t stat[4];
|
||||
|
||||
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/"
|
||||
|
||||
unsigned long crun;
|
||||
//sensors_event_t temp_event, pressure_event, humidity_event;
|
||||
|
||||
@@ -15,8 +15,8 @@ framework = arduino
|
||||
upload_protocol = espota
|
||||
upload_port = 192.168.1.147
|
||||
lib_deps =
|
||||
BME280 @ ^3.0.0
|
||||
finitespace/BME280 @ ^3.0.0
|
||||
milesburton/DallasTemperature @ ^3.9.1
|
||||
Bounce2 @ ^2.55
|
||||
LiquidCrystal_PCF8574 @ ^1.2.0
|
||||
AsyncMqttClient @ ^0.8.2
|
||||
thomasfredericks/Bounce2 @ ^2.55
|
||||
mathertel/LiquidCrystal_PCF8574 @ ^1.2.0
|
||||
marvinroger/AsyncMqttClient @ ^0.8.2
|
||||
|
||||
@@ -146,12 +146,12 @@ void loop() {
|
||||
if(mv){
|
||||
mv = true;
|
||||
lcd.setBacklight(255);
|
||||
mqttClient.publish("/home/kuh/move", 1, false, "1");
|
||||
mqttClient.publish(TOPIC"kuh/move", 1, false, "1");
|
||||
}
|
||||
else{
|
||||
mv = false;
|
||||
lcd.setBacklight(0);
|
||||
mqttClient.publish("/home/kuh/move", 1, false, "0");
|
||||
mqttClient.publish(TOPIC"kuh/move", 1, false, "0");
|
||||
}
|
||||
prMV = mv;
|
||||
}
|
||||
@@ -257,40 +257,40 @@ void publishMin()
|
||||
digitalWrite(BLUE, HIGH);
|
||||
if(!isnan(tempOut)){
|
||||
dtostrf(tempOut, 6, 1, strFVal);
|
||||
mqttClient.publish("/home/kuh/temp_out", 1, false, strFVal);
|
||||
mqttClient.publish(TOPIC"kuh/temp_out", 1, false, strFVal);
|
||||
}
|
||||
if(!isnan(tempIn)){
|
||||
dtostrf(tempIn, 6, 1, strFVal);
|
||||
mqttClient.publish("/home/kuh/temp_in", 1, false, strFVal);
|
||||
mqttClient.publish(TOPIC"kuh/temp_in", 1, false, strFVal);
|
||||
}
|
||||
if(!isnan(hum)){
|
||||
dtostrf(hum, 6, 1, strFVal);
|
||||
mqttClient.publish("/home/kuh/humidity", 1, false, strFVal);
|
||||
mqttClient.publish(TOPIC"kuh/humidity", 1, false, strFVal);
|
||||
}
|
||||
if(!isnan(press)){
|
||||
dtostrf(press, 6, 1, strFVal);
|
||||
mqttClient.publish("/home/kuh/pressure", 1, false, strFVal);
|
||||
mqttClient.publish(TOPIC"kuh/pressure", 1, false, strFVal);
|
||||
}
|
||||
//itoa(lightSP, strFVal, 10);
|
||||
//mqttClient.publish("/home/kuh/light_sp", 1, false, strFVal);
|
||||
//mqttClient.publish(TOPIC"kuh/light_sp", 1, false, strFVal);
|
||||
//itoa(lightDB, strFVal, 10);
|
||||
//mqttClient.publish("/home/kuh/light_db", 1, false, strFVal);
|
||||
//mqttClient.publish(TOPIC"kuh/light_db", 1, false, strFVal);
|
||||
itoa(adc, strFVal, 10);
|
||||
mqttClient.publish("/home/kuh/light_cur", 1, false, strFVal);
|
||||
mqttClient.publish(TOPIC"kuh/light_cur", 1, false, strFVal);
|
||||
if(!isnan(tempHol)){
|
||||
dtostrf(tempHol, 6, 1, strFVal);
|
||||
mqttClient.publish("/home/kuh/hol_top", 1, false, strFVal);
|
||||
mqttClient.publish(TOPIC"kuh/hol_top", 1, false, strFVal);
|
||||
}
|
||||
if(!isnan(tempHoM)){
|
||||
dtostrf(tempHoM, 6, 1, strFVal);
|
||||
mqttClient.publish("/home/kuh/hol_down", 1, false, strFVal);
|
||||
mqttClient.publish(TOPIC"kuh/hol_down", 1, false, strFVal);
|
||||
}
|
||||
if(!isnan(tempMor)){
|
||||
dtostrf(tempMor, 6, 1, strFVal);
|
||||
mqttClient.publish("/home/kuh/moroz", 1, false, strFVal);
|
||||
mqttClient.publish(TOPIC"kuh/moroz", 1, false, strFVal);
|
||||
}
|
||||
ultoa(crun, strFVal, 10);
|
||||
mqttClient.publish("/home/kuh/millis", 1, false, strFVal);
|
||||
mqttClient.publish(TOPIC"kuh/millis", 1, false, strFVal);
|
||||
digitalWrite(BLUE, LOW);
|
||||
}
|
||||
|
||||
@@ -354,14 +354,14 @@ void onWifiDisconnect(const WiFiEventStationModeDisconnected& event) {
|
||||
void onMqttConnect(bool sessionPresent) {
|
||||
char v[6];
|
||||
itoa(lightData.SP, v, 10);
|
||||
mqttClient.publish("/home/kuh/light_sp", 1, false, v);
|
||||
mqttClient.publish("/home/kuh/light_sp_set", 1, false, v);
|
||||
mqttClient.publish(TOPIC"kuh/light_sp", 1, false, v);
|
||||
mqttClient.publish(TOPIC"kuh/light_sp_set", 1, false, v);
|
||||
itoa(lightData.DB, v, 10);
|
||||
mqttClient.publish("/home/kuh/light_db", 1, false, v);
|
||||
mqttClient.publish("/home/kuh/light_db_set", 1, false, v);
|
||||
mqttClient.publish("/home/kuh/move", 1, false, mv == 1 ? "1" : "0");
|
||||
mqttClient.subscribe("/home/kuh/light_sp_set", 1);
|
||||
mqttClient.subscribe("/home/kuh/light_db_set", 1);
|
||||
mqttClient.publish(TOPIC"kuh/light_db", 1, false, v);
|
||||
mqttClient.publish(TOPIC"kuh/light_db_set", 1, false, v);
|
||||
mqttClient.publish(TOPIC"kuh/move", 1, false, mv == 1 ? "1" : "0");
|
||||
mqttClient.subscribe(TOPIC"kuh/light_sp_set", 1);
|
||||
mqttClient.subscribe(TOPIC"kuh/light_db_set", 1);
|
||||
digitalWrite(BLUE, LOW);
|
||||
}
|
||||
|
||||
@@ -375,17 +375,17 @@ void onMqttDisconnect(AsyncMqttClientDisconnectReason reason) {
|
||||
void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties properties, size_t len, size_t index, size_t total) {
|
||||
bool w = false;
|
||||
char v[6];
|
||||
if(strcmp(topic, "/home/kuh/light_sp_set") == 0){
|
||||
if(strcmp(topic, TOPIC"kuh/light_sp_set") == 0){
|
||||
lightSP = atoi(payload);
|
||||
w = true;
|
||||
itoa(lightData.SP, v, 10);
|
||||
mqttClient.publish("/home/kuh/light_sp", 1, false, v);
|
||||
mqttClient.publish(TOPIC"kuh/light_sp", 1, false, v);
|
||||
}
|
||||
if(strcmp(topic, "/home/kuh/light_db_set") == 0){
|
||||
if(strcmp(topic, TOPIC"kuh/light_db_set") == 0){
|
||||
lightDB = atoi(payload);
|
||||
w = true;
|
||||
itoa(lightData.DB, v, 10);
|
||||
mqttClient.publish("/home/kuh/light_db", 1, false, v);
|
||||
mqttClient.publish(TOPIC"kuh/light_db", 1, false, v);
|
||||
}
|
||||
if(w){
|
||||
lightData.SP = lightSP;
|
||||
|
||||
Reference in New Issue
Block a user