Skip to content

Commit

Permalink
Added attach to configManager and client.notifyConfigChange message…
Browse files Browse the repository at this point in the history
…s handler, Updated documentation
  • Loading branch information
myhomeiot committed Jan 12, 2022
1 parent 5ec37f3 commit 7344f5c
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 10 deletions.
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ You can send any command using the service `dahua_vto.send_command` or `dahua_vt
`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.
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)

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).
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).

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

Expand Down Expand Up @@ -240,6 +240,30 @@ data:
method: RecordUpdater.clear
instance_params: {'name': 'VideoTalkMissedLog'}
event: false
# Arming the VTH alarm
service: dahua_vto.send_command
data:
entity_id: sensor.dahua_vth
method: configManager.setConfig
params: {'table': {'AlarmEnable': true, 'CurrentProfile': 'Outdoor'}, 'name': 'CommGlobal'}
event: false
# Disarming the VTH alarm
service: dahua_vto.send_command
data:
entity_id: sensor.dahua_vth
method: configManager.setConfig
params: {'table': {'AlarmEnable': false, 'CurrentProfile': 'AtHome'}, 'name': 'CommGlobal'}
event: false
# Getting the VTH alarm status
service: dahua_vto.send_command
data:
entity_id: sensor.dahua_vth
method: configManager.getConfig
params: {'name': 'CommGlobal'}
event: true
```

# Debugging
Expand Down
2 changes: 1 addition & 1 deletion custom_components/dahua_vto/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"domain": "dahua_vto",
"name": "Dahua VTO",
"version": "1.0.6",
"version": "1.0.7",
"documentation": "https://github.com/myhomeiot/DahuaVTO",
"issue_tracker": "https://github.com/myhomeiot/DahuaVTO/issues",
"requirements": [],
Expand Down
23 changes: 15 additions & 8 deletions custom_components/dahua_vto/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
DAHUA_LOGIN_PARAMS = {
"clientType": "", "ipAddr": "(null)", "loginType": "Direct"}

DEFAULT_NAME = "Dahua VTO"
DEFAULT_PORT = 5000
DEFAULT_TIMEOUT = 10

DEFAULT_KEEPALIVEINTERVAL = 60

_LOGGER = logging.getLogger(__name__)

# Validation of the user's configuration
# Validation of the platform configuration
DEFAULT_NAME = "Dahua VTO"
DEFAULT_PORT = 5000
DEFAULT_TIMEOUT = 10

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Required(CONF_HOST): cv.string,
Expand Down Expand Up @@ -179,10 +179,17 @@ def receive(self, message):
self.heartbeat = self.loop.create_task(self.heartbeat_loop())
self.send({"method": "eventManager.attach",
"params": {"codes": ["All"]}})
self.send({"method": "configManager.attach",
"params": {"name": "CommGlobal"}})
elif message.get("method") == "client.notifyEventStream":
for message in params.get("eventList"):
message["entity_id"] = self.entity.entity_id
self.hass.bus.fire(DOMAIN, message)
for event in params.get("eventList"):
event["entity_id"] = self.entity.entity_id
self.hass.bus.fire(DOMAIN, event)
elif message.get("method") == "client.notifyConfigChange":
table = params.get("table")
table["entity_id"] = self.entity.entity_id
table["Code"] = message.get("method")
self.hass.bus.fire(DOMAIN, table)

def data_received(self, data):
try:
Expand Down

0 comments on commit 7344f5c

Please sign in to comment.