thank you for your analysis.
it's a bit painful this MQTT overflow story !
We'll wait for n update and see if it gets better!
thank you for your analysis.
it's a bit painful this MQTT overflow story !
We'll wait for n update and see if it gets better!
Hi,
I restart to dev my Shelly script to manage my pool pump with new version of firmware 1.0.3.
I wouldike know how the MQTT queue is managed because I don't have some information on my mqtt broker ( mosquito) without stop/crash of the script and have many log with :
I make some test with MQTT.publish, and it seems that the limit is 20 in loop "for" before MQTT queue overflow log.
Do you have some informations about that ?
I don't use 20 MQTT.publish on my script, so i imagine that the queue is related to anything ? number of call ? size of the call ? ...
The MQTT queue managment has changed since firmware 0.14 ?
You can use this URL to reduce your code lenght:
it's very efficient en reduce the code /3.
Tx for your reply, I know but I prefer read my code and all commenst in order to debug
Hi, I used shelly script to control my pool pump with temperature.
I started to make this script with 0.12 firmware version and not i'm with 0.14.
With new version 1.0.3, the script must be less than 15000 bits !!! can you update this limit ?, my script is 30kbit.
I would like update my script in order to use shelly addon to plu température sensor, but i can't improve or just commit my script with this limit.
Hi all,
I use my own DHCP server, and I had configured option 42 to provide NTP server. It seems that shelly device ( 1 or plus 1) don't use this, and keep time .google.com.
Do you have some informations about that ? This can be implement in orter to facilitate deployment ?
(I think that it doesn'use also option 7 of DHPC to provide syslog server..)
you should look on log of shelly, configure your log on Device->Debug.
you can see log of your script but also log of shelly and why it is stopping.
Hi,
I have a big script, which run correctly one shelly is booted.
But I Tested the script on reboot and it craches.
After some investigation it seems, tha is sntp.
I use Shelly.getComponentStatus("sys"); and return me an null on boot:
2022-09-13,09:32:35,Notice,pc-149.home,user,shellyplus1-441793a56dd4,110 2.323 2 0|Subscription callback error: type error
2022-09-13,09:32:35,Notice,pc-149.home,user,shellyplus1-441793a56dd4,109 2.318 2 0| at script_3.js:225
2022-09-13,09:32:35,Notice,pc-149.home,user,shellyplus1-441793a56dd4,108 2.314 2 0| at script_3.js:774
2022-09-13,09:32:35,Notice,pc-149.home,user,shellyplus1-441793a56dd4,107 2.311 2 0| at script_3.js:802
2022-09-13,09:32:35,Notice,pc-149.home,user,shellyplus1-441793a56dd4,106 2.303 1 0|[POOL_] get_current_time() time: null
And hi see after that the shelly sync with SNTP server, but it should do this before:
2022-09-13,09:32:36,Notice,pc-149.home,user,shellyplus1-441793a56dd4,"120 3.073 2 2|mgos_sntp.c:64 SNTP reply from 192.168.1.101: time 1663054356.152770, local 3.151209, delta 1663054353.001561"
Here is part of my script that is very simple:
let result = Shelly.getComponentStatus("sys");
print("[POOL_] get_current_time() time:", result.time);
let time = result.time; // "HH:MM"
// compute current time in float format (12h45 -> 12.75)
let t = JSON.parse(time.slice(0,2)) + JSON.parse(time.slice(3,5)) / 60;
This call isn't the first in my script, there is many others call before, and perhaps the shelly is busy to make own call on init.
So I don't know if it's a shelly bug, or find an other solution and perhaps catch this "null" return ?
extract of complete log:
Date,Time,Level,Host Name,Category,Program,Messages,
2022-09-13,09:32:45,Notice,pc-149.home,user,shellyplus1-441793a56dd4,"134 12.440 2 2|shelly_notification:145 Status change of sys: {""available_updates"":{}}"
2022-09-13,09:32:45,Notice,pc-149.home,user,shellyplus1-441793a56dd4,133 12.427 2 2|shelly_http.cpp:68 0x3ffd5704 HTTP got 200 OK and 2 byte response
2022-09-13,09:32:43,Notice,pc-149.home,user,shellyplus1-441793a56dd4,132 10.768 2 2|shelly_http.cpp:184 0x3ffd5704 HTTPS GET https://updates.shelly.cloud/update/Plus1 (SSL CA shelly_cloud.pem)
2022-09-13,09:32:43,Notice,pc-149.home,user,shellyplus1-441793a56dd4,131 10.749 2 2|shelly_update.cpp:170 Checking for updates.
2022-09-13,09:32:39,Notice,pc-149.home,user,shellyplus1-441793a56dd4,130 6.789 2 2|mg_rpc.c:314 shelly.getstatus via WS_in 192.168.1.44:56961
2022-09-13,09:32:38,Notice,pc-149.home,user,shellyplus1-441793a56dd4,129 5.891 2 2|mg_rpc.c:314 shelly.getconfig via WS_in 192.168.1.44:56961
2022-09-13,09:32:37,Notice,pc-149.home,user,shellyplus1-441793a56dd4,128 4.802 2 2|mg_rpc.c:314 shelly.getdeviceinfo via WS_in 192.168.1.44:56961
2022-09-13,09:32:37,Notice,pc-149.home,user,shellyplus1-441793a56dd4,127 4.642 2 2|mg_rpc.c:314 Shelly.GetStatus via SHC 35.233.16.150:6022
2022-09-13,09:32:37,Notice,pc-149.home,user,shellyplus1-441793a56dd4,126 4.511 2 1|shelly_notification:101 ch type=WS_in info=192.168.1.44:56961 has no DST
2022-09-13,09:32:37,Notice,pc-149.home,user,shellyplus1-441793a56dd4,"125 4.501 2 2|shelly_notification:145 Status change of cloud: {""connected"":true}"
2022-09-13,09:32:37,Notice,pc-149.home,user,shellyplus1-441793a56dd4,124 4.478 2 2|mg_rpc.c:314 Shelly.GetConfig via SHC 35.233.16.150:6022
2022-09-13,09:32:37,Notice,pc-149.home,user,shellyplus1-441793a56dd4,123 4.462 2 2|shelly_cloud.cpp:165 shelly cloud is online
2022-09-13,09:32:37,Notice,pc-149.home,user,shellyplus1-441793a56dd4,122 4.455 2 2|mgos_rpc_channel_ws.:54 0x3ffd309c WS handshake resp 101
2022-09-13,09:32:36,Notice,pc-149.home,user,shellyplus1-441793a56dd4,121 3.871 2 2|mgos_http_server.c:180 0x3ffd6da8 HTTP connection from 192.168.1.44:56961
2022-09-13,09:32:36,Notice,pc-149.home,user,shellyplus1-441793a56dd4,"120 3.073 2 2|mgos_sntp.c:64 SNTP reply from 192.168.1.101: time 1663054356.152770, local 3.151209, delta 1663054353.001561"
2022-09-13,09:32:36,Notice,pc-149.home,user,shellyplus1-441793a56dd4,"119 3.047 2 2|shelly_notification:145 Status change of script:3: {""id"":3,""errors"":[""type_error""],""running"":false}"
2022-09-13,09:32:35,Notice,pc-149.home,user,shellyplus1-441793a56dd4,118 2.385 2 2|shelly_mqtt_script_:117 MQTT unsubscribed ha/pool
2022-09-13,09:32:35,Notice,pc-149.home,user,shellyplus1-441793a56dd4,117 2.379 2 2|mgos_mqtt_conn.c:624 MQTT0 unsub ha/pool
2022-09-13,09:32:35,Notice,pc-149.home,user,shellyplus1-441793a56dd4,116 2.373 2 2|shelly_mqtt_script_:117 MQTT unsubscribed shellyplus1-441793a56dd4/number/cmd
2022-09-13,09:32:35,Notice,pc-149.home,user,shellyplus1-441793a56dd4,115 2.364 2 2|mgos_mqtt_conn.c:624 MQTT0 unsub shellyplus1-441793a56dd4/number/cmd
2022-09-13,09:32:35,Notice,pc-149.home,user,shellyplus1-441793a56dd4,114 2.355 2 2|shelly_mqtt_script_:117 MQTT unsubscribed shellyplus1-441793a56dd4/select/cmd
2022-09-13,09:32:35,Notice,pc-149.home,user,shellyplus1-441793a56dd4,113 2.346 2 2|mgos_mqtt_conn.c:624 MQTT0 unsub shellyplus1-441793a56dd4/select/cmd
2022-09-13,09:32:35,Notice,pc-149.home,user,shellyplus1-441793a56dd4,112 2.337 2 2|shelly_timer_script_:73 JS_Timer 0x3ffde47c is gone
2022-09-13,09:32:35,Notice,pc-149.home,user,shellyplus1-441793a56dd4,111 2.330 2 2|shelly_timer_script_:73 JS_Timer 0x3ffd6794 is gone
2022-09-13,09:32:35,Notice,pc-149.home,user,shellyplus1-441793a56dd4,110 2.323 2 0|Subscription callback error: type error
2022-09-13,09:32:35,Notice,pc-149.home,user,shellyplus1-441793a56dd4,109 2.318 2 0| at script_3.js:225
2022-09-13,09:32:35,Notice,pc-149.home,user,shellyplus1-441793a56dd4,108 2.314 2 0| at script_3.js:774
2022-09-13,09:32:35,Notice,pc-149.home,user,shellyplus1-441793a56dd4,107 2.311 2 0| at script_3.js:802
2022-09-13,09:32:35,Notice,pc-149.home,user,shellyplus1-441793a56dd4,106 2.303 1 0|[POOL_] get_current_time() time: null
2022-09-13,09:32:35,Notice,pc-149.home,user,shellyplus1-441793a56dd4,105 2.292 1 0|[POOL] update_temp - update_temp_max: 0 update_temp_max_last: 0 temp_ext: 0
2022-09-13,09:32:35,Notice,pc-149.home,user,shellyplus1-441793a56dd4,104 2.281 1 0|[POOL] update_temp - max today: 0 today: 0 yesterday: 0
2022-09-13,09:32:35,Notice,pc-149.home,user,shellyplus1-441793a56dd4,103 2.268 1 0|[POOL] update_temp() lock_update => true
2022-09-13,09:32:35,Notice,pc-149.home,user,shellyplus1-441793a56dd4,102 2.260 1 0|[POOL_DISABLE_TEMP] disable_temp null true
2022-09-13,09:32:35,Notice,pc-149.home,user,shellyplus1-441793a56dd4,101 2.253 1 0|[POOL] update_temp 1 0
2022-09-13,09:32:35,Notice,pc-149.home,user,shellyplus1-441793a56dd4,100 2.246 1 0|[MQTT-SELECT] AUTO Auto
2022-09-13,09:32:35,Notice,pc-149.home,user,shellyplus1-441793a56dd4,99 2.239 1 0|[MQTT] listen SELECT Auto
2022-09-13,09:32:35,Notice,pc-149.home,user,shellyplus1-441793a56dd4,"98 2.068 2 2|shelly_notification:145 Status change of mqtt: {""connected"":true}"
2022-09-13,09:32:34,Notice,pc-149.home,user,shellyplus1-441793a56dd4,97 2.051 2 2|mgos_mqtt_conn.c:169 MQTT0 sub shellyplus1-441793a56dd4/rpc @ 1
2022-09-13,09:32:34,Notice,pc-149.home,user,shellyplus1-441793a56dd4,96 2.043 2 2|mgos_mqtt_conn.c:169 MQTT0 sub ha/pool @ 1
2022-09-13,09:32:34,Notice,pc-149.home,user,shellyplus1-441793a56dd4,95 2.036 2 2|mgos_mqtt_conn.c:169 MQTT0 sub shellyplus1-441793a56dd4/number/cmd @ 1
2022-09-13,09:32:34,Notice,pc-149.home,user,shellyplus1-441793a56dd4,94 2.027 2 2|mgos_mqtt_conn.c:169 MQTT0 sub shellyplus1-441793a56dd4/select/cmd @ 1
2022-09-13,09:32:34,Notice,pc-149.home,user,shellyplus1-441793a56dd4,93 2.018 2 2|mgos_mqtt_conn.c:242 MQTT0 CONNACK 0
2022-09-13,09:32:34,Notice,pc-149.home,user,shellyplus1-441793a56dd4,92 2.004 2 2|mgos_mqtt_conn.c:189 MQTT0 TCP connected ok (0)
2022-09-13,09:32:34,Notice,pc-149.home,user,shellyplus1-441793a56dd4,91 1.995 2 2|mgos_mdns.c:143 Listening on udp://:5353... 0x3ffdec08
2022-09-13,09:32:34,Notice,pc-149.home,user,shellyplus1-441793a56dd4,90 1.983 2 2|mgos_mqtt_conn.c:442 MQTT0 connecting to 192.168.1.105:1883
2022-09-13,09:32:34,Notice,pc-149.home,user,shellyplus1-441793a56dd4,"89 1.975 2 2|mgos_net.c:104 WiFi STA: ready, IP 192.168.1.55, GW 192.168.1.1, DNS 8.8.8.8, NTP 192.168.1.101"
2022-09-13,09:32:34,Notice,pc-149.home,user,shellyplus1-441793a56dd4,88 1.963 2 2|mgos_net.c:93 WiFi STA: connected
2022-09-13,09:32:34,Notice,pc-149.home,user,shellyplus1-441793a56dd4,"87 1.953 2 2|shelly_notification:145 Status change of wifi: {""rssi"":-77,""ssid"":""isynet"",""sta_ip"":""192.168.1.55"",""status"":""got ip""}"
2022-09-13,09:32:34,Notice,pc-149.home,user,shellyplus1-441793a56dd4,"86 1.932 2 2|shelly_notification:145 Status change of wifi: {""rssi"":-77,""ssid"":""isynet"",""sta_ip"":""192.168.1.55"",""status"":""connected""}"
2022-09-13,09:32:34,Notice,pc-149.home,user,shellyplus1-441793a56dd4,85 1.912 2 2|shelly_wifi.cpp:395 Shelly Wifi IP acquired
2022-09-13,09:32:34,Notice,pc-149.home,user,shellyplus1-441793a56dd4,84 1.904 2 2|shelly_wifi.cpp:374 Shelly Wifi Connected
2022-09-13,09:32:34,Notice,pc-149.home,user,shellyplus1-441793a56dd4,"83 1.898 2 2|mgos_wifi.c:86 WiFi STA: Connected, BSSID 26:5a:4c:1f:19:19 ch 1 RSSI -77"
2022-09-13,09:32:34,Notice,pc-149.home,user,shellyplus1-441793a56dd4,82 1.888 2 2|mgos_net.c:89 WiFi STA: connecting
2022-09-13,09:32:34,Notice,pc-149.home,user,shellyplus1-441793a56dd4,"81 1.878 2 2|shelly_notification:145 Status change of wifi: {""rssi"":-77,""ssid"":null,""sta_ip"":null,""status"":""connecting""}"
2022-09-13,09:32:34,Notice,pc-149.home,user,shellyplus1-441793a56dd4,80 1.780 2 2|shelly_mqtt_script_:112 MQTT subscribed to shellyplus1-441793a56dd4/select/cmd
2022-09-13,09:32:34,Notice,pc-149.home,user,shellyplus1-441793a56dd4,"79 1.735 2 2|I (2493) wifi:AP's beacon interval = 102400 us, DTIM period = 1"
2022-09-13,09:32:34,Notice,pc-149.home,user,shellyplus1-441793a56dd4,"78 1.723 2 2|[0;32mI (2483) esp_netif_handlers: sta ip: 192.168.1.55, mask: 255.255.255.0, gw: 192.168.1.1[0m"
2022-09-13,09:32:32,Notice,pc-149.home,user,shellyplus1-441793a56dd4,"344 207.869 2 2|shelly_notification:145 Status change of mqtt: {""connected"":false}"
2022-09-13,09:32:32,Notice,pc-149.home,user,shellyplus1-441793a56dd4,"343 207.854 2 2|shelly_notification:145 Status change of cloud: {""connected"":false}"
2022-09-13,09:32:32,Notice,pc-149.home,user,shellyplus1-441793a56dd4,342 207.840 2 2|mgos_mqtt_conn.c:221 MQTT0 disconnected
2022-09-13,09:32:31,Notice,pc-149.home,user,shellyplus1-441793a56dd4,341 207.832 2 2|shelly_cloud.cpp:182 shelly cloud is down
2022-09-13,09:32:31,Notice,pc-149.home,user,shellyplus1-441793a56dd4,340 207.818 2 2|mgos_mqtt_conn.c:469 MQTT0 disconnect
2022-09-13,09:32:31,Notice,pc-149.home,user,shellyplus1-441793a56dd4,339 207.013 2 2|mgos_system.c:58 Rebooting in 1000 ms
2022-09-13,09:32:31,Notice,pc-149.home,user,shellyplus1-441793a56dd4,338 207.006 2 2|mg_rpc.c:314 shelly.reboot via WS_in 192.168.1.44:51862
Alles anzeigen
Hi, Ho good thing !.
Me, I abandonnate this idea because of two things:
* and limit of 5 RPC call on shelly script
Like call are async, it's difficult to manage this for me.
So I rewrite some part of your script to use some synchronous call, and add features.
Can I have the screenshot?
this is my test script ( with fake token of course )
let token = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc5MiOiIxDFKQZGMyZWY4OTI0MTU0YmY4ZDU3JKLkODg5NmFmNCIsImlhdCI6MTY2MTg5MjQ1MywiZXhwIjoxOTc3MjUyNDUzfQ.6bM9doaC1rSQs-ZRwTbXE5IBoxvRDTQ6izGh1O8ZYZQ";
let h = {
method: "GET",
url: "http://192.168.1.105:8123/api/states/sun.sun",
headers : {
Authorization: token,
'Content-Type': "application/json",
},
timeout: 4,
};
print(h.headers["Content-Type"]);
print("LENGTH", token.length );
Shelly.call("HTTP.Request", h, function (result,error_code,error_message) {
print(result);
print(error_code);
print(error_message);
});
Alles anzeigen
And this, the log of shelly:
shelly_user_script.:365 mJS RAM stat: initial: 151880 after: 146652, used: 522810:29:29.414
shelly_user_script.:403 Running 'script_5.js'...10:29:29.421
application/json 10:29:29.435
LENGTH 190 10:29:29.437
shelly_user_script.:375 mJS RAM stat: after user code: 151880 after: 143560, used: 832010:29:29.453
shelly_notification:145 Status change of script:5: {"id":5,"running":true}10:29:29.466
mg_rpc.c:314 HTTP.Request via loopback 10:29:29.489
mgos_mongoose.c:66 New heap free LWM: 12604410:29:29.505
null 10:29:29.512
-103 10:29:29.514
Invalid argument 'headers': length should be less than 128! 10:29:29.522
mg_rpc.c:314 script.list via WS_in 192.168.1.44:63867
Alles anzeigen
Hi,
I try to make an HTTP.Request on my Home Assistant server, but after some times, I found my problem:
Invalid argument 'headers': length should be less than 128!
Because the generate token is very long !
token.length ==>> 191
Do you see a solution for this ? because I think that other application can have very long token.
Thankyou
Excellent !
Thanks for sharing, the HA integration looks great !
Yes i'm working to include HA autodiscovery and create sensor and control in specific branch
Thank you for your complete response, it's very important to know limitation cycles :-). I will study all your response to my projet thank you very much
Ok thanks for your reply, I understand the need about async result.
I will think about it, because timer seems to be a "crapy fix". perhaps move the code into response, but I wouldlike get the value to use it into another function.. so I will think about.
if a function require many KVS values, is very complicated to make clean code into response function....
there is a solution to be notify when response is done ?
ARG, thank you, I suspected this...
Do you know if there is plan to make this call synchron like some other call ?
Hi,
I test the last beta (0.11beta3) on shelly 1 plus.
For one of my project I test the new KVS and I don't understand why my var "out_the_call" is undefined in my log:
mg_rpc.c:314 script.setconfig via WS_in 192.168.1.44:5051117:16:06.390
mg_rpc.c:314 script.putcode via WS_in 192.168.1.44:5051117:16:06.678
mg_rpc.c:314 script.start via WS_in 192.168.1.44:5051117:16:06.952
shelly_user_script.:403 Running 'api_math.js'...17:16:06.976
shelly_user_script.:403 Running 'init.js'...17:16:07.700
shelly_user_script.:365 mJS RAM stat: initial: 159796 after: 154808, used: 498817:16:07.180
shelly_user_script.:403 Running 'script_3.js'...17:16:07.250
[TEST] start 17:16:07.330
[TEST] out_the_call: undefined 17:16:07.490
shelly_user_script.:375 mJS RAM stat: after user code: 159796 after: 152804, used: 699217:16:07.580
shelly_notification:145 Status change of script:3: {"id":3,"running":true}17:16:07.690
mg_rpc.c:314 KVS.Set via loopback 17:16:07.860
mg_rpc.c:314 KVS.get via loopback 17:16:07.174
shelly_notification:145 Status change of sys: {"kvs_rev":34}17:16:07.183
[POOL] INTHE CALL: 13 17:16:07.206
mg_rpc.c:314 script.list via WS_in 192.168.1.44:5051117:16:07.292
mg_rpc.c:314 KVS.List via WS_in 192.168.1.44:50511
Alles anzeigen
My code:
print("[TEST] start");
let out_the_call;
function kvsSet(key, value){
Shelly.call(
"KVS.Set",
{"key":key, "value":value}
);
}
function kvsGet(key){
Shelly.call(
"KVS.get",
{"key":key},
function (result) {
print("[POOL] INTHE CALL:",result.value);
out_the_call = result.value;
}
);
}
kvsSet("temp","13");
kvsGet("temp");
print("[TEST] out_the_call:",out_the_call);
Alles anzeigen
If you have one idea please
Thank you.
And I wait also Shelly plus addon to add temperature sensor with shelly plus and make autonomous system
Hi ggilles ,
I modify your script for my usage here, thank you very much:
I wait stable version of firmware to use KVS
Thank you very much I will study this
Hi Gilles, sorry but I don't have solution for you... BUT, can you share your shelly script ? I wouldlike implement this with my pool pump