Skip to content

Commit 4216484

Browse files
committed
Merge branch 'main' of github.com:rroller/dahua into main
2 parents 72a0e89 + 96d1d83 commit 4216484

File tree

4 files changed

+55
-7
lines changed

4 files changed

+55
-7
lines changed

README.md

+49-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,48 @@
11

2-
# Dahua
2+
# Home Assistant Dahua Integration
3+
The `Dahua` integration allows you to integrate your [Dahua](https://www.dahuasecurity.com/) cameras in Home Assistant.
34

5+
## Installation
46

7+
### Manual install
8+
To manually install:
59

10+
```bash
11+
# Download a copy of this repository
12+
$ wget https://github.com/rroller/dahua/archive/main.zip
13+
14+
# Unzip the archive
15+
$ unzip main.zip
16+
17+
# Move the dahua directory into your custom_components directory in your Home Assistant install
18+
$ mv dahua/custom_components/dahua <home-assistant-install-directory>/config/custom_components/
19+
```
20+
21+
### HACS install
22+
To install with [HACS](https://hacs.xyz/):
23+
24+
1. Click on HACS in the Home Assistant menu
25+
2. Click on `Integrations`
26+
3. Click the top right menu (the three dots)
27+
4. Select `Custom repositories`
28+
5. Paste the repository URL (`https://github.com/rroller/dahua`) in the dialog box
29+
6. Select category `Integration`
30+
7. Click `Add`
31+
8. Click `Install`
32+
9. Add integration?
33+
34+
> :warning: **After executing one of the above installation methods, restart Home Assistant. Also clear your browser cache before proceeding to the next step, as the integration may not be visible otherwise.**
35+
36+
37+
# Known supported cameras
38+
This integration should word with most Dahua cameras. It has been tested with very old and very new Dahua cameras.
39+
The following are confirmed to work:
40+
41+
* xxx
42+
* yyy
43+
* IPC-HDlkjsdf
44+
45+
# Services and Entities
646
## Services
747
```
848
camera.enable_motion_detection
@@ -14,6 +54,14 @@ dahua.set_infrared_mode
1454
brightness: 100 # 0 - 100 inclusive
1555
````
1656
57+
## Camera
58+
59+
## Switches
60+
61+
## Lights
62+
63+
## Binary Sensors
64+
1765
# Local development
1866
If you wish to work on this component, the easiest way is to follow [HACS Dev Container README](https://github.com/custom-components/integration_blueprint/blob/master/.devcontainer/README.md). In short:
1967

custom_components/dahua/client.py

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
_LOGGER: logging.Logger = logging.getLogger(__package__)
1616

1717
HEADERS = {"Content-type": "application/json; charset=UTF-8"}
18-
WHITE_LIGHT_TYPE = 1
1918
SECURITY_LIGHT_TYPE = 1
2019
SIREN_TYPE = 2
2120

custom_components/dahua/light.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,10 @@ async def async_turn_off(self, **kwargs):
153153

154154

155155
class DahuaSecurityLight(DahuaBaseEntity, LightEntity):
156-
"""Representation of a Dahua light (for cameras that have them). This is the red/blue flashing lights"""
156+
"""
157+
Representation of a Dahua light (for cameras that have them). This is the red/blue flashing lights.
158+
The camera will only keep this light on for a few seconds before it automatically turns off.
159+
"""
157160

158161
def __init__(self, coordinator: DahuaDataUpdateCoordinator, entry, name):
159162
super().__init__(coordinator, entry)

custom_components/dahua/switch.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ async def async_setup_entry(hass: HomeAssistant, entry, async_add_devices):
1212
"""Setup sensor platform."""
1313
coordinator: DahuaDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
1414

15-
devices = []
16-
1715
# I think most cameras have a motion sensor so we'll blindly add a switch for it
18-
devices.append(DahuaMotionDetectionBinarySwitch(coordinator, entry))
16+
devices = [DahuaMotionDetectionBinarySwitch(coordinator, entry)]
1917

2018
# But only some cams have a siren, very few do actually
2119
if coordinator.supports_siren():
@@ -68,7 +66,7 @@ class DahuaSirenBinarySwitch(DahuaBaseEntity, SwitchEntity):
6866
"""dahua siren switch class. Used to enable or disable camera built in sirens"""
6967

7068
async def async_turn_on(self, **kwargs): # pylint: disable=unused-argument
71-
"""Turn on/enable the camrea siren"""
69+
"""Turn on/enable the camera's siren"""
7270
await self.coordinator.client.async_set_coaxial_control_state(SIREN_TYPE, True)
7371
await self.coordinator.async_refresh()
7472

0 commit comments

Comments
 (0)