bropat / eufy-security-client

This shared library allows to control Eufy security devices by connecting to the Eufy cloud servers and local/remote stations over p2p.
MIT License
467 stars 67 forks source link

StationGuardModeProperty in types is missing 6: "Off" #27

Closed schliemann closed 3 years ago

schliemann commented 3 years ago

Trying to setGuardMode on station to 6 throws the following error:

(node:6913) UnhandledPromiseRejectionWarning: InvalidPropertyValueError: Value "6" isn't a valid value for property "guardMode" at Object.validValue (/usr/lib/node_modules/homebridge-eufy-security-control/node_modules/eufy-security-client/src/utils.ts:108:19) at Station.setGuardMode (/usr/lib/node_modules/homebridge-eufy-security-control/node_modules/eufy-security-client/src/http/station.ts:513:13)

I think 6: "Off" should be added to StationGuardModeProperty here? https://github.com/bropat/eufy-security-client/blob/65ed8cb02675924b914c480079b16fe91160e056/src/http/types.ts#L2233

bropat commented 3 years ago

"Off" is only supported on a keypad device. Do you set this mode on a keypad device? If not, then the error is correct ;)

As I already explained to you in issue #13.

schliemann commented 3 years ago

Ah. Makes sense. Thanks.

schliemann commented 3 years ago

It was possible in 0.8.3. I do understand the argument of it being a keypad only value in eufys code. I am using a homebridge plugin and mapping and trying to set the station guard mode to Off since that is the value the keypad will set when I leave the house.

But without this property it is not possible programmatically to set the mode to Off.

bropat commented 3 years ago

The properties are mapped to the respective device, so if you have a keypad the "Off" value should work. Here you can find the keypad property:

https://github.com/bropat/eufy-security-client/blob/e398105a0cbffe23a373eda6779c1338d9535455/src/http/types.ts#L2236-L2249

But without this property it is not possible programmatically to set the mode to Off.

Have you tried it or are you just assuming? I mean at the keypad

schliemann commented 3 years ago

Is you proposal to call https://github.com/bropat/eufy-security-client/blob/65ed8cb02675924b914c480079b16fe91160e056/src/http/device.ts#L78 on the keypad device?

I guess I can do this. But I don't understand the argument for not supporting all guard modes on the station. I know that the only physical device that can set the Off mode is the keypad. But the guard mode is persisted in the base station, right?

bropat commented 3 years ago

No, here:

https://github.com/bropat/eufy-security-client/blob/65ed8cb02675924b914c480079b16fe91160e056/src/eufysecurity.ts#L946

The following check in the setGuardMode method is based on the official Eufy App:

https://github.com/bropat/eufy-security-client/blob/65ed8cb02675924b914c480079b16fe91160e056/src/http/station.ts#L525-L526

The reason why I reproduce the checks is because otherwise unforeseen situations can occur in the app or the device.

Otherwise you can also use the getPropertyMetadata of the Station class to load the respective property and query it for supported values.

One more thing:

I don't have a keypad, so it's also easy that I misinterpreted and included something wrong ;) If it is so, just say.

schliemann commented 3 years ago

Previously I was calling this.Station.setGuardMode(6)

which would then update the guard mode to Off.

I don't see how https://github.com/bropat/eufy-security-client/blob/65ed8cb02675924b914c480079b16fe91160e056/src/http/station.ts#L525-L526 would work since the station is not a KeyPad?

a-watts commented 3 years ago

Hello, I'm really enjoying this homebridge-eufy-security plugin via Hoobs. To the point that I bought/add Eufy Keypad to my setup. I would love to get the Eufy keypad status blue light indicators to reflect the status too OFF when turning OFF via Homekit, but currently it's just Disarming the eufy system. Which makes the keypad status light on Keypad not light OFF.

I'm willing to assist with troubleshooting if you need someone to test it out directly from the Eufy Keypad.

Below are the logs when I turn the Eufy system off directly from the Keypad:

