Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
fuatakgun committed Jan 13, 2022
2 parents 33ac012 + c83ab30 commit 55ffdc2
Show file tree
Hide file tree
Showing 7 changed files with 230 additions and 56 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/HACSCheck.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: HACS

on:
push:
pull_request:

jobs:
validate-hassfest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Hassfest validation
uses: home-assistant/actions/hassfest@master

validate-hacs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: HACS validation
uses: hacs/action@main
with:
category: integration
29 changes: 11 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ logger:
Please follow screenshots below. In summary;
- You will first install HASS Add On assuming you are running on Hassos or Supervised. If not, please execute this command to run docker instance manually ```docker run -it -e USERNAME=email@address.com -e PASSWORD=password_goes_here -p 3000:3000 bropat/eufy-security-ws:X.Y.Z```. To find out correct values for X.Y.Z, please chek here /~https://github.com/fuatakgun/eufy_security_addon/blob/main/config.json#L3
- Later on, you should install RTSP Server Add On to have faster/more reliable p2p streaming. I will deprecate/not support file based streaming soon, so, please migrate in timely manner. If you are not using Hassos or Supervised installation please execute this command to run docker instance manually ```docker run --rm -it -e RTSP_PROTOCOLS=tcp -d -p 8554:8554 -p 1935:1935 aler9/rtsp-simple-server```
- When you are done with HASS Add On, you will install integration via adding integration address to HACS, downloading files over UI, restarting home assistant and setting up integration.
- When you are done with HASS Add On, you will install integration via HACS, downloading files over UI, restarting home assistant and setting up integration.
- Double check if your `configuration.yaml` includes `ffmpeg` integration. If not, please do like this; https://www.home-assistant.io/integrations/ffmpeg/#configuration . This integration relies on `ffmpeg` to be setup to live stream via P2P and capture images from live RTSP/P2P streams.

## 6.1 Installing Eufy Security Add On - Required
Expand Down Expand Up @@ -105,40 +105,33 @@ Please follow screenshots below. In summary;

## 6.3 Installing Integration

1- Go to HACS and click on `Custom repositories`
1- Go to HACS and search for 'Eufy Security'

