Skip to content

Commit 7344f5c

Browse files
committed
Added attach to configManager and client.notifyConfigChange messages handler, Updated documentation
1 parent 5ec37f3 commit 7344f5c

File tree

3 files changed

+41
-10
lines changed

3 files changed

+41
-10
lines changed

README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ You can send any command using the service `dahua_vto.send_command` or `dahua_vt
181181
`dahua_vto.send_instance_command` sequential call to service.factory.instance, service.method with object returned by factory.instance and service.destroy, where service it's a first part of the `method` before `.`. Result of service.method returned as event.
182182
I doesn't found documentation but you can grab some commands and their parameters from [Dahua-JSON-Debug-Console-v2.py](https://github.com/mcw0/Tools)
183183

184-
All device `client.notifyEventStream` messages you will receive as events, information about some of them you can find [here](https://github.com/elad-bar/DahuaVTO2MQTT/blob/master/MQTTEvents.MD).
184+
All device `client.notifyEventStream` and `client.notifyConfigChange` messages you will receive as events, information about some of them you can find [here](https://github.com/elad-bar/DahuaVTO2MQTT/blob/master/MQTTEvents.MD).
185185

186186
For most of the cases you can use `BackKeyLight` event `State`, the list of some of them you can found in table below.
187187

@@ -240,6 +240,30 @@ data:
240240
method: RecordUpdater.clear
241241
instance_params: {'name': 'VideoTalkMissedLog'}
242242
event: false
243+
244+
# Arming the VTH alarm
245+
service: dahua_vto.send_command
246+
data:
247+
entity_id: sensor.dahua_vth
248+
method: configManager.setConfig
249+
params: {'table': {'AlarmEnable': true, 'CurrentProfile': 'Outdoor'}, 'name': 'CommGlobal'}
250+
event: false
251+
252+
# Disarming the VTH alarm
253+
service: dahua_vto.send_command
254+
data:
255+
entity_id: sensor.dahua_vth
256+
method: configManager.setConfig
257+
params: {'table': {'AlarmEnable': false, 'CurrentProfile': 'AtHome'}, 'name': 'CommGlobal'}
258+
event: false
259+
260+
# Getting the VTH alarm status
261+
service: dahua_vto.send_command
262+
data:
263+
entity_id: sensor.dahua_vth
264+
method: configManager.getConfig
265+
params: {'name': 'CommGlobal'}
266+
event: true
243267
```
244268

245269
# Debugging

custom_components/dahua_vto/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"domain": "dahua_vto",
33
"name": "Dahua VTO",
4-
"version": "1.0.6",
4+
"version": "1.0.7",
55
"documentation": "https://github.com/myhomeiot/DahuaVTO",
66
"issue_tracker": "https://github.com/myhomeiot/DahuaVTO/issues",
77
"requirements": [],

custom_components/dahua_vto/sensor.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@
2020
DAHUA_LOGIN_PARAMS = {
2121
"clientType": "", "ipAddr": "(null)", "loginType": "Direct"}
2222

23-
DEFAULT_NAME = "Dahua VTO"
24-
DEFAULT_PORT = 5000
25-
DEFAULT_TIMEOUT = 10
26-
2723
DEFAULT_KEEPALIVEINTERVAL = 60
2824

2925
_LOGGER = logging.getLogger(__name__)
3026

31-
# Validation of the user's configuration
27+
# Validation of the platform configuration
28+
DEFAULT_NAME = "Dahua VTO"
29+
DEFAULT_PORT = 5000
30+
DEFAULT_TIMEOUT = 10
31+
3232
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
3333
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
3434
vol.Required(CONF_HOST): cv.string,
@@ -179,10 +179,17 @@ def receive(self, message):
179179
self.heartbeat = self.loop.create_task(self.heartbeat_loop())
180180
self.send({"method": "eventManager.attach",
181181
"params": {"codes": ["All"]}})
182+
self.send({"method": "configManager.attach",
183+
"params": {"name": "CommGlobal"}})
182184
elif message.get("method") == "client.notifyEventStream":
183-
for message in params.get("eventList"):
184-
message["entity_id"] = self.entity.entity_id
185-
self.hass.bus.fire(DOMAIN, message)
185+
for event in params.get("eventList"):
186+
event["entity_id"] = self.entity.entity_id
187+
self.hass.bus.fire(DOMAIN, event)
188+
elif message.get("method") == "client.notifyConfigChange":
189+
table = params.get("table")
190+
table["entity_id"] = self.entity.entity_id
191+
table["Code"] = message.get("method")
192+
self.hass.bus.fire(DOMAIN, table)
186193

187194
def data_received(self, data):
188195
try:

0 commit comments

Comments
 (0)