8/3/2021, 1:18:49 PM [EufySecurity] Handle Station Raw Property Changes: -- 1266 -35 1628021929527 8/3/2021, 1:18:49 PM [EufySecurity] Handle Station Raw Property Changes: -- 1147 1628021928 1628021929527 8/3/2021, 1:19:00 PM {"name":"eufyLog","hostname":"hoobs","pid":980,"level":30,"msg":"Alarm mode for station T8010P132019084A changed to: undefined","time":"2021-08-03T20:19:00.881Z","v":0} 8/3/2021, 1:19:00 PM [EufySecurity] Handle Station Raw Property Changes: -- 1151 6 1628021940882 8/3/2021, 1:19:00 PM [EufySecurity] Received onStationCurrentModePushNotification - currentMode 6 homekitCurrentMode 3 8/3/2021, 1:19:00 PM [EufySecurity] Handle Station Property Changes: -- currentMode { value: 6, timestamp: 1628021940882 } 8/3/2021, 1:19:00 PM [EufySecurity] Handle Station Raw Property Changes: -- 1266 -34 1628021940998 8/3/2021, 1:19:01 PM [EufySecurity] Handle Station Raw Property Changes: -- 1224 6 1628021940998 8/3/2021, 1:19:01 PM [EufySecurity] Received onStationGuardModePushNotification - guardmode 6 homekitGuardMode 3 8/3/2021, 1:19:01 PM [EufySecurity] Handle Station Property Changes: -- guardMode { value: 6, timestamp: 1628021940998 } 8/3/2021, 1:19:01 PM [EufySecurity] Handle Station Raw Property Changes: -- 1147 1628021940 1628021940998

schliemann commented 3 years ago

@bropat I'm still not sure how I, with the current version of the client, can set the guardMode to Off?

fuatakgun commented 3 years ago

I am using this functionality through eufy-security-ws web socket, no issues.

schliemann commented 3 years ago

@fuatakgun And you are able to set the guardmode to 6 (Off)?

fuatakgun commented 3 years ago

My bad, i am using disarmed mode, not off.

fuatakgun commented 3 years ago

Over here: https://github.com/fuatakgun/eufy_security/blob/master/custom_components/eufy_security/alarm_control_panel.py

schliemann commented 3 years ago

@fuatakgun As far as I can see you don't use Off state?

bropat commented 3 years ago

@schliemann Can someone share a keypad with me?

schliemann commented 3 years ago

I can.

bropat commented 3 years ago

I need admin rights to be able to test everything and implement other features if necessary.

Where are you from? USA or Europe? Just so I send you the right account ;)

schliemann commented 3 years ago

@bropat Europe

bropat commented 3 years ago

@schliemann

REDACTED

schliemann commented 3 years ago

@bropat Shared now. I have disabled all device alarms just so we don't trigger alarms at home 😅

bropat commented 3 years ago

@schliemann Thank you very much. I'll have a look tonight and let you know.

lenoxys commented 3 years ago

My 2 cents, I still can trigger off mode (6) from app as well not only from the keypad.

IMG_2E4BC822C97C-1

bropat commented 3 years ago

@schliemann I'm working on it now and will be doing some tests soon.

The OFF mode is clear to me now.

schliemann commented 3 years ago

Great news, @bropat 👍🏻. You are doing an awesome job. Really appreciate it.

bropat commented 3 years ago

@schliemann Thank you :-)

The OFF mode is now applied correctly (only visible and usable if a keypad is registered at the station).

I am adding or correcting a few other functions. e.g.: Eufycam 2c and 2c Pro now support turning the light on and off, the night vision setting has been corrected (haven't had a 2c/2c pro in my hands yet to test :-P).

Do you think you can still give me access tomorrow, so I can finish testing a few things and check your issue regarding the doorbell livestream, among other things?

That's it for today.

schliemann commented 3 years ago

@bropat Sounds like a really good solution. You are welcome to use the access as long as you need it.

fuatakgun commented 3 years ago

Trying to understand why do we need off and how is it different than disarmed? Can you help me?

Background: i see that keypad creates it automatically and it goes to off mode when keypad used but it doesn't exist for non-keypad users, so we can not generalize it.

lenoxys commented 3 years ago

Off is useful if you have keypad because he does display the status directly on the keypad if you select off but it doesn't if you use disarmed. Disarmed can't be custom while off can be.

fuatakgun commented 3 years ago

I see, thanks

a-watts commented 3 years ago

Which version will start having the OFF capability? I'd like to test it out with my keypad to see if works. I'll send my feedback if it does or not.

bropat commented 3 years ago

@a-watts As of version 1.1.0 (2021-08-11):

(bropat) Fixed issue with guard mode setting where the "Off" state was not handled correctly (only supported with keypad) (#27)