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
|
||||
|
||||
void Changed(int i, DeviceAddress addr, float val) {
|
||||
void Changed(int i, DeviceAddress addr, float currentTemp) {
|
||||
char addrstr[32] = "NIL";
|
||||
//char addrbuf[17];
|
||||
char valstr[16] = "NIL";
|
||||
char *owEmit = NULL;
|
||||
char *owEmitString = NULL;
|
||||
char *owItem = NULL;
|
||||
|
||||
SetBytes(addr, 8, addrstr);
|
||||
@@ -566,25 +566,33 @@ void Changed(int i, DeviceAddress addr, float val) {
|
||||
|
||||
aJsonObject *owObj = aJson.getObjectItem(owArr, addrstr);
|
||||
if (owObj) {
|
||||
owEmit = aJson.getObjectItem(owObj, "emit")->valuestring;
|
||||
owEmitString = aJson.getObjectItem(owObj, "emit")->valuestring;
|
||||
|
||||
if (owEmit) {
|
||||
printFloatValueToStr(val,valstr);
|
||||
debugSerial<<owEmit<<F("=")<<valstr<<eol;
|
||||
if (owEmitString) {
|
||||
printFloatValueToStr(currentTemp,valstr);
|
||||
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;
|
||||
|
||||
if ((val == -127.0) || (val == 85.0) || (val == 0.0)) { //ToDo: 1-w short circuit mapped to "0" celsium
|
||||
#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;
|
||||
}
|
||||
strcpy_P(addrstr, outprefix);
|
||||
strncat(addrstr, owEmit, sizeof(addrstr));
|
||||
//strncat(addrstr, addrbuf, sizeof(addrstr));
|
||||
#endif
|
||||
|
||||
strcpy_P(addrstr, outprefix);
|
||||
strncat(addrstr, owEmitString, sizeof(addrstr));
|
||||
mqttClient.publish(addrstr, valstr);
|
||||
}
|
||||
owItem = aJson.getObjectItem(owObj, "item")->valuestring;
|
||||
if (owItem) {
|
||||
thermoSetCurTemp(owItem, val); ///TODO: Refactore using Items interface
|
||||
}
|
||||
if (owItem)
|
||||
thermoSetCurTemp(owItem, currentTemp); ///TODO: Refactore using Items interface
|
||||
|
||||
else debugSerial<<F("1w-item not found in config")<<eol;
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ void restoreState();
|
||||
lan_status lanLoop();
|
||||
|
||||
#ifndef OWIRE_DISABLE
|
||||
void Changed(int i, DeviceAddress addr, float val);
|
||||
void Changed(int i, DeviceAddress addr, float currentTemp);
|
||||
#endif
|
||||
|
||||
void modbusIdle(void);
|
||||
|
||||
@@ -63,9 +63,7 @@ int owUpdate() {
|
||||
}; //alive
|
||||
if (ifind < 0 && sensors) {
|
||||
wstat[t_count] = SW_FIND; //Newly detected
|
||||
debugSerial.print(F("dev#"));
|
||||
debugSerial.print(t_count);
|
||||
debugSerial.print(F(" Addr:"));
|
||||
debugSerial<<F("dev#")<<t_count<<F(" Addr:");
|
||||
PrintBytes(term[t_count], 8,0);
|
||||
debugSerial.println();
|
||||
if (term[t_count][0] == 0x28) {
|
||||
@@ -78,8 +76,7 @@ int owUpdate() {
|
||||
}//if
|
||||
} //while
|
||||
|
||||
debugSerial.print(F("1-wire count: "));
|
||||
debugSerial.println(t_count);
|
||||
debugSerial<<F("1-wire count: ")<<t_count;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -89,7 +86,7 @@ int owSetup(owChangedType owCh) {
|
||||
//// todo - move memory allocation to here
|
||||
if (net) return true; // Already initialized
|
||||
#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;
|
||||
#else
|
||||
debugSerial.print(F("One wire setup on PIN:"));
|
||||
@@ -190,9 +187,7 @@ void owAdd(DeviceAddress addr) {
|
||||
memcpy(term[t_count], addr, 8);
|
||||
//term[t_count]=addr;
|
||||
|
||||
debugSerial.print(F("dev#"));
|
||||
debugSerial.print(t_count);
|
||||
debugSerial.print(F(" Addr:"));
|
||||
debugSerial<<F("dev#")<<t_count<<F(" Addr:");
|
||||
PrintBytes(term[t_count], 8,0);
|
||||
debugSerial.println();
|
||||
if (term[t_count][0] == 0x28) {
|
||||
|
||||
@@ -9,19 +9,19 @@
|
||||
; http://docs.platformio.org/page/projectconf.html
|
||||
[platformio]
|
||||
src_dir = lighthub
|
||||
;env_default =
|
||||
env_default =
|
||||
; megaatmega2560
|
||||
; megaatmega2560-net
|
||||
; due
|
||||
; esp8266
|
||||
; esp32
|
||||
; megaatmega2560-5500
|
||||
; due-5500
|
||||
due-5500
|
||||
; controllino
|
||||
; stm32
|
||||
|
||||
;build_dir = /tmp/pioenvs
|
||||
;libdeps_dir = /tmp/piolibdeps
|
||||
build_dir = /tmp/pioenvs
|
||||
libdeps_dir = /tmp/piolibdeps
|
||||
|
||||
[env:esp32]
|
||||
platform = espressif32
|
||||
|
||||
Reference in New Issue
Block a user