diff --git a/README.md b/README.md index cab00ae..f3f19a1 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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 diff --git a/custom_components/dahua_vto/manifest.json b/custom_components/dahua_vto/manifest.json index 6f995e0..76d6dbf 100644 --- a/custom_components/dahua_vto/manifest.json +++ b/custom_components/dahua_vto/manifest.json @@ -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": [], diff --git a/custom_components/dahua_vto/sensor.py b/custom_components/dahua_vto/sensor.py index cde7031..e6ddd42 100644 --- a/custom_components/dahua_vto/sensor.py +++ b/custom_components/dahua_vto/sensor.py @@ -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, @@ -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: