jghaanstra / cloud.shelly

Homey app to control Shelly Cloud devices
GNU General Public License v3.0
21 stars 14 forks source link

Beacon mode not working #194

Closed RWissenburg closed 11 months ago

RWissenburg commented 1 year ago

As request

Problem: using the shelly blue button 1 with the shelly 1PM to get a better presence with homey.

Bluetooth on the button is enabled, the 1pm has the script.

In homey it isnt working correctly.

Monitoring it with the beacon timeout on 10 “minutes”.

What i notice, sometimes 1 see the beacon stays in range for at least the set 10 minutes

After the 10 minutens time out, its turns to out of range, and almost immediately (seconds) it turns back to in range

Second what i see, is that after that… its flipping from in/out of range every minute sliowy increasing to more minutes .

Also when the beacon say its in range on the first tab of the device tile, its say on the last tab is out of range

jghaanstra commented 1 year ago

I have tested this for the third now and I can not reproduce this. It's working for for me so I don't know how to fix it.

jghaanstra commented 1 year ago

Something I do notice is that the script on the Shelly device is not receiving all beacon events. In the case where Homey also doesnt pick these up I can image a device being registered as away. I'll ask Allterco Robotics about this.

jghaanstra commented 1 year ago

Could you enable websocket debug on the Shelly 1PM under debug settings, then edit the script and add console.log(BTHparsed); above the line with Shelly.emitEvent('NotifyBluetoothStatus', BTHparsed); somewhere around line 130 and watch the output on the console. Press a button on the BLU Button to see if you see an event. If so, keep it running to see if you are also receiving regular beacon events.

RWissenburg commented 1 year ago

Oke websocket debug was already enabled, added the line to the script as you mention

if (last_packet_id === BTHparsed.pid) return; last_packet_id = BTHparsed.pid; console.log(BTHparsed); Shelly.emitEvent('NotifyBluetoothStatus', BTHparsed);

saved, en then get a error on the console.

MJS error: parse error at line 68: []

Line 68 shows this if (type === int16) res = this.getInt16LE(buffer);

the outcome of de debug console

