fuatakgun / eufy_security

Home Assistant integration to manage Eufy Security devices as cameras, home base stations, doorbells, motion and contact sensors.
922 stars 77 forks source link

Support for Door/Entry Sensor #85

Closed jayjc303 closed 2 years ago

jayjc303 commented 3 years ago

This doesn't seem to support the Eufy Door/Entry sensor. After installing, it doesn't show up on the device list hence I'll assume that it's not supported. All other Eufy devices show up, including Homebase 2, Floodlight Cam and 2K battery doorbell.

It would be great to detect the sensor's open and close state to trigger other automations.

fuatakgun commented 3 years ago

did you enable notifications for door sensors? integration fully relies on incoming push notifications, it is actually running an emulated mobile app (thanks to eufy-security-ws) to receive these notifications.

jayjc303 commented 3 years ago

Thanks for the quick response. Yes door sensor has notification turned on. What entity should I be looking for? And will it be under the Home base? If you're saying it's already tested and fully supported I will try to dig deeper to find it. Thanks

fuatakgun commented 3 years ago

Ok got it, you don't see the device at all, then i am definitely wrong.

I need you to enable debug level logging for integration (check readme) and share your logs especially for start_listening web socket call. Then we can proceed with this.

jayjc303 commented 3 years ago

Here's the extract from my logs. The Entry Sensor is called 'Garage'. Thanks

