mirror of https://github.com/arendst/Tasmota.git
commit
751366f7b7
|
@ -69,9 +69,6 @@ keywords if then else endif, or, and are better readable for beginners (others m
|
||||||
#define MAX_SARRAY_NUM 32
|
#define MAX_SARRAY_NUM 32
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <renderer.h>
|
|
||||||
extern Renderer *renderer;
|
|
||||||
|
|
||||||
uint32_t EncodeLightId(uint8_t relay_id);
|
uint32_t EncodeLightId(uint8_t relay_id);
|
||||||
uint32_t DecodeLightId(uint32_t hue_id);
|
uint32_t DecodeLightId(uint32_t hue_id);
|
||||||
|
|
||||||
|
@ -210,6 +207,10 @@ void alt_eeprom_readBytes(uint32_t adr, uint32_t len, uint8_t *buf) {
|
||||||
#endif // LITTLEFS_SCRIPT_SIZE
|
#endif // LITTLEFS_SCRIPT_SIZE
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef TESLA_POWERWALL
|
||||||
|
#include "powerwall.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
// offsets epoch readings by 1.1.2019 00:00:00 to fit into float with second resolution
|
// offsets epoch readings by 1.1.2019 00:00:00 to fit into float with second resolution
|
||||||
#ifndef EPOCH_OFFSET
|
#ifndef EPOCH_OFFSET
|
||||||
#define EPOCH_OFFSET 1546300800
|
#define EPOCH_OFFSET 1546300800
|
||||||
|
@ -871,7 +872,7 @@ char *script;
|
||||||
}
|
}
|
||||||
|
|
||||||
// variables usage info
|
// variables usage info
|
||||||
AddLog(LOG_LEVEL_INFO, PSTR("Script: nv=%d, tv=%d, vns=%d, ram=%d"), nvars, svars, index, glob_script_mem.script_mem_size);
|
AddLog(LOG_LEVEL_INFO, PSTR("Script: nv=%d, tv=%d, vns=%d, vmem=%d, smem=%d"), nvars, svars, index, glob_script_mem.script_mem_size, glob_script_mem.script_size);
|
||||||
|
|
||||||
// copy string variables
|
// copy string variables
|
||||||
char *cp1 = glob_script_mem.glob_snp;
|
char *cp1 = glob_script_mem.glob_snp;
|
||||||
|
@ -1082,11 +1083,23 @@ void script_udp_sendvar(char *vname,float *fp,char *sp) {
|
||||||
void ws2812_set_array(float *array ,uint32_t len, uint32_t offset) {
|
void ws2812_set_array(float *array ,uint32_t len, uint32_t offset) {
|
||||||
|
|
||||||
Ws2812ForceSuspend();
|
Ws2812ForceSuspend();
|
||||||
for (uint32_t cnt = 0; cnt<len; cnt++) {
|
for (uint32_t cnt = 0; cnt < len; cnt++) {
|
||||||
uint32_t index = cnt + offset;
|
uint32_t index;
|
||||||
if (index>Settings->light_pixels) break;
|
if (! (offset & 0x1000)) {
|
||||||
|
index = cnt + (offset & 0x7ff);
|
||||||
|
} else {
|
||||||
|
index = cnt/2 + (offset & 0x7ff);
|
||||||
|
}
|
||||||
|
if (index > Settings->light_pixels) break;
|
||||||
|
if (! (offset & 0x1000)) {
|
||||||
uint32_t col = array[cnt];
|
uint32_t col = array[cnt];
|
||||||
Ws2812SetColor(index + 1, col>>16, col>>8, col, 0);
|
Ws2812SetColor(index + 1, col>>16, col>>8, col, 0);
|
||||||
|
} else {
|
||||||
|
uint32_t hcol = array[cnt];
|
||||||
|
cnt++;
|
||||||
|
uint32_t lcol = array[cnt];
|
||||||
|
Ws2812SetColor(index + 1, hcol>>8, hcol, lcol>>8, lcol);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Ws2812ForceUpdate();
|
Ws2812ForceUpdate();
|
||||||
}
|
}
|
||||||
|
@ -1641,6 +1654,16 @@ char *isvar(char *lp, uint8_t *vtype, struct T_INDEX *tind, float *fp, char *sp,
|
||||||
|
|
||||||
if (gv && gv->jo) {
|
if (gv && gv->jo) {
|
||||||
// look for json input
|
// look for json input
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
char sbuf[SCRIPT_MAXSSIZE];
|
||||||
|
sbuf[0]=0;
|
||||||
|
char tmp[128];
|
||||||
|
Replace_Cmd_Vars(lp, 1, tmp, sizeof(tmp));
|
||||||
|
uint32_t res = JsonParsePath(gv->jo, tmp, '#', NULL, sbuf, sizeof(sbuf)); // software_version
|
||||||
|
AddLog(LOG_LEVEL_INFO, PSTR("json string: %s %s"),tmp, sbuf);
|
||||||
|
#endif
|
||||||
|
|
||||||
JsonParserObject *jpo = gv->jo;
|
JsonParserObject *jpo = gv->jo;
|
||||||
char jvname[64];
|
char jvname[64];
|
||||||
strcpy(jvname, vname);
|
strcpy(jvname, vname);
|
||||||
|
@ -2404,6 +2427,7 @@ chknext:
|
||||||
rstring[0] = 0;
|
rstring[0] = 0;
|
||||||
int8_t index = fvar;
|
int8_t index = fvar;
|
||||||
char *wd = ResponseData();
|
char *wd = ResponseData();
|
||||||
|
|
||||||
strlcpy(rstring, wd, glob_script_mem.max_ssize);
|
strlcpy(rstring, wd, glob_script_mem.max_ssize);
|
||||||
if (index) {
|
if (index) {
|
||||||
if (strlen(wd) && index) {
|
if (strlen(wd) && index) {
|
||||||
|
@ -2550,12 +2574,11 @@ chknext:
|
||||||
if (!TasmotaGlobal.global_state.wifi_down) {
|
if (!TasmotaGlobal.global_state.wifi_down) {
|
||||||
// erase nvs
|
// erase nvs
|
||||||
lp = GetNumericArgument(lp + 4, OPER_EQU, &fvar, gv);
|
lp = GetNumericArgument(lp + 4, OPER_EQU, &fvar, gv);
|
||||||
|
int32_t sel = fvar;
|
||||||
homekit_main(0, fvar);
|
fvar = homekit_main(0, sel);
|
||||||
if (fvar >= 98) {
|
if (sel >= 98) {
|
||||||
glob_script_mem.homekit_running == false;
|
glob_script_mem.homekit_running == false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
lp++;
|
lp++;
|
||||||
len = 0;
|
len = 0;
|
||||||
|
@ -6515,6 +6538,10 @@ char buff[512];
|
||||||
|
|
||||||
if (sflg) {
|
if (sflg) {
|
||||||
#ifdef USE_DISPLAY_DUMP
|
#ifdef USE_DISPLAY_DUMP
|
||||||
|
|
||||||
|
#include <renderer.h>
|
||||||
|
extern Renderer *renderer;
|
||||||
|
|
||||||
// screen copy
|
// screen copy
|
||||||
#define fileHeaderSize 14
|
#define fileHeaderSize 14
|
||||||
#define infoHeaderSize 40
|
#define infoHeaderSize 40
|
||||||
|
@ -7691,7 +7718,6 @@ uint32_t scripter_create_task(uint32_t num, uint32_t time, uint32_t core, uint32
|
||||||
#endif // USE_SCRIPT_TASK
|
#endif // USE_SCRIPT_TASK
|
||||||
#endif // ESP32
|
#endif // ESP32
|
||||||
|
|
||||||
|
|
||||||
int32_t http_req(char *host, char *request) {
|
int32_t http_req(char *host, char *request) {
|
||||||
WiFiClient http_client;
|
WiFiClient http_client;
|
||||||
HTTPClient http;
|
HTTPClient http;
|
||||||
|
@ -7706,6 +7732,10 @@ int32_t http_req(char *host, char *request) {
|
||||||
request++;
|
request++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HTTP_DEBUG
|
||||||
|
AddLog(LOG_LEVEL_INFO, PSTR("HTTP heap %d"), ESP_getFreeHeap());
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!mode) {
|
if (!mode) {
|
||||||
// GET
|
// GET
|
||||||
strcat(hbuff, request);
|
strcat(hbuff, request);
|
||||||
|
@ -7720,13 +7750,23 @@ int32_t http_req(char *host, char *request) {
|
||||||
httpCode = http.POST(request);
|
httpCode = http.POST(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HTTP_DEBUG
|
||||||
|
AddLog(LOG_LEVEL_INFO, PSTR("HTTP RESULT %s"), http.getString().c_str());
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef USE_WEBSEND_RESPONSE
|
#ifdef USE_WEBSEND_RESPONSE
|
||||||
#ifdef MQTT_DATA_STRING
|
#ifdef MQTT_DATA_STRING
|
||||||
TasmotaGlobal.mqtt_data = http.getString();
|
TasmotaGlobal.mqtt_data = http.getString();
|
||||||
#else
|
#else
|
||||||
strlcpy(TasmotaGlobal.mqtt_data, http.getString().c_str(), ResponseSize());
|
strlcpy(TasmotaGlobal.mqtt_data, http.getString().c_str(), ResponseSize());
|
||||||
#endif
|
#endif
|
||||||
//AddLog(LOG_LEVEL_INFO, PSTR("HTTP RESULT %s"), ResponseData());
|
|
||||||
|
#ifdef HTTP_DEBUG
|
||||||
|
AddLog(LOG_LEVEL_INFO, PSTR("HTTP MQTT BUFFER %s"), ResponseData());
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// AddLog(LOG_LEVEL_INFO, PSTR("JSON %s"), wd_jstr);
|
||||||
|
// TasmotaGlobal.mqtt_data = wd_jstr;
|
||||||
Run_Scripter(">E", 2, ResponseData());
|
Run_Scripter(">E", 2, ResponseData());
|
||||||
|
|
||||||
glob_script_mem.glob_error = 0;
|
glob_script_mem.glob_error = 0;
|
||||||
|
@ -7746,10 +7786,21 @@ int32_t http_req(char *host, char *request) {
|
||||||
#include <WiFiClientSecure.h>
|
#include <WiFiClientSecure.h>
|
||||||
#endif //ESP8266
|
#endif //ESP8266
|
||||||
|
|
||||||
|
#ifdef TESLA_POWERWALL
|
||||||
|
Powerwall powerwall = Powerwall();
|
||||||
|
String authCookie = "";
|
||||||
|
#endif
|
||||||
|
|
||||||
// get tesla powerwall info page json string
|
// get tesla powerwall info page json string
|
||||||
uint32_t call2https(const char *host, const char *path) {
|
uint32_t call2https(const char *host, const char *path) {
|
||||||
if (TasmotaGlobal.global_state.wifi_down) return 1;
|
if (TasmotaGlobal.global_state.wifi_down) return 1;
|
||||||
uint32_t status = 0;
|
uint32_t status = 0;
|
||||||
|
|
||||||
|
#ifdef TESLA_POWERWALL
|
||||||
|
authCookie = powerwall.getAuthCookie();
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
WiFiClientSecure *httpsClient;
|
WiFiClientSecure *httpsClient;
|
||||||
httpsClient = new WiFiClientSecure;
|
httpsClient = new WiFiClientSecure;
|
||||||
|
|
Loading…
Reference in New Issue