MJS error: parse error at line 68: [] 19:18:53 shelly_bluetooth_rel:92 ADV bc:02:6e:c3:c1:d0: mfd={}, svc={"fcd2":"RABMAWQ6AQ=="} 19:24:45 shelly_notification:161 Status change of switch:0: {"id":0,"aenergy":{"by_minute":[0.000,0.000,0.000],"minute_ts":1690997099,"total":0.000}} 19:25:00 shelly_bluetooth_rel:92 ADV bc:02:6e:c3:c1:d0: mfd={}, svc={"fcd2":"RABPAWQ6AA=="} 19:25:03 mgos_http_server.c:180 0x3ffdc96c HTTP connection from 192.168.106.3:42224 19:25:07 mg_rpc.c:314 Shelly.GetStatus via HTTP 192.168.106.3:42224 19:25:07 shelly_bluetooth_rel:92 ADV bc:02:6e:c3:c1:d0: mfd={}, svc={"fcd2":"RABSAWQ6AA=="} 19:25:28 shelly_bluetooth_rel:92 ADV bc:02:6e:c3:c1:d0: mfd={}, svc={"fcd2":"RABVAWQ6AA=="} 19:25:52 shelly_notification:161 Status change of switch:0: {"id":0,"aenergy":{"by_minute":[0.000,0.000,0.000],"minute_ts":1690997159,"total":0.000}} 19:26:00 shelly_bluetooth_rel:92 ADV bc:02:6e:c3:c1:d0: mfd={}, svc={"fcd2":"RABXAWQ6AA=="} 19:26:08 mgos_http_server.c:180 0x3ffdff78 HTTP connection from 192.168.106.3:42342 19:26:20 mg_rpc.c:314 Shelly.GetStatus via HTTP 192.168.106.3:42342 19:26:20 shelly_bluetooth_rel:92 ADV bc:02:6e:c3:c1:d0: mfd={}, svc={"fcd2":"RABbAWQ6AA=="} 19:26:40 shelly_notification:161 Status change of switch:0: {"id":0,"aenergy":{"by_minute":[0.000,0.000,0.000],"minute_ts":1690997219,"total":0.000}} 19:27:00 shelly_bluetooth_rel:92 ADV bc:02:6e:c3:c1:d0: mfd={}, svc={"fcd2":"RABeAWQ6AA=="} 19:27:04 shelly_bluetooth_rel:92 ADV bc:02:6e:c3:c1:d0: mfd={}, svc={"fcd2":"RABhAWQ6AA=="} 19:27:28 mgos_http_server.c:180 0x3ffdff78 HTTP connection from 192.168.106.3:42452 19:27:33 mg_rpc.c:314 Shelly.GetStatus via HTTP 192.168.106.3:42452 19:27:33 shelly_notification:161 Status change of switch:0: {"id":0,"aenergy":{"by_minute":[0.000,0.000,0.000],"minute_ts":1690997279,"total":0.000}} 19:28:00 shelly_bluetooth_rel:92 ADV bc:02:6e:c3:c1:d0: mfd={}, svc={"fcd2":"RABmAWQ6AA=="} 19:28:08 shelly_bluetooth_rel:92 ADV bc:02:6e:c3:c1:d0: mfd={}, svc={"fcd2":"RABpAWQ6AA=="} 19:28:32 mgos_http_server.c:180 0x3ffdff78 HTTP connection from 192.168.106.3:42574 19:28:47 mg_rpc.c:314 Shelly.GetStatus via HTTP 192.168.106.3:42574 19:28:47 shelly_bluetooth_rel:92 ADV bc:02:6e:c3:c1:d0: mfd={}, svc={"fcd2":"RABsAWQ6AA=="} 19:28:56 shelly_notification:161 Status change of switch:0: {"id":0,"aenergy":{"by_minute":[0.000,0.000,0.000],"minute_ts":1690997339,"total":0.000}} 19:29:00 mgos_http_server.c:180 0x3ffdff78 HTTP connection from 192.168.106.3:42698 19:29:59 mg_rpc.c:314 Shelly.GetStatus via HTTP 192.168.106.3:42698 19:29:59 shelly_notification:161 Status change of switch:0: {"id":0,"aenergy":{"by_minute":[0.000,0.000,0.000],"minute_ts":1690997399,"total":0.000}} 19:30:00 shelly_bluetooth_rel:92 ADV bc:02:6e:c3:c1:d0: mfd={}, svc={"fcd2":"RAB7AWQ6AA=="} 19:30:56 shelly_notification:161 Status change of switch:0: {"id":0,"aenergy":{"by_minute":[0.000,0.000,0.000],"minute_ts":1690997459,"total":0.000}} 19:31:00 shelly_bluetooth_rel:92 ADV bc:02:6e:c3:c1:d0: mfd={}, svc={"fcd2":"RAB8AWQ6AA=="} 19:31:04 mgos_http_server.c:180 0x3ffdff78 HTTP connection from 192.168.106.3:42818 19:31:12 mg_rpc.c:314 Shelly.GetStatus via HTTP 192.168.106.3:42818 19:31:12 shelly_bluetooth_rel:92 ADV bc:02:6e:c3:c1:d0: mfd={}, svc={"fcd2":"RAB+AWQ6AA=="} 19:31:20 shelly_bluetooth_rel:92 ADV bc:02:6e:c3:c1:d0: mfd={}, svc={"fcd2":"RAB/AWQ6AA=="} 19:31:28 shelly_notification:161 Status change of switch:0: {"id":0,"aenergy":{"by_minute":[0.000,0.000,0.000],"minute_ts":1690997519,"total":0.000}} 19:32:00 mgos_http_server.c:180 0x3ffdff78 HTTP connection from 192.168.106.3:42942 19:32:25 mg_rpc.c:314 Shelly.GetStatus via HTTP 192.168.106.3:42942 19:32:25 shelly_bluetooth_rel:92 ADV bc:02:6e:c3:c1:d0: mfd={}, svc={"fcd2":"RACHAWQ6AA=="} 19:32:32 shelly_bluetooth_rel:92 ADV bc:02:6e:c3:c1:d0: mfd={}, svc={"fcd2":"RACKAWQ6AA=="} 19:32:56 shelly_notification:161 Status change of switch:0: {"id":0,"aenergy":{"by_minute":[0.000,0.000,0.000],"minute_ts":1690997579,"total":0.000}} 19:33:00 Test your code here e.g. print('Hello World')

jghaanstra commented 1 year ago

Could you delete the script and re-add it from the device settings of the Plus 1PM and repeat the steps.

Afterwards look at the console of the script, not the generic debug console.

RWissenburg commented 1 year ago

Where i find the script?. ....

jghaanstra commented 1 year ago

image