21-10-19 19:32:43 DEBUG (MainThread) [custom_components.eufy_security] eufy_security - WebSocket message sent. {"messageId": "set_api_schema", "command": "set_api_schema", "schemaVersion": 3} 2021-10-19 19:32:43 DEBUG (MainThread) [custom_components.eufy_security] eufy_security - WebSocket message sent. {"messageId": "start_listening", "command": "start_listening"} 2021-10-19 19:32:43 DEBUG (MainThread) [custom_components.eufy_security] eufy_security - check_if_started_listening 2021-10-19 19:32:43 DEBUG (MainThread) [custom_components.eufy_security] eufy_security - wait start - devices 2021-10-19 19:32:43 DEBUG (MainThread) [custom_components.eufy_security] eufy_security - wait - 0 - devices None 2021-10-19 19:32:43 DEBUG (MainThread) [custom_components.eufy_security] eufy_security - process_messages started 2021-10-19 19:32:44 INFO (MainThread) [homeassistant.setup] Setting up ssdp 2021-10-19 19:32:44 INFO (MainThread) [homeassistant.setup] Setup of domain ssdp took 0.0 seconds 2021-10-19 19:32:44 DEBUG (MainThread) [custom_components.eufy_security] eufy_security - on_message - {'type': 'result', 'success': True, 'messageId': 'set_api_schema', 'result': {}} 2021-10-19 19:32:44 DEBUG (MainThread) [custom_components.eufy_security] eufy_security - on_message - {'type': 'result', 'success': True, 'messageId': 'start_listening', 'result': {'state': {'driver': {'version': '0.9.4', 'connected': True, 'pushConnected': True}, 'stations': [{'name': 'Newport', 'model': 'T8010', 'serialNumber': 'T8010N132003XXXX', 'hardwareVersion': 'P0', 'softwareVersion': '2.1.7.8h', 'lanIpAddress': '192.168.0.163', 'macAddress': '8C:85:80:31:A8:5C', 'currentMode': 1, 'guardMode': 1, 'connected': False, 'timeFormat': 0, 'alarmTone': 1, 'promptVolume': 16, 'notificationSwitchModeSchedule': False, 'notificationSwitchModeGeofence': False, 'notificationSwitchModeApp': False, 'notificationSwitchModeKeypad': False, 'notificationStartAlarmDelay': False}, {'name': 'Newport - Kitchen', 'model': 'T8410', 'serialNumber': 'T8410P202118XXXX', 'hardwareVersion': 'P2', 'softwareVersion': '2.1.0.5', 'lanIpAddress': '180.150.XX.XX', 'macAddress': '8C8580A068C3', 'currentMode': 1, 'guardMode': 47, 'connected': True}, {'name': 'Newport - Driveway', 'model': 'T8420', 'serialNumber': 'T8420H011935XXXX', 'hardwareVersion': '2.2', 'softwareVersion': '1.0.0.38', 'lanIpAddress': '180.150.XX.XX', 'macAddress': 'AC:5D:5C:FB:66:8F', 'currentMode': 1, 'guardMode': 1, 'connected': False}], 'devices': [{'name': 'Inside Newport', 'model': 'T8113', 'serialNumber': 'T8113N132010XXXX', 'hardwareVersion': 'eufy2_mini', 'softwareVersion': '1.7.4', 'stationSerialNumber': 'T8010N132003XXXX', 'enabled': True, 'state': 1, 'battery': 91, 'batteryTemperature': 25, 'lastChargingDays': 25, 'lastChargingTotalEvents': 89, 'lastChargingRecordedEvents': 35, 'lastChargingFalseEvents': 54, 'batteryUsageLastWeek': 0, 'motionDetected': False, 'personDetected': False, 'personName': '', 'antitheftDetection': False, 'autoNightvision': True, 'ledStatus': True, 'motionDetection': True, 'rtspStream': True, 'watermark': 0, 'wifiRSSI': -70, 'pictureUrl': 'https://zhixin-security-pr.s3.us-west-2.amazonaws.com/thumb/2021/10/17/station/T8010N13200317C2/1E2rbiTFPJVc6eXD./camera00_20211017125456.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJYLV2KOLW6PU4FSA%2F20211018%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20211018T215253Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=aea227dbe1840a1b33f1b1081073a0ff', 'motionDetectionType': 0, 'motionDetectionSensivity': 46, 'microphone': True, 'speaker': True, 'speakerVolume': 96, 'audioRecording': True, 'powerSource': 0, 'powerWorkingMode': 0, 'notificationType': 1}, {'name': 'Garage', 'model': 'T8900', 'serialNumber': 'T8900P002039XXXX', 'hardwareVersion': '0.0.1', 'softwareVersion': '0.1.0gb', 'stationSerialNumber': 'T8010N132003XXXX', 'batteryLow': False}, {'name': 'Newport - Doorbell', 'model': 'T8210', 'serialNumber': 'T8210P002039XXXX', 'hardwareVersion': 'T8210', 'softwareVersion': '2.2.3.3', 'stationSerialNumber': 'T8010N132003XXXX', 'enabled': True, 'state': 1, 'battery': 81, 'batteryTemperature': 13, 'lastChargingDays': 13, 'lastChargingTotalEvents': 388, 'lastChargingRecordedEvents': 23, 'lastChargingFalseEvents': 365, 'batteryUsageLastWeek': 8, 'motionDetected': False, 'personDetected': False, 'personName': '', 'ringing': False, 'autoNightvision': True, 'ledStatus': False, 'motionDetection': False, 'watermark': 1, 'wifiRSSI': -63, 'pictureUrl': 'https://zhixin-security-pr.s3.us-west-2.amazonaws.com/thumb/2021/10/17/station/T8010N13200317C2/pcUFZUTHAB3YNzww.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJYLV2KOLW6PU4FSA%2F20211018%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20211018T215253Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=1456cf5a75ddeda1bcd81633fe990668f2', 'motionDetectionType': 0, 'microphone': True, 'speakerVolume': 54, 'ringtoneVolume': 49, 'audioRecording': True, 'powerWorkingMode': 3, 'recordingClipLength': 55, 'recordingRetriggerInterval': 60, 'videoWDR': True, 'chimeIndoor': False, 'chimeHomebase': True, 'chimeHomebaseRingtoneVolume': 17, 'chimeHomebaseRingtoneType': 2, 'notificationType': 1, 'notificationRing': 1, 'notificationMotion': 1}, {'name': 'Newport - Kitchen', 'model': 'T8410', 'serialNumber': 'T8410P202118XXXX', 'hardwareVersion': 'P2', 'softwareVersion': '2.1.0.5', 'stationSerialNumber': 'T8410P202118XXXX', 'enabled': False, 'motionDetected': False, 'personDetected': False, 'personName': '', 'soundDetected': False, 'petDetected': False, 'cryingDetected': False, 'autoNightvision': True, 'ledStatus': True, 'motionDetection': True, 'soundDetection': False, 'petDetection': False, 'rtspStream': False, 'pictureUrl': 'https://security-app.eufylife.com/v1/s/g/0_3', 'motionDetectionType': 1, 'motionDetectionSensivity': 3, 'motionTracking': True, 'soundDetectionType': 1, 'soundDetectionSensivity': 3, 'microphone': True, 'speaker': True, 'speakerVolume': 80, 'audioRecording': True, 'videoStreamingQuality': 0, 'notificationType': 3, 'notificationPerson': True, 'notificationPet': True, 'notificationAllOtherMotion': True, 'notificationCrying': True, 'notificationAllSound': True}, {'name': 'Newport - Driveway', 'model': 'T8420', 'serialNumber': 'T8420H011935XXXX', 'hardwareVersion': '2.2', 'softwareVersion': '1.0.0.38', 'stationSerialNumber': 'T8420H011935XXXX', 'motionDetected': False, 'personDetected': False, 'personName': '', 'autoNightvision': True, 'watermark': 2, 'pictureUrl': 'https://zhixin-security-pr.s3.us-west-2.amazonaws.com/thumb/2021/10/18/station/T8420H011935189A/ExjHrvVh1fxGh44O./T8420H011935189A_20211018150038?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJYLV2KOLW6PU4FSA%2F20211018%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20211018T215253Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=2e1d424a2fed870c6ea348c07a700', 'light': False, 'microphone': True, 'speaker': True, 'speakerVolume': 63, 'recordingEndClipMotionStops': True, 'recordingClipLength': 60, 'recordingRetriggerInterval': 0, 'lightSettingsEnable': True, 'lightSettingsBrightnessManual': 100, 'lightSettingsBrightnessMotion': 100, 'lightSettingsBrightnessSchedule': 100, 'lightSettingsMotionTriggered': True, 'lightSettingsMotionTriggeredDistance': 80, 'lightSettingsMotionTriggeredTimer': 30}]}}}