![6-hacs-custom-repositories](https://user-images.githubusercontent.com/11085566/126563932-e9fc2783-02a1-42d3-8f4a-bc0fa2edf386.PNG)

2- Add custom integration repository URL
```/~https://github.com/fuatakgun/eufy_security/```

![7-hacs-add](https://user-images.githubusercontent.com/11085566/126563937-4ad08d92-b9c1-45e3-a205-be9b244bc3a7.PNG)

3- Install the `Eufy Secucirty` repository
2- Install the `Eufy Security` repository

![8-hacs-install](https://user-images.githubusercontent.com/11085566/126563950-1c89c1e8-f77d-46ac-8910-77048500a07f.PNG)

4- You need to restart your HA instance to pick up new repository.
3- You need to restart your HA instance to pick up new repository.

![9-hacs-restart](https://user-images.githubusercontent.com/11085566/126563954-b801e4ea-b93e-4695-928d-a82221fe01f4.PNG)

5- After restart, go to `Configuration` - `Integrations` page and click on `Add Integration`
4- After restart, go to `Configuration` - `Integrations` page and click on `Add Integration`

![10-integrations](https://user-images.githubusercontent.com/11085566/126563961-a05c5e50-b006-4759-b55a-548f691a13d8.PNG)

6- Search for ```Eufy Security``` and click on it
5- Search for ```Eufy Security``` and click on it

![11-integration-search](https://user-images.githubusercontent.com/11085566/126563968-920a74de-ab93-456b-b4b2-dcf651a07f9f.PNG)

7- In next page, use ```localhost``` if you have used Add-on installation, otherwise put your Docker instance ip address and keep `3000` as port
6- In next page, use ```localhost``` if you have used Add-on installation, otherwise put your Docker instance ip address and keep `3000` as port

![12-integration-configure](https://user-images.githubusercontent.com/11085566/126563976-234005e7-2920-4ef0-a301-187d4d929f10.png)

8- You will be shown devices connected to your account. Or you can be alerted with captcha notification.
7- You will be shown devices connected to your account. Or you can be alerted with captcha notification.

![13-integration-done](https://user-images.githubusercontent.com/11085566/126563982-38b3a00a-ff6a-45aa-8dcc-b04e864a37f8.PNG)

9- Follow screenshots below for captcha
8- Follow screenshots below for captcha
a. Get notified about captcha request
![image](https://user-images.githubusercontent.com/11085566/145604195-7b5499b3-9603-468b-aa03-84121047719b.png)

Expand All @@ -153,11 +146,11 @@ d. If you put the wrong code, after couple of seconds, you will get a similar er

e. After entering correct captcha code, your devices will be ready to use.

10- If your camera does not support RTSP based live streaming, you can use `Start Live Stream` and `Stop Live Stream` services rather than turn_on and turn_off because they tend to be using RTSP functions. They require camera entities as input, you can use UI for this. More importantly, please set your `Streaming Quality` settings to `Low` per each camera using Eufy Security app, otherwise WebRTC will fail to stream the video. Underlying issue is realted mid or high quality codecs are not supported by WebRTC.
9- If your camera does not support RTSP based live streaming, you can use `Start Live Stream` and `Stop Live Stream` services rather than turn_on and turn_off because they tend to be using RTSP functions. They require camera entities as input, you can use UI for this. More importantly, please set your `Streaming Quality` settings to `Low` per each camera using Eufy Security app, otherwise WebRTC will fail to stream the video. Underlying issue is realted mid or high quality codecs are not supported by WebRTC.

![14-services-live-stream](https://user-images.githubusercontent.com/11085566/126563991-5ef949c5-144c-4702-a9e3-577e2d37c0f8.PNG)

11- If you want faster P2P live streaming, go to Integration Configuration section and enable it.
10- If you want faster P2P live streaming, go to Integration Configuration section and enable it.
![image](https://user-images.githubusercontent.com/11085566/127866543-1345d56f-b4f3-4154-96c7-a278d747cf8d.png)

## 6.3 WebRTC - Required
Expand Down
84 changes: 76 additions & 8 deletions custom_components/eufy_security/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
DEVICE_CLASS_POWER,
DEVICE_CLASS_SOUND,
)

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import STATE_OFF, STATE_ON
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import EntityCategory

from .const import COORDINATOR, DOMAIN, Device, get_child_value
from .coordinator import EufySecurityDataUpdateCoordinator
Expand All @@ -29,160 +31,223 @@ async def async_setup_entry(
"status_led_enabled",
"Status Led Enabled",
"state.statusLed",
"mdi: led-on",
"mdi:led-on",
None,
EntityCategory.DIAGNOSTIC,
),
(
"motion_sensor",
"Motion Sensor",
"state.motionDetected",
None,
DEVICE_CLASS_MOTION,
None,
),
(
"motion_detection_enabled",
"Motion Detection Enabled",
"state.motionDetection",
None,
DEVICE_CLASS_MOTION,
EntityCategory.DIAGNOSTIC,
),
(
"person_detector_sensor",
"Person Detector Sensor",
"state.personDetected",
None,
DEVICE_CLASS_MOTION,
EntityCategory.DIAGNOSTIC,
),
(
"person_detection_enabled",
"Person Detection Enabled",
"state.personDetection",
None,
DEVICE_CLASS_MOTION,
EntityCategory.DIAGNOSTIC,
),
(
"pet_detector_sensor",
"Pet Detector Sensor",
"state.petDetected",
None,
DEVICE_CLASS_MOTION,
None,
),
(
"pet_detection_enabled",
"Pet Detection Enabled",
"state.petDetection",
"mdi: dog",
None,
EntityCategory.DIAGNOSTIC,
),
(
"sound_detector_sensor",
"Sound Detector Sensor",
"state.soundDetected",
None,
DEVICE_CLASS_SOUND,
None,
),
(
"sound_detection_enabled",
"Sound Detection Enabled",
"state.soundDetection",
"mdi: account-voice",
None,
EntityCategory.DIAGNOSTIC,
),
(
"crying_detector_sensor",
"Crying Detector Sensor",
"state.cryingDetected",
None,
DEVICE_CLASS_SOUND,
None,
),
(
"sensor_open",
"Sensor Open",
"state.sensorOpen",
None,
DEVICE_CLASS_DOOR,
None,
),
(
"battery_low",
"Battery Low",
"state.batteryLow",
None,
DEVICE_CLASS_BATTERY,
EntityCategory.DIAGNOSTIC,
),
(
"ringing_sensor",
"Ringing Sensor",
"state.ringing",
"mdi:bell-ring",
None,
None,
),
("sensor_open", "Sensor Open", "state.sensorOpen", None, DEVICE_CLASS_DOOR),
("battery_low", "Battery Low", "state.batteryLow", None, DEVICE_CLASS_BATTERY),
("ringing_sensor", "Ringing Sensor", "state.ringing", "mdi:bell-ring", None),
(
"motion_tracking_enabled",
"Motion Tracking",
"state.motionTracking",
"mdi:go-kart-track",
None,
EntityCategory.DIAGNOSTIC,
),
(
"notification_person_enabled",
"Notification for Person",
"state.notificationPerson",
"mdi:bell-ring",
None,
EntityCategory.DIAGNOSTIC,
),
(
"notification_pet_enabled",
"Notification for Pet",
"state.notificationPet",
"mdi:bell-ring",
None,
EntityCategory.DIAGNOSTIC,
),
(
"notification_all_other_motion_enabled",
"Notification for All Other Motion",
"state.notificationAllOtherMotion",
"mdi:bell-ring",
None,
EntityCategory.DIAGNOSTIC,
),
(
"notification_crying_enabled",
"Notification for Crying",
"state.notificationCrying",
"mdi:bell-ring",
None,
EntityCategory.DIAGNOSTIC,
),
(
"notification_all_sound_enabled",
"Notification for All Sound",
"state.notificationAllSound",
"mdi:bell-ring",
None,
EntityCategory.DIAGNOSTIC,
),
(
"speaker_enabled",
"Speaker",
"state.speaker",
"mdi:bullhorn",
None,
EntityCategory.DIAGNOSTIC,
),
("speaker_enabled", "Speaker", "state.speaker", "mdi:bullhorn", None),
(
"microphone_enabled",
"Microphone",
"state.microphone",
"mdi:microphone",
None,
EntityCategory.DIAGNOSTIC,
),
(
"auto_night_vision_enabled",
"Auto Night vision",
"state.autoNightvision",
"mdi:weather-night",
None,
EntityCategory.DIAGNOSTIC,
),
(
"audio_recording_enabled",
"Audio Recording",
"state.audioRecording",
"mdi:record-rec",
None,
EntityCategory.DIAGNOSTIC,
),
(
"charging",
"Charging Status",
"state.chargingStatus",
None,
DEVICE_CLASS_BATTERY_CHARGING,
EntityCategory.DIAGNOSTIC,
),
(
"enabled",
"Enabled",
"state.enabled",
None,
DEVICE_CLASS_POWER,
EntityCategory.DIAGNOSTIC,
),
(
"streaming",
"Streaming Sensor",
"is_streaming",
None,
DEVICE_CLASS_MOTION,
EntityCategory.DIAGNOSTIC,
),
("enabled", "Enabled", "state.enabled", None, DEVICE_CLASS_POWER),
("streaming", "Streaming Sensor", "is_streaming", None, DEVICE_CLASS_MOTION),
(
"rtsp_stream_enabled",
"RTSP Stream",
"state.rtspStream",
"mdi:cast-connected",
None,
EntityCategory.DIAGNOSTIC,
),
]

entities = []
for device in coordinator.devices.values():
for id, description, key, icon, device_class in INSTRUMENTS:
for id, description, key, icon, device_class, entity_category in INSTRUMENTS:
if not get_child_value(device.__dict__, key) is None:
entities.append(
EufySecurityBinarySensor(
Expand All @@ -194,6 +259,7 @@ async def async_setup_entry(
key,
icon,
device_class,
entity_category,
)
)

Expand All @@ -211,13 +277,15 @@ def __init__(
key: str,
icon: str,
device_class: str,
entity_category: str,
):
super().__init__(coordinator, config_entry, device)
self._id = id
self.description = description
self.key = key
self._icon = icon
self._device_class = device_class
self._attr_entity_category = entity_category

if self.id == "motion_sensor" and device.is_motion_sensor() is True:
self.key = "motionDetection"
Expand Down
3 changes: 2 additions & 1 deletion custom_components/eufy_security/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"issue_tracker": "/~https://github.com/fuatakgun/eufy_security/issues",
"dependencies": ["ffmpeg", "http"],
"config_flow": true,
"version": "1.1.0",
"codeowners": ["@fuatakgun"],
"requirements": ["websocket-client==1.1.0"],
"version": "0.0.1"
"iot_class": "cloud_push"
}
Loading

0 comments on commit 55ffdc2

Please sign in to comment.