Beiträge von valdus
-
-
For a start...THANK YOU!
But, it has a problem.
First from a fully closed position I'm just opening it and I get these two messages:
shellyplus2pm-5443b23eae68/cover:0/event
shellyplus2pm-5443b23eae68/cover:0/position
Now I just close it and I get flooded with below:
shellyplus2pm-5443b23eae68/cover:0/shellyplus2pm-5443b23eae68/cover:0/shellyplus2pm-5443b23eae68/cover:0/shellyplus2pm-5443b23eae68/cover:0/shellyplus2pm-5443b23eae68/cover:0/event
with a value of closing
If I open it again all the above take a value closed. If I stop it midway they get the value of open.
The first two messages always get the correct values but all the other messages should not be there...
Just an observation not for you but for shelly. Isn't it too much all this scripting for such a simple task?
I'm used from tasmota where the same is just 6 words with a rule :
ON shutter1#position do publish helloworld/position %value% endon
I could not imagine that such a simple task would take you writing down all this code for me...I'm feeling bad...sorry and thank you again.
-
OK, there you have it...
Code
Alles anzeigenConsole Full log Script working... shelly_user_script.:338 JS RAM stat: after user code: 126988 after: 124896, used: 2092 shelly_notification:163 Status change of script:1: {"id":1,"running":true} shos_rpc_inst.c:230 script.getcode via WS_in 192.168.0.102:53204 shelly_scripts_rpc.:351 Sending "script_1.js" shos_rpc_inst.c:230 script.getcode via WS_in 192.168.0.102:53204 shelly_notification:163 Status change of cover:0: {"id":0,"apower":58.6} shelly_notification:163 Status change of cover:0: {"id":0,"apower":119.8} Deteced opening, Cover: cover:0 shelly_notification:163 Status change of cover:0: {"id":0,"last_direction":"open","move_started_at":1695669283.80,"move_timeout":60.00,"source":"http","state":"opening"} shelly_http_client.:606 0x3ffe1314: Finished; bytes 887, code 200, redir 0/3, auth 0, status OK shelly_notification:163 Status change of cover:0: {"id":0,"apower":126.1} shelly_notification:163 Status change of cover:0: {"id":0,"aenergy":{"by_minute":[592.909,0.000,809.567],"minute_ts":1695669299,"total":34.205}} shelly_notification:163 Status change of cover:0: {"id":0,"apower":105.9} shelly_notification:163 Status change of cover:0: {"id":0,"apower":9.6} shelly_notification:163 Status change of cover:0: {"id":0,"apower":3.8} shelly_notification:163 Status change of cover:0: {"id":0,"apower":0.0} Deteced fully open, Cover: cover:0 shelly_notification:163 Status change of cover:0: {"id":0,"apower":0,"current":0,"current_pos":100,"move_started_at":null,"move_timeout":null,"pf":0,"source":"limit_switch","state":"open"} shelly_notification:163 Status change of cover:0: {"id":0,"apower":7.0} shelly_notification:163 Status change of cover:0: {"id":0,"apower":113.2} Deteced closing, Cover: cover:0 shelly_notification:163 Status change of cover:0: {"id":0,"last_direction":"close","move_started_at":1695669335.43,"move_timeout":60.00,"source":"http","state":"closing"} shelly_notification:163 Status change of cover:0: {"id":0,"apower":122.1} shelly_notification:163 Status change of cover:0: {"id":0,"apower":108.9} shelly_notification:163 Status change of cover:0: {"id":0,"apower":10.3} shelly_notification:163 Status change of cover:0: {"id":0,"apower":4.0} shelly_notification:163 Status change of cover:0: {"id":0,"apower":0.0} Hmm it called closed not close... cover:0 shelly_notification:163 Status change of cover:0: {"id":0,"apower":0,"current":0,"current_pos":0,"move_started_at":null,"move_timeout":null,"pf":0,"source":"limit_switch","state":"closed"} shelly_http_client.:606 0x3ffe1314: Finished; bytes 883, code 200, redir 0/3, auth 0, status OK shelly_notification:163 Status change of cover:0: {"id":0,"aenergy":{"by_minute":[1177.276,592.909,0.000],"minute_ts":1695669359,"total":35.383}} 22:16:00 ›_ ↵ Shelly Plus2PM 5443B23EAE68| 1.0.3| aecad392| 22:16:16
-
OK, here are the debug results, first stopped and then opened :
Code
Alles anzeigenConsole Full log Debug: EventData-> { "component": "cover:0", "name": "cover", "id": 0, "now": 1695649338.09716486930, "info": { "component": "cover:0", "id": 0, "event": "power_update", "apower": 40.2, "ts": 1695649338.09999990463 } } Debug: Result-> { "id": 0 } shelly_notification:163 Status change of cover:0: {"id":0,"apower":40.2} Debug: EventData-> { "component": "cover:0", "name": "cover", "id": 0, "now": 1695649338.09732675552, "info": { "component": "cover:0", "id": 0, "event": "current_update", "current": 0.5, "ts": 1695649338.09999990463 } } Debug: Result-> { "id": 0 } shos_init.c:81 New min heap free: 117644 shos_init.c:81 New min heap free: 115544 Debug: EventData-> { "component": "cover:0", "name": "cover", "id": 0, "now": 1695649338.30300498008, "info": { "component": "cover:0", "id": 0, "event": "power_update", "apower": 123.5, "ts": 1695649338.29999995231 } } Debug: Result-> { "id": 0 } shelly_notification:163 Status change of cover:0: {"id":0,"apower":123.5} Debug: EventData-> { "component": "cover:0", "name": "cover", "id": 0, "now": 1695649338.30317687988, "info": { "component": "cover:0", "id": 0, "event": "current_update", "current": 0.6, "ts": 1695649338.29999995231 } } Debug: Result-> { "id": 0 } Debug: EventData-> { "component": "cover:0", "name": "cover", "id": 0, "now": 1695649338.31213307380, "info": { "component": "cover:0", "id": 0, "event": "opening", "source": "http", "ts": 1695649338.30999994277 } } Debug: Result-> { "id": 0 } shelly_notification:163 Status change of cover:0: {"id":0,"move_started_at":1695649338.31,"move_timeout":60.00,"source":"http","state":"opening"} shos_init.c:81 New min heap free: 104688 shelly_http_client.:606 0x3ffe3320: Finished; bytes 887, code 200, redir 0/3, auth 0, status OK Debug: EventData-> { "component": "cover:0", "name": "cover", "id": 0, "now": 1695649344.14790177345, "info": { "component": "cover:0", "id": 0, "event": "power_update", "apower": 92.2, "ts": 1695649344.14999985694 } } Debug: Result-> { "id": 0 } shelly_notification:163 Status change of cover:0: {"id":0,"apower":92.2} Debug: EventData-> { "component": "cover:0", "name": "cover", "id": 0, "now": 1695649344.14806175231, "info": { "component": "cover:0", "id": 0, "event": "current_update", "current": 0.4, "ts": 1695649344.14999985694 } } Debug: Result-> { "id": 0 } Debug: EventData-> { "component": "cover:0", "name": "cover", "id": 0, "now": 1695649344.34192490577, "info": { "component": "cover:0", "id": 0, "event": "power_update", "apower": 0, "ts": 1695649344.33999991416 } } Debug: Result-> { "id": 0 } shelly_notification:163 Status change of cover:0: {"id":0,"apower":0.0} Debug: EventData-> { "component": "cover:0", "name": "cover", "id": 0, "now": 1695649344.34210491180, "info": { "component": "cover:0", "id": 0, "event": "current_update", "current": 0, "ts": 1695649344.33999991416 } } Debug: Result-> { "id": 0 } Debug: EventData-> { "component": "cover:0", "name": "cover", "id": 0, "now": 1695649344.70596623420, "info": { "component": "cover:0", "id": 0, "event": "stopped", "source": "http", "ts": 1695649344.71000003814 } } Debug: Result-> { "id": 0 } shelly_notification:163 Status change of cover:0: {"id":0,"apower":0,"current":0,"current_pos":46,"move_started_at":null,"move_timeout":null,"pf":0,"source":"http","state":"stopped"} ›_ ↵ Shelly Plus2PM 5443B23EAE68| 1.0.3| aecad392| 16:42:52
Code
Alles anzeigenDebug: EventData-> { "component": "cover:0", "name": "cover", "id": 0, "now": 1695649654.19212174415, "info": { "component": "cover:0", "id": 0, "event": "power_update", "apower": 1.8, "ts": 1695649654.18999981880 } } Debug: Result-> { "id": 0 } shelly_notification:163 Status change of cover:0: {"id":0,"apower":1.8} Debug: EventData-> { "component": "cover:0", "name": "cover", "id": 0, "now": 1695649654.19227600097, "info": { "component": "cover:0", "id": 0, "event": "current_update", "current": 0.2, "ts": 1695649654.18999981880 } } Debug: Result-> { "id": 0 } Debug: EventData-> { "component": "cover:0", "name": "cover", "id": 0, "now": 1695649654.38416385650, "info": { "component": "cover:0", "id": 0, "event": "power_update", "apower": 122.4, "ts": 1695649654.37999987602 } } Debug: Result-> { "id": 0 } shelly_notification:163 Status change of cover:0: {"id":0,"apower":122.4} Debug: EventData-> { "component": "cover:0", "name": "cover", "id": 0, "now": 1695649654.38433575630, "info": { "component": "cover:0", "id": 0, "event": "current_update", "current": 0.6, "ts": 1695649654.37999987602 } } Debug: Result-> { "id": 0 } Debug: EventData-> { "component": "cover:0", "name": "cover", "id": 0, "now": 1695649654.58939290046, "info": { "component": "cover:0", "id": 0, "event": "opening", "source": "http", "ts": 1695649654.58999991416 } } Debug: Result-> { "id": 0 } shelly_notification:163 Status change of cover:0: {"id":0,"move_started_at":1695649654.59,"move_timeout":60.00,"source":"http","state":"opening"} shelly_http_client.:606 0x3ffe20ec: Finished; bytes 887, code 200, redir 0/3, auth 0, status OK shos_rpc_inst.c:230 Cover.GetStatus via HTTP_in GET 192.168.0.5:52347 Debug: EventData-> { "component": "cover:0", "name": "cover", "id": 0, "now": 1695649666.13884568214, "info": { "component": "cover:0", "id": 0, "event": "power_update", "apower": 116.2, "ts": 1695649666.13999986648 } } Debug: Result-> { "id": 0 } shelly_notification:163 Status change of cover:0: {"id":0,"apower":116.2} Debug: EventData-> { "component": "cover:0", "name": "cover", "id": 0, "now": 1695649667.38815975189, "info": { "component": "cover:0", "id": 0, "event": "current_update", "current": 0.6, "ts": 1695649667.38999986648 } } Debug: Result-> { "id": 0 } Debug: EventData-> { "component": "cover:0", "name": "cover", "id": 0, "now": 1695649667.48993921279, "info": { "component": "cover:0", "id": 0, "event": "power_update", "apower": 14.2, "ts": 1695649667.49000000953 } } Debug: Result-> { "id": 0 } shelly_notification:163 Status change of cover:0: {"id":0,"apower":14.2} Debug: EventData-> { "component": "cover:0", "name": "cover", "id": 0, "now": 1695649667.49009895324, "info": { "component": "cover:0", "id": 0, "event": "current_update", "current": 0.1, "ts": 1695649667.49000000953 } } Debug: Result-> { "id": 0 } Debug: EventData-> { "component": "cover:0", "name": "cover", "id": 0, "now": 1695649667.68074893951, "info": { "component": "cover:0", "id": 0, "event": "power_update", "apower": 0, "ts": 1695649667.67999982833 } } Debug: Result-> { "id": 0 } shelly_notification:163 Status change of cover:0: {"id":0,"apower":0.0} Debug: EventData-> { "component": "cover:0", "name": "cover", "id": 0, "now": 1695649667.68119549751, "info": { "component": "cover:0", "id": 0, "event": "current_update", "current": 0, "ts": 1695649667.67999982833 } } Debug: Result-> { "id": 0 } Debug: EventData-> { "component": "cover:0", "name": "cover", "id": 0, "now": 1695649668.04615807533, "info": { "component": "cover:0", "id": 0, "event": "open", "source": "limit_switch", "ts": 1695649668.04999995231 } } Debug: Result-> { "id": 0 } shelly_notification:163 Status change of cover:0: {"id":0,"apower":0,"current":0,"current_pos":100,"move_started_at":null,"move_timeout":null,"pf":0,"source":"limit_switch","state":"open"} ›_ ↵ Shelly Plus2PM 5443B23EAE68| 1.0.3| aecad392| 16:47:56
Thank you again.
-
-
Hello,
I need help regarding the title. I am not a mjs expert and I want a script that publishes a custom mqtt topic when
Shelly Plus 2PM in cover mode, changes state or changes position.
The only thing that I managed to write, combining bits from here and there is the below scipt
Code
Alles anzeigenfunction startTimer() { Timer.set(30*1000,true,function(){ Shelly.call( "cover.getStatus", { id: 0 }, function (response) { MQTT.publish("hello/world/state", JSON.stringify(response.state), 0, false); MQTT.publish("hello/world/pos", JSON.stringify(response.current_pos), 0, false); MQTT.publish("hello/world/temp", JSON.stringify(response.temperature.tC), 0, false); }, null ); } ,null); } startTimer();
But of course this is not what i want. I understand I should use a statusHandler or eventHandler but I really don;t understand how to do it...
So, if anybody could help me I would appreciate it.
Thank you in advance.