fuatakgun commented 3 years ago

created an issue on WS repository: https://github.com/bropat/eufy-security-ws/issues/32

i don't see the state of sensor in your dump, i was expecting something like sensor_open:true but I only see battery_low. Let's see @bropat's reaction on this.

        {
          'name': 'Garage',
          'model': 'T8900',
          'serialNumber': 'T8900P002039XXXX',
          'hardwareVersion': '0.0.1',
          'softwareVersion': '0.1.0gb',
          'stationSerialNumber': 'T8010N132003XXXX',
          'batteryLow': False
        }
jayjc303 commented 3 years ago

Here's the sensorOpen line.

2021-10-19 19:32:45 DEBUG (MainThread) [custom_components.eufy_security] eufy_security - on_message - {'type': 'result', 'success': True, 'messageId': 'get_properties', 'result': {'properties': {'name': {'value': 'Garage', 'timestamp': 1634407099000}, 'model': {'value': 'T8900', 'timestamp': 1634407099000}, 'serialNumber': {'value': 'T8900P002039XXXX', 'timestamp': 1634407099000}, 'type': {'value': 2, 'timestamp': 1634407099000}, 'hardwareVersion': {'value': '0.0.1', 'timestamp': 1634407099000}, 'softwareVersion': {'value': '0.1.0gb', 'timestamp': 1634285281000}, 'stationSerialNumber': {'value': 'T8010N132003XXXX', 'timestamp': 1634407099000}, 'sensorOpen': {'value': False, 'timestamp': 1634609414234}, 'batteryLow': {'value': False, 'timestamp': 1634285282000}, 'sensorChangeTime': {'value': 1634530236, 'timestamp': 1634285282000}}}}

fuatakgun commented 3 years ago

this should be part of initial output of start_listening, not get_properties

jayjc303 commented 3 years ago

Got it. Let's see what @bropat finds. thx again.

TheRealStark commented 3 years ago

Thanks for posting @jayjc303 - looking to accomplish the same thing over here.

fuatakgun commented 2 years ago

this is waiting on update to new version: https://github.com/fuatakgun/eufy_security/issues/59

fuatakgun commented 2 years ago

updated both add-on and integration, please give it a try, YOU MUST UPDATE BOTH OF THEM.

https://github.com/fuatakgun/eufy_security/issues/59#issuecomment-968352909

fuatakgun commented 2 years ago

should be working fine, please update here if it is not working as expected

TheRealStark commented 2 years ago

Works great! Thanks @fuatakgun !

Do you know if the sensor is able to report battery level and if so, have events trigger when battery level runs low?

fuatakgun commented 2 years ago

You tell me :-) do you have a battery sensor for your device? Most of the time, i am coding blindly as i don't own all of these devices

TheRealStark commented 2 years ago

Yeah, in the Eufy app, it appears it does display the current battery level of the Entry Sensor!

fuatakgun commented 2 years ago

I mean, inside home assistant, do you have a battery sensor after using this integration?

TheRealStark commented 2 years ago

No, it doesn't. This is all that appears:

image

fuatakgun commented 2 years ago

And screenshot from eufy app please?

fuatakgun commented 2 years ago

Hey, please create a separate issue for missing battery sensor. Also dump your attributes of door sensor using developer tools and share screenshot from eufy app.

TheRealStark commented 2 years ago

Done: https://github.com/fuatakgun/eufy_security/issues/158