RWissenburg commented 1 year ago

Nothing there.....

Schermafbeelding 2023-08-02 200303 `

jghaanstra commented 1 year ago

Go to the advanced settings from the Shelly Plus 1PM in Homey and click the Start BLE Proxy button.

p.s. where did you edit the script if it isnt there?

RWissenburg commented 1 year ago

yup found it already 👍 edit the script again, it now says "saved dismiss"

output of the console of the script

mgos_http_server.c:180 0x3ffdd124 HTTP connection from 192.168.106.3:46818 20:13:48 mg_rpc.c:314 Shelly.GetStatus via HTTP 192.168.106.3:46818 20:13:48 shelly_bluetooth_rel:92 ADV bc:02:6e:c3:c1:d0: mfd={}, svc={"fcd2":"RADHAWQ6AQ=="} 20:13:52 shelly_bluetooth_rel:92 ADV bc:02:6e:c3:c1:d0: mfd={}, svc={"fcd2":"RADIAWQ6AA=="} 20:14:00 shelly_notification:161 Status change of switch:0: {"id":0,"aenergy":{"by_minute":[0.000,0.000,0.000],"minute_ts":1691000039,"total":0.000}} 20:14:00 shelly_bluetooth_rel:92 ADV bc:02:6e:c3:c1:d0: mfd={}, svc={"fcd2":"RADLAWQ6AA=="} 20:14:24 shelly_bluetooth_rel:92 ADV bc:02:6e:c3:c1:d0: mfd={}, svc={"fcd2":"RADOAWQ6AA=="} 20:14:48 shelly_notification:161 Status change of switch:0: {"id":0,"aenergy":{"by_minute":[0.000,0.000,0.000],"minute_ts":1691000099,"total":0.000}} 20:15:00 mgos_http_server.c:180 0x3ffdd8fc HTTP connection from 192.168.106.3:46938 20:15:01 mg_rpc.c:314 Shelly.GetStatus via HTTP 192.168.106.3:46938 20:15:01 shelly_bluetooth_rel:92 ADV bc:02:6e:c3:c1:d0: mfd={}, svc={"fcd2":"RADRAWQ6AA=="} 20:15:12 shelly_bluetooth_rel:92 ADV bc:02:6e:c3:c1:d0: mfd={}, svc={"fcd2":"RADUAWQ6AA=="} 20:15:36 shelly_bluetooth_rel:92 ADV bc:02:6e:c3:c1:d0: mfd={}, svc={"fcd2":"RADXAWQ6AA=="} 20:16:00 shelly_notification:161 Status change of switch:0: {"id":0,"aenergy":{"by_minute":[0.000,0.000,0.000],"minute_ts":1691000159,"total":0.000}} 20:16:00 mgos_http_server.c:180 0x3ffdcba8 HTTP connection from 192.168.106.3:47066 20:16:14 mg_rpc.c:314 Shelly.GetStatus via HTTP 192.168.106.3:47066 20:16:14 shelly_bluetooth_rel:92 ADV bc:02:6e:c3:c1:d0: mfd={}, svc={"fcd2":"RADaAWQ6AA=="} 20:16:24 shelly_bluetooth_rel:92 ADV bc:02:6e:c3:c1:d0: mfd={}, svc={"fcd2":"RADdAWQ6AA=="} 20:16:48 shelly_notification:161 Status change of switch:0: {"id":0,"aenergy":{"by_minute":[0.000,0.000,0.000],"minute_ts":1691000219,"total":0.000}} 20:17:00 shelly_bluetooth_rel:92 ADV bc:02:6e:c3:c1:d0: mfd={}, svc={"fcd2":"RADgAWQ6AA=="} 20:17:12 mgos_http_server.c:180 0x3ffdd124 HTTP connection from 192.168.106.3:47190 20:17:28 mg_rpc.c:314 Shelly.GetStatus via HTTP 192.168.106.3:47190 20:17:28 shelly_bluetooth_rel:92 ADV bc:02:6e:c3:c1:d0: mfd={}, svc={"fcd2":"RADjAWQ6AA=="} 20:17:36 shelly_bluetooth_rel:92 ADV bc:02:6e:c3:c1:d0: mfd={}, svc={"fcd2":"RADmAWQ6AA=="} 20:18:00 shelly_notification:161 Status change of switch:0: {"id":0,"aenergy":{"by_minute":[0.000,0.000,0.000],"minute_ts":1691000279,"total":0.000}} 20:18:00 shelly_bluetooth_rel:92 ADV bc:02:6e:c3:c1:d0: mfd={}, svc={"fcd2":"RADpAWQ6AA=="} 20:18:24 mgos_http_server.c:180 0x3ffdd124 HTTP connection from 192.168.106.3:47304 20:18:41 mg_rpc.c:314 Shelly.GetStatus via HTTP 192.168.106.3:47304 20:18:41 shelly_bluetooth_rel:92 ADV bc:02:6e:c3:c1:d0: mfd={}, svc={"fcd2":"RADsAWQ6AA=="} 20:18:48 shelly_notification:161 Status change of switch:0: {"id":0,"aenergy":{"by_minute":[0.000,0.000,0.000],"minute_ts":1691000339,"total":0.000}} 20:19:00 shelly_bluetooth_rel:92 ADV bc:02:6e:c3:c1:d0: mfd={}, svc={"fcd2":"RADvAWQ6AA=="} 20:19:12 shelly_bluetooth_rel:92 ADV bc:02:6e:c3:c1:d0: mfd={}, svc={"fcd2":"RADyAWQ6AA=="} 20:19:36 mgos_http_server.c:180 0x3ffdd7c4 HTTP connection from 192.168.106.3:47412 20:19:53 mg_rpc.c:314 Shelly.GetStatus via HTTP 192.168.106.3:47412 20:19:53

jghaanstra commented 1 year ago

This is not the output from the script console. It should look something like this. But I'm not actually interested in what it says exactly. I want to know if you see regular updates indicating there are beacon events being processed.

image

Events where button is value 0 are beacon events.

RWissenburg commented 1 year ago

yes its the outcome drom the script console. Schermafbeelding 2023-08-02 211932

Cant find anywhere else a outcome like you said.

jghaanstra commented 1 year ago

Uncheck the full log option on the top right of the console. Then clear the console with the red icon on the top left. Then push the BLU button and see if you get a report. If so, wait if other reports (with button value 0) also come in.

RWissenburg commented 1 year ago

Nope nothing comes in, log stays empty

jghaanstra commented 1 year ago

Not even when you push the button?

(and you did add the extra line console.log(BTHparsed); after you added the script)

RWissenburg commented 1 year ago

yep nothing.....did the whole thing over again adding the extra line....saved.... push the button.

nothing

jghaanstra commented 1 year ago

How are the Bluetooth settings of the Shelly Plus 1PM configured?

RWissenburg commented 1 year ago

bluetooth enabled, gateway enabled. dont know if there are more settings. at least cant find other settings.

What i notice in the real shelly app, that the 1pm detects the 1/2/3 clicks of the button.

https://github.com/jghaanstra/cloud.shelly/assets/32013370/af34af5c-d7e4-4ea7-a149-7f3c040898a2

jghaanstra commented 1 year ago

Disable the BLE Gateway and start again with the steps for testing. BLE Gateway is for sending events over cloud but will block the BLE script.

RWissenburg commented 1 year ago

oke stil a empty log

jghaanstra commented 1 year ago

Did you reboot the Shelly Plus 1PM after changing the setting?

RWissenburg commented 1 year ago

yes i did

jghaanstra commented 1 year ago

I give up. I dont think this is an issue with the app but something with your setup. But I have no clue why it isnt working for you.

RWissenburg commented 1 year ago

well, i dont know either.

Understand that is hard for you to find out what it could be.

Only i can say is... thank you for the effort.

I throw it aside for the day. And if i get i fixed somehow...i let you know

thkssss

RWissenburg commented 1 year ago

last update for now. did a complete reset.... deleted both devices from the shelly app and homey. started all over again.

Stil not working in de homey app.

I leave as it is for the moment and wait if there are others with the same problem. For now i going to look for another solution.

jghaanstra commented 1 year ago

I've looked into this further. I havent got a solution but these are my current findings:

I'll add more information when it becomes available.

jghaanstra commented 1 year ago

@RWissenburg could you update your Plus/Pro devices to firmware 1.0.0 and test again. I seem to be getting much better results with that firmware.

jghaanstra commented 11 months ago

I have tested this to much extend now. When then Plus/Pro device is setup correctly as proxy and the BLU Button is within range this should be working well. Closing this issue.

RWissenburg commented 11 months ago

Missed your latest replies, tested again and working ok now. Didnt change anything so all fine.

jghaanstra commented 11 months ago

Good to hear and thanx for the donation!