mirror of
https://github.com/anklimov/lighthub
synced 2025-12-06 11:49:51 +03:00
1w domoticz support
This commit is contained in:
@@ -554,11 +554,11 @@ void resetHard() {
|
|||||||
|
|
||||||
#ifdef _owire
|
#ifdef _owire
|
||||||
|
|
||||||
void Changed(int i, DeviceAddress addr, float val) {
|
void Changed(int i, DeviceAddress addr, float currentTemp) {
|
||||||
char addrstr[32] = "NIL";
|
char addrstr[32] = "NIL";
|
||||||
//char addrbuf[17];
|
//char addrbuf[17];
|
||||||
char valstr[16] = "NIL";
|
char valstr[16] = "NIL";
|
||||||
char *owEmit = NULL;
|
char *owEmitString = NULL;
|
||||||
char *owItem = NULL;
|
char *owItem = NULL;
|
||||||
|
|
||||||
SetBytes(addr, 8, addrstr);
|
SetBytes(addr, 8, addrstr);
|
||||||
@@ -566,25 +566,33 @@ void Changed(int i, DeviceAddress addr, float val) {
|
|||||||
|
|
||||||
aJsonObject *owObj = aJson.getObjectItem(owArr, addrstr);
|
aJsonObject *owObj = aJson.getObjectItem(owArr, addrstr);
|
||||||
if (owObj) {
|
if (owObj) {
|
||||||
owEmit = aJson.getObjectItem(owObj, "emit")->valuestring;
|
owEmitString = aJson.getObjectItem(owObj, "emit")->valuestring;
|
||||||
|
|
||||||
if (owEmit) {
|
if (owEmitString) {
|
||||||
printFloatValueToStr(val,valstr);
|
printFloatValueToStr(currentTemp,valstr);
|
||||||
debugSerial<<owEmit<<F("=")<<valstr<<eol;
|
debugSerial<<owEmitString<<F("=")<<valstr<<eol;
|
||||||
|
if ((currentTemp == -127.0) || (currentTemp == 85.0) || (currentTemp == 0.0)) //ToDo: 1-w short circuit mapped to "0" celsium
|
||||||
|
return;
|
||||||
|
|
||||||
|
#ifdef WITH_DOMOTICZ
|
||||||
|
aJsonObject *idx = aJson.getObjectItem(owObj, "idx");
|
||||||
|
if (idx && idx->valuestring) {//DOMOTICZ json format support
|
||||||
|
debugSerial << endl << idx->valuestring << F(" Domoticz valstr:");
|
||||||
|
char valstr[50];
|
||||||
|
sprintf(valstr, "{\"idx\":%s,\"svalue\":\"%.1f\"}", idx->valuestring, currentTemp);
|
||||||
|
debugSerial << valstr;
|
||||||
|
mqttClient.publish(owEmitString, valstr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if ((val == -127.0) || (val == 85.0) || (val == 0.0)) { //ToDo: 1-w short circuit mapped to "0" celsium
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
strcpy_P(addrstr, outprefix);
|
strcpy_P(addrstr, outprefix);
|
||||||
strncat(addrstr, owEmit, sizeof(addrstr));
|
strncat(addrstr, owEmitString, sizeof(addrstr));
|
||||||
//strncat(addrstr, addrbuf, sizeof(addrstr));
|
|
||||||
|
|
||||||
mqttClient.publish(addrstr, valstr);
|
mqttClient.publish(addrstr, valstr);
|
||||||
}
|
}
|
||||||
owItem = aJson.getObjectItem(owObj, "item")->valuestring;
|
owItem = aJson.getObjectItem(owObj, "item")->valuestring;
|
||||||
if (owItem) {
|
if (owItem)
|
||||||
thermoSetCurTemp(owItem, val); ///TODO: Refactore using Items interface
|
thermoSetCurTemp(owItem, currentTemp); ///TODO: Refactore using Items interface
|
||||||
}
|
|
||||||
|
|
||||||
else debugSerial<<F("1w-item not found in config")<<eol;
|
else debugSerial<<F("1w-item not found in config")<<eol;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ void restoreState();
|
|||||||
lan_status lanLoop();
|
lan_status lanLoop();
|
||||||
|
|
||||||
#ifndef OWIRE_DISABLE
|
#ifndef OWIRE_DISABLE
|
||||||
void Changed(int i, DeviceAddress addr, float val);
|
void Changed(int i, DeviceAddress addr, float currentTemp);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void modbusIdle(void);
|
void modbusIdle(void);
|
||||||
|
|||||||
@@ -63,9 +63,7 @@ int owUpdate() {
|
|||||||
}; //alive
|
}; //alive
|
||||||
if (ifind < 0 && sensors) {
|
if (ifind < 0 && sensors) {
|
||||||
wstat[t_count] = SW_FIND; //Newly detected
|
wstat[t_count] = SW_FIND; //Newly detected
|
||||||
debugSerial.print(F("dev#"));
|
debugSerial<<F("dev#")<<t_count<<F(" Addr:");
|
||||||
debugSerial.print(t_count);
|
|
||||||
debugSerial.print(F(" Addr:"));
|
|
||||||
PrintBytes(term[t_count], 8,0);
|
PrintBytes(term[t_count], 8,0);
|
||||||
debugSerial.println();
|
debugSerial.println();
|
||||||
if (term[t_count][0] == 0x28) {
|
if (term[t_count][0] == 0x28) {
|
||||||
@@ -78,8 +76,7 @@ int owUpdate() {
|
|||||||
}//if
|
}//if
|
||||||
} //while
|
} //while
|
||||||
|
|
||||||
debugSerial.print(F("1-wire count: "));
|
debugSerial<<F("1-wire count: ")<<t_count;
|
||||||
debugSerial.println(t_count);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,7 +86,7 @@ int owSetup(owChangedType owCh) {
|
|||||||
//// todo - move memory allocation to here
|
//// todo - move memory allocation to here
|
||||||
if (net) return true; // Already initialized
|
if (net) return true; // Already initialized
|
||||||
#ifdef DS2482_100_I2C_TO_1W_BRIDGE
|
#ifdef DS2482_100_I2C_TO_1W_BRIDGE
|
||||||
debugSerial.println(F("DS2482_100_I2C_TO_1W_BRIDGE init"));
|
debugSerial<<F("DS2482_100_I2C_TO_1W_BRIDGE init");
|
||||||
net = new OneWire;
|
net = new OneWire;
|
||||||
#else
|
#else
|
||||||
debugSerial.print(F("One wire setup on PIN:"));
|
debugSerial.print(F("One wire setup on PIN:"));
|
||||||
@@ -190,9 +187,7 @@ void owAdd(DeviceAddress addr) {
|
|||||||
memcpy(term[t_count], addr, 8);
|
memcpy(term[t_count], addr, 8);
|
||||||
//term[t_count]=addr;
|
//term[t_count]=addr;
|
||||||
|
|
||||||
debugSerial.print(F("dev#"));
|
debugSerial<<F("dev#")<<t_count<<F(" Addr:");
|
||||||
debugSerial.print(t_count);
|
|
||||||
debugSerial.print(F(" Addr:"));
|
|
||||||
PrintBytes(term[t_count], 8,0);
|
PrintBytes(term[t_count], 8,0);
|
||||||
debugSerial.println();
|
debugSerial.println();
|
||||||
if (term[t_count][0] == 0x28) {
|
if (term[t_count][0] == 0x28) {
|
||||||
|
|||||||
@@ -9,19 +9,19 @@
|
|||||||
; http://docs.platformio.org/page/projectconf.html
|
; http://docs.platformio.org/page/projectconf.html
|
||||||
[platformio]
|
[platformio]
|
||||||
src_dir = lighthub
|
src_dir = lighthub
|
||||||
;env_default =
|
env_default =
|
||||||
; megaatmega2560
|
; megaatmega2560
|
||||||
; megaatmega2560-net
|
; megaatmega2560-net
|
||||||
; due
|
; due
|
||||||
; esp8266
|
; esp8266
|
||||||
; esp32
|
; esp32
|
||||||
; megaatmega2560-5500
|
; megaatmega2560-5500
|
||||||
; due-5500
|
due-5500
|
||||||
; controllino
|
; controllino
|
||||||
; stm32
|
; stm32
|
||||||
|
|
||||||
;build_dir = /tmp/pioenvs
|
build_dir = /tmp/pioenvs
|
||||||
;libdeps_dir = /tmp/piolibdeps
|
libdeps_dir = /tmp/piolibdeps
|
||||||
|
|
||||||
[env:esp32]
|
[env:esp32]
|
||||||
platform = espressif32
|
platform = espressif32
|
||||||
|
|||||||
Reference in New Issue
Block a user