@@ -55,7 +55,7 @@ char force_pwr_decimals[6] = "true"; // to fix Marstek bug
5555bool forcePwrDecimals = true ; // to fix Marstek bug
5656char sma_id[17 ] = " " ;
5757
58- char tibber_url [32 ] = " http:// 192.168.2.87 " ; // replace with your IP from Tibber-Pulse
58+ char tibber_url [32 ] = " 192.168.2.xx " ; // replace with your IP from Tibber-Pulse
5959char tibber_user[32 ] = " admin" ; // fixed!
6060char tibber_password[32 ] = " xxxx-xxxx" ; // replace with password printed on Tibbel-Pulse-Adapter
6161char tibber_rpc[32 ] = " /data.json?node_id=1" ; // fixed!
@@ -163,10 +163,10 @@ JsonVariant resolveJsonPath(JsonVariant variant, const char *path) {
163163void setPowerData (double totalPower) {
164164 for (int i = 0 ; i <= 2 ; i++) {
165165 PhasePower[i].power = round2 (totalPower * 0.3333 );
166- PhasePower[i].voltage = defaultVoltage;
166+ PhasePower[i].voltage = round2 ( defaultVoltage) ;
167167 PhasePower[i].current = round2 (PhasePower[i].power / PhasePower[i].voltage );
168168 PhasePower[i].apparentPower = round2 (PhasePower[i].power );
169- PhasePower[i].powerFactor = defaultPowerFactor;
169+ PhasePower[i].powerFactor = round2 ( defaultPowerFactor) ;
170170 PhasePower[i].frequency = defaultFrequency;
171171 }
172172 DEBUG_SERIAL .print (" Current total power: " );
@@ -178,10 +178,10 @@ void setPowerData(double phase1Power, double phase2Power, double phase3Power) {
178178 PhasePower[1 ].power = round2 (phase2Power);
179179 PhasePower[2 ].power = round2 (phase3Power);
180180 for (int i = 0 ; i <= 2 ; i++) {
181- PhasePower[i].voltage = defaultVoltage;
181+ PhasePower[i].voltage = round2 ( defaultVoltage);
182182 PhasePower[i].current = round2 (PhasePower[i].power / PhasePower[i].voltage );
183183 PhasePower[i].apparentPower = round2 (PhasePower[i].power );
184- PhasePower[i].powerFactor = defaultPowerFactor;
184+ PhasePower[i].powerFactor = round2 ( defaultPowerFactor) ;
185185 PhasePower[i].frequency = defaultFrequency;
186186 }
187187 DEBUG_SERIAL .print (" Current power L1: " );
@@ -783,7 +783,7 @@ bool decodeSMLval(uint32_t &retval, byte * payload, byte* smlcode, uint smlsize,
783783
784784 if ((nlen < 1 ) ||(nlen > 8 ))
785785 {
786- DEBUG_SERIAL .printf (" decodeSMLval unvalid length & d\r\n " , nlen);
786+ DEBUG_SERIAL .printf (" decodeSMLval unvalid length % d\r\n " , nlen);
787787 return false ;
788788 }
789789
@@ -815,7 +815,8 @@ bool queryTibberPulseHTTP() {
815815 bool ret = true ;
816816 int getlength = 0 ;
817817 DEBUG_SERIAL .print (" Querying Tibber-Pulse raw SML: " );
818- String url = String (tibber_url);
818+ String url = " http://" ;
819+ url += String (tibber_url);
819820 url += String (tibber_rpc);
820821 // DEBUG_SERIAL.printf("Tibber URL:%s user:%s \r\n", url.c_str(), tibber_user);
821822 http.begin (wifi_client, url);
@@ -902,7 +903,6 @@ bool queryTibberPulseHTTP() {
902903 return ret;
903904}
904905
905-
906906void WifiManagerSetup () {
907907 // Set Shelly ID to ESP's MAC address by default
908908 uint8_t mac[6 ];
@@ -941,7 +941,7 @@ void WifiManagerSetup() {
941941
942942 WiFiManagerParameter custom_mqtt_server (" server" , " <b>Server</b><br>MQTT Server IP, query url for generic HTTP or Modbus TCP server IP for SUNSPEC" , mqtt_server, 80 );
943943 WiFiManagerParameter custom_mqtt_port (" port" , " <b>Port</b><br> for MQTT or Modbus TCP (SUNSPEC)" , mqtt_port, 6 );
944- WiFiManagerParameter custom_query_period (" query_period" , " <b>Query period</b><br>for generic HTTP and SUNSPEC , in milliseconds" , query_period, 10 );
944+ WiFiManagerParameter custom_query_period (" query_period" , " <b>Query period</b><br>for generic HTTP, SUNSPEC and TIBBERPULSE , in milliseconds" , query_period, 10 );
945945 WiFiManagerParameter custom_led_gpio (" led_gpio" , " <b>GPIO</b><br>of internal LED" , led_gpio, 3 );
946946 WiFiManagerParameter custom_led_gpio_i (" led_gpio_i" , " <b>GPIO is inverted</b><br><code>true</code> or <code>false</code>" , led_gpio_i, 6 );
947947 WiFiManagerParameter custom_shelly_mac (" mac" , " <b>Shelly ID</b><br>12 char hexadecimal, defaults to MAC address of ESP" , shelly_mac, 13 );
@@ -964,9 +964,9 @@ void WifiManagerSetup() {
964964 WiFiManagerParameter custom_energy_out_path (" energy_out_path" , " <b>Energy to grid JSON path</b><br>e.g. <code>ENERGY.FeedIn</code>" , energy_out_path, 60 );
965965 // for Tibber-Pulse
966966 WiFiManagerParameter custom_section5 (" <hr><h3>Tibber-Pulse</h3>" );
967- WiFiManagerParameter custom_tibber_url (" url" , " <b>url</b><br>e.g.:<code>http:// 192.168.xx.xx</code>" , tibber_url, 32 );
968- WiFiManagerParameter custom_tibber_user (" tibber_user" , " <b>user</b><br><code>admin</code>" , tibber_user, 32 );
969- WiFiManagerParameter custom_tibber_password (" tibber_password" , " <b>password</b><br>form:<code>xxxx-xxxx</code>" , tibber_password, 32 );
967+ WiFiManagerParameter custom_tibber_url (" url" , " <b>url</b><br>e.g.:<code>192.168.xx.xx</code>" , tibber_url, 32 );
968+ WiFiManagerParameter custom_tibber_user (" tibber_user" , " <b>user</b><br><code>admin</code>" , tibber_user, 32 );
969+ WiFiManagerParameter custom_tibber_password (" tibber_password" , " <b>password</b><br>form:<code>xxxx-xxxx</code>" ,tibber_password, 32 );
970970
971971 WiFiManager wifiManager;
972972 if (!DEBUG ) {
@@ -1202,7 +1202,9 @@ void setup(void) {
12021202 webSocket.onEvent (webSocketEvent);
12031203 server.addHandler (&webSocket);
12041204 server.begin ();
1205-
1205+ #ifdef ESP32
1206+ http.setConnectTimeout (500 ); // if url not found or down
1207+ #endif
12061208 // Set up RPC over UDP for Marstek users
12071209 UdpRPC.begin (String (shelly_port).toInt ());
12081210
0 commit comments