You managed to grab the pyHik package after I changed the version number to an earlier one to push a test version to pypi. To get things working you need to edit the REQUIREMENTS line in the hikvision.py file in your hass binary_sensors directory. Change the version from 0.1 to 0.0.1 and it should work.
Wow, I missed that, got it running. Thank you!
No problem, thanks for testing. Please report back after youāve been running it for a little while if everything is working OK. If I can get yourself and @tinglis1 both running Iāll start the PR process to get it integrated into the project.
sure, Iāll keep it running and report back if I notice anything.
I very quickly ran this component on my development version with debug logging and got the following error in the log.
The sensors show but do not trip when the events do.
16-12-07 09:05:02 homeassistant.loader: Loaded binary_sensor.hikvision from custom_components.binary_sensor.hikvision
16-12-07 09:05:02 homeassistant.bootstrap: Setting up binary_sensor
16-12-07 09:05:02 homeassistant.components.binary_sensor: Setting up binary_sensor.hikvision
16-12-07 09:05:03 pyhik.hikvision: Sensor type "callhelp" is added without a friendly name.
16-12-07 09:05:03 pyhik.hikvision: Sensor type "WLSensor" is added without a friendly name.
16-12-07 09:05:03 pyhik.hikvision: Sensor type "WLSensor" is added without a friendly name.
16-12-07 09:05:03 pyhik.hikvision: Sensor type "WLSensor" is added without a friendly name.
16-12-07 09:05:03 pyhik.hikvision: Sensor type "WLSensor" is added without a friendly name.
16-12-07 09:05:03 pyhik.hikvision: Sensor type "WLSensor" is added without a friendly name.
16-12-07 09:05:03 pyhik.hikvision: Sensor type "WLSensor" is added without a friendly name.
16-12-07 09:05:03 pyhik.hikvision: Sensor type "WLSensor" is added without a friendly name.
16-12-07 09:05:03 pyhik.hikvision: Sensor type "WLSensor" is added without a friendly name.
16-12-07 09:05:03 homeassistant.core: Bus:Handling <Event state_changed[L]: old_state=None, entity_id=binary_sensor.cam46_motion, new_state=<state binary_sensor.cam46_motion=off; last_tripped_time=2016-12-07T19:35:03.168871+10:30, sensor_class=motion, friendly_name=cam46 Motion @ 2016-12-07T09:05:03.180794+10:30>>
16-12-07 09:05:03 homeassistant.core: Bus:Handling <Event state_changed[L]: old_state=None, entity_id=binary_sensor.cam46_line_crossing, new_state=<state binary_sensor.cam46_line_crossing=off; last_tripped_time=2016-12-07T19:35:03.168885+10:30, sensor_class=motion, friendly_name=cam46 Line Crossing @ 2016-12-07T09:05:03.182729+10:30>>
16-12-07 09:05:03 homeassistant.core: Bus:Handling <Event state_changed[L]: old_state=None, entity_id=binary_sensor.cam46_field_detection, new_state=<state binary_sensor.cam46_field_detection=off; last_tripped_time=2016-12-07T19:35:03.168889+10:30, sensor_class=motion, friendly_name=cam46 Field Detection @ 2016-12-07T09:05:03.185268+10:30>>
16-12-07 09:05:03 homeassistant.core: Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "uvloop/future.pyx", line 372, in uvloop.loop.BaseTask._fast_step (uvloop/loop.c:105885)
File "/usr/src/app/homeassistant/helpers/entity_component.py", line 335, in _async_process_entity
new_entity, self, update_before_add=update_before_add
File "/usr/src/app/homeassistant/helpers/entity_component.py", line 204, in async_add_entity
yield from entity.async_update_ha_state()
File "/usr/src/app/homeassistant/helpers/entity.py", line 224, in async_update_ha_state
attr = self.state_attributes or {}
File "/usr/src/app/homeassistant/components/binary_sensor/__init__.py", line 77, in state_attributes
if self.sensor_class is not None:
File "/config/custom_components/binary_sensor/hikvision.py", line 195, in sensor_class
return SENSOR_CLASS_MAP[self._sensor]
KeyError: 'callhelp'
16-12-07 09:05:03 homeassistant.core: Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "uvloop/future.pyx", line 372, in uvloop.loop.BaseTask._fast_step (uvloop/loop.c:105885)
File "/usr/src/app/homeassistant/helpers/entity_component.py", line 335, in _async_process_entity
new_entity, self, update_before_add=update_before_add
File "/usr/src/app/homeassistant/helpers/entity_component.py", line 204, in async_add_entity
yield from entity.async_update_ha_state()
File "/usr/src/app/homeassistant/helpers/entity.py", line 224, in async_update_ha_state
attr = self.state_attributes or {}
File "/usr/src/app/homeassistant/components/binary_sensor/__init__.py", line 77, in state_attributes
if self.sensor_class is not None:
File "/config/custom_components/binary_sensor/hikvision.py", line 195, in sensor_class
return SENSOR_CLASS_MAP[self._sensor]
KeyError: 'PIR Alarm'
16-12-07 09:05:03 homeassistant.core: Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "uvloop/future.pyx", line 372, in uvloop.loop.BaseTask._fast_step (uvloop/loop.c:105885)
File "/usr/src/app/homeassistant/helpers/entity_component.py", line 335, in _async_process_entity
new_entity, self, update_before_add=update_before_add
File "/usr/src/app/homeassistant/helpers/entity_component.py", line 204, in async_add_entity
yield from entity.async_update_ha_state()
File "/usr/src/app/homeassistant/helpers/entity.py", line 224, in async_update_ha_state
attr = self.state_attributes or {}
File "/usr/src/app/homeassistant/components/binary_sensor/__init__.py", line 77, in state_attributes
if self.sensor_class is not None:
File "/config/custom_components/binary_sensor/hikvision.py", line 195, in sensor_class
return SENSOR_CLASS_MAP[self._sensor]
KeyError: 'WLSensor'
I will hopefully have some time tomorrow to dig into the issue deeper but thought I would share the log in advance.
See my xml below:
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<EventNotification xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<EventTriggerList xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<EventTrigger xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<id>VMD-1</id>
<eventType>VMD</eventType>
<eventDescription>VMD Event trigger Information</eventDescription>
<videoInputChannelID>1</videoInputChannelID>
<dynVideoInputChannelID>1</dynVideoInputChannelID>
<EventTriggerNotificationList xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<EventTriggerNotification>
<id>record-1</id>
<notificationMethod>record</notificationMethod>
<videoInputID>1</videoInputID>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>beep</id>
<notificationMethod>beep</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>center</id>
<notificationMethod>center</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
</EventTriggerNotificationList>
</EventTrigger>
<EventTrigger xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<id>videoloss-1</id>
<eventType>videoloss</eventType>
<eventDescription>Videoloss Event trigger Information</eventDescription>
<videoInputChannelID>1</videoInputChannelID>
<dynVideoInputChannelID>1</dynVideoInputChannelID>
<EventTriggerNotificationList xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0"></EventTriggerNotificationList>
</EventTrigger>
<EventTrigger xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<id>tamper-1</id>
<eventType>tamperdetection</eventType>
<eventDescription>shelteralarm Event trigger Information</eventDescription>
<videoInputChannelID>1</videoInputChannelID>
<dynVideoInputChannelID>1</dynVideoInputChannelID>
<EventTriggerNotificationList xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0"></EventTriggerNotificationList>
</EventTrigger>
<EventTrigger xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<id>diskfull</id>
<eventType>diskfull</eventType>
<eventDescription>exception Information</eventDescription>
<videoInputChannelID>1</videoInputChannelID>
<dynVideoInputChannelID>1</dynVideoInputChannelID>
<EventTriggerNotificationList xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0"></EventTriggerNotificationList>
</EventTrigger>
<EventTrigger xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<id>diskerror</id>
<eventType>diskerror</eventType>
<eventDescription>exception Information</eventDescription>
<videoInputChannelID>1</videoInputChannelID>
<dynVideoInputChannelID>1</dynVideoInputChannelID>
<EventTriggerNotificationList xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<EventTriggerNotification>
<id>beep</id>
<notificationMethod>beep</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
</EventTriggerNotificationList>
</EventTrigger>
<EventTrigger xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<id>nicbroken</id>
<eventType>nicbroken</eventType>
<eventDescription>exception Information</eventDescription>
<videoInputChannelID>1</videoInputChannelID>
<dynVideoInputChannelID>1</dynVideoInputChannelID>
<EventTriggerNotificationList xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0"></EventTriggerNotificationList>
</EventTrigger>
<EventTrigger xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<id>ipconflict</id>
<eventType>ipconflict</eventType>
<eventDescription>exception Information</eventDescription>
<videoInputChannelID>1</videoInputChannelID>
<dynVideoInputChannelID>1</dynVideoInputChannelID>
<EventTriggerNotificationList xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0"></EventTriggerNotificationList>
</EventTrigger>
<EventTrigger xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<id>illaccess</id>
<eventType>illaccess</eventType>
<eventDescription>exception Information</eventDescription>
<videoInputChannelID>1</videoInputChannelID>
<dynVideoInputChannelID>1</dynVideoInputChannelID>
<EventTriggerNotificationList xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0"></EventTriggerNotificationList>
</EventTrigger>
<EventTrigger xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<id>Linedetection-1</id>
<eventType>linedetection</eventType>
<eventDescription>Linedetection Event trigger Information</eventDescription>
<videoInputChannelID>1</videoInputChannelID>
<dynVideoInputChannelID>1</dynVideoInputChannelID>
<EventTriggerNotificationList xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<EventTriggerNotification>
<id>record-1</id>
<notificationMethod>record</notificationMethod>
<videoInputID>1</videoInputID>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>center</id>
<notificationMethod>center</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
</EventTriggerNotificationList>
</EventTrigger>
<EventTrigger xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<id>fielddetection-1</id>
<eventType>fielddetection</eventType>
<eventDescription>fielddetection Event trigger Information</eventDescription>
<videoInputChannelID>1</videoInputChannelID>
<dynVideoInputChannelID>1</dynVideoInputChannelID>
<EventTriggerNotificationList xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<EventTriggerNotification>
<id>record-1</id>
<notificationMethod>record</notificationMethod>
<videoInputID>1</videoInputID>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>center</id>
<notificationMethod>center</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
</EventTriggerNotificationList>
</EventTrigger>
<EventTrigger xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<id>videomismatch</id>
<eventType>videomismatch</eventType>
<eventDescription>exception Information</eventDescription>
<videoInputChannelID>1</videoInputChannelID>
<dynVideoInputChannelID>1</dynVideoInputChannelID>
<EventTriggerNotificationList xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<EventTriggerNotification>
<id>beep</id>
<notificationMethod>beep</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
</EventTriggerNotificationList>
</EventTrigger>
<EventTrigger xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<id>badvideo</id>
<eventType>badvideo</eventType>
<eventDescription>exception Information</eventDescription>
<videoInputChannelID>1</videoInputChannelID>
<dynVideoInputChannelID>1</dynVideoInputChannelID>
<EventTriggerNotificationList xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0"></EventTriggerNotificationList>
</EventTrigger>
<EventTrigger xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<id>PIR</id>
<eventType>PIR</eventType>
<eventDescription>PIR Event trigger Information</eventDescription>
<videoInputChannelID>1</videoInputChannelID>
<dynVideoInputChannelID>1</dynVideoInputChannelID>
<EventTriggerNotificationList xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<EventTriggerNotification>
<id>email</id>
<notificationMethod>email</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>record-1</id>
<notificationMethod>record</notificationMethod>
<videoInputID>1</videoInputID>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>beep</id>
<notificationMethod>beep</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>center</id>
<notificationMethod>center</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>FTP</id>
<notificationMethod>FTP</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
</EventTriggerNotificationList>
</EventTrigger>
<EventTrigger xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<id>callhelp</id>
<eventType>callhelp</eventType>
<eventDescription>exception Information</eventDescription>
<videoInputChannelID>1</videoInputChannelID>
<dynVideoInputChannelID>1</dynVideoInputChannelID>
<EventTriggerNotificationList xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<EventTriggerNotification>
<id>email</id>
<notificationMethod>email</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>record-1</id>
<notificationMethod>record</notificationMethod>
<videoInputID>1</videoInputID>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>beep</id>
<notificationMethod>beep</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>center</id>
<notificationMethod>center</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>FTP</id>
<notificationMethod>FTP</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
</EventTriggerNotificationList>
</EventTrigger>
<EventTrigger xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<id>facedetection</id>
<eventType>facedetection</eventType>
<eventDescription>exception Information</eventDescription>
<videoInputChannelID>1</videoInputChannelID>
<dynVideoInputChannelID>1</dynVideoInputChannelID>
<EventTriggerNotificationList xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0"></EventTriggerNotificationList>
</EventTrigger>
<EventTrigger xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<id>WLSensor-1</id>
<eventType>WLSensor</eventType>
<eventDescription>WLSensor Event trigger Information</eventDescription>
<WLSensorID>1</WLSensorID>
<videoInputChannelID>1</videoInputChannelID>
<dynVideoInputChannelID>1</dynVideoInputChannelID>
<EventTriggerNotificationList xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<EventTriggerNotification>
<id>email</id>
<notificationMethod>email</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>record-1</id>
<notificationMethod>record</notificationMethod>
<videoInputID>1</videoInputID>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>beep</id>
<notificationMethod>beep</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>center</id>
<notificationMethod>center</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>FTP</id>
<notificationMethod>FTP</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
</EventTriggerNotificationList>
</EventTrigger>
<EventTrigger xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<id>WLSensor-2</id>
<eventType>WLSensor</eventType>
<eventDescription>WLSensor Event trigger Information</eventDescription>
<WLSensorID>2</WLSensorID>
<videoInputChannelID>1</videoInputChannelID>
<dynVideoInputChannelID>1</dynVideoInputChannelID>
<EventTriggerNotificationList xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<EventTriggerNotification>
<id>email</id>
<notificationMethod>email</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>record-1</id>
<notificationMethod>record</notificationMethod>
<videoInputID>1</videoInputID>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>beep</id>
<notificationMethod>beep</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>center</id>
<notificationMethod>center</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>FTP</id>
<notificationMethod>FTP</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
</EventTriggerNotificationList>
</EventTrigger>
<EventTrigger xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<id>WLSensor-3</id>
<eventType>WLSensor</eventType>
<eventDescription>WLSensor Event trigger Information</eventDescription>
<WLSensorID>3</WLSensorID>
<videoInputChannelID>1</videoInputChannelID>
<dynVideoInputChannelID>1</dynVideoInputChannelID>
<EventTriggerNotificationList xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<EventTriggerNotification>
<id>email</id>
<notificationMethod>email</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>record-1</id>
<notificationMethod>record</notificationMethod>
<videoInputID>1</videoInputID>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>beep</id>
<notificationMethod>beep</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>center</id>
<notificationMethod>center</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>FTP</id>
<notificationMethod>FTP</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
</EventTriggerNotificationList>
</EventTrigger>
<EventTrigger xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<id>WLSensor-4</id>
<eventType>WLSensor</eventType>
<eventDescription>WLSensor Event trigger Information</eventDescription>
<WLSensorID>4</WLSensorID>
<videoInputChannelID>1</videoInputChannelID>
<dynVideoInputChannelID>1</dynVideoInputChannelID>
<EventTriggerNotificationList xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<EventTriggerNotification>
<id>email</id>
<notificationMethod>email</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>record-1</id>
<notificationMethod>record</notificationMethod>
<videoInputID>1</videoInputID>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>beep</id>
<notificationMethod>beep</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>center</id>
<notificationMethod>center</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>FTP</id>
<notificationMethod>FTP</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
</EventTriggerNotificationList>
</EventTrigger>
<EventTrigger xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<id>WLSensor-5</id>
<eventType>WLSensor</eventType>
<eventDescription>WLSensor Event trigger Information</eventDescription>
<WLSensorID>5</WLSensorID>
<videoInputChannelID>1</videoInputChannelID>
<dynVideoInputChannelID>1</dynVideoInputChannelID>
<EventTriggerNotificationList xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<EventTriggerNotification>
<id>email</id>
<notificationMethod>email</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>record-1</id>
<notificationMethod>record</notificationMethod>
<videoInputID>1</videoInputID>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>beep</id>
<notificationMethod>beep</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>center</id>
<notificationMethod>center</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>FTP</id>
<notificationMethod>FTP</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
</EventTriggerNotificationList>
</EventTrigger>
<EventTrigger xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<id>WLSensor-6</id>
<eventType>WLSensor</eventType>
<eventDescription>WLSensor Event trigger Information</eventDescription>
<WLSensorID>6</WLSensorID>
<videoInputChannelID>1</videoInputChannelID>
<dynVideoInputChannelID>1</dynVideoInputChannelID>
<EventTriggerNotificationList xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<EventTriggerNotification>
<id>email</id>
<notificationMethod>email</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>record-1</id>
<notificationMethod>record</notificationMethod>
<videoInputID>1</videoInputID>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>beep</id>
<notificationMethod>beep</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>center</id>
<notificationMethod>center</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>FTP</id>
<notificationMethod>FTP</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
</EventTriggerNotificationList>
</EventTrigger>
<EventTrigger xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<id>WLSensor-7</id>
<eventType>WLSensor</eventType>
<eventDescription>WLSensor Event trigger Information</eventDescription>
<WLSensorID>7</WLSensorID>
<videoInputChannelID>1</videoInputChannelID>
<dynVideoInputChannelID>1</dynVideoInputChannelID>
<EventTriggerNotificationList xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<EventTriggerNotification>
<id>email</id>
<notificationMethod>email</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>record-1</id>
<notificationMethod>record</notificationMethod>
<videoInputID>1</videoInputID>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>beep</id>
<notificationMethod>beep</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>center</id>
<notificationMethod>center</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>FTP</id>
<notificationMethod>FTP</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
</EventTriggerNotificationList>
</EventTrigger>
<EventTrigger xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<id>WLSensor-8</id>
<eventType>WLSensor</eventType>
<eventDescription>WLSensor Event trigger Information</eventDescription>
<WLSensorID>8</WLSensorID>
<videoInputChannelID>1</videoInputChannelID>
<dynVideoInputChannelID>1</dynVideoInputChannelID>
<EventTriggerNotificationList xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<EventTriggerNotification>
<id>email</id>
<notificationMethod>email</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>record-1</id>
<notificationMethod>record</notificationMethod>
<videoInputID>1</videoInputID>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>beep</id>
<notificationMethod>beep</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>center</id>
<notificationMethod>center</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>FTP</id>
<notificationMethod>FTP</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
</EventTriggerNotificationList>
</EventTrigger>
</EventTriggerList>
</EventNotification>
Thanks for the debug log and your XML dump. You have quite a few more sensors available than I do in my cameras and it seems like iām still not handling unmapped ones correctly.
Iāll try to sort things out and post here when updates are pushed to github.
@tinglis1 I think I have your issues sorted out.
Grab the updated HASS binary_sensor file here:
https://github.com/mezz64/home-assistant/blob/8fb91f4cb078e8d713d224641e244dccdc8c2074/homeassistant/components/binary_sensor/hikvision.py
And the latest version of the pyHik library is now in PyPi as version 0.0.2.
By the way, can you tell me what the āWLSensorā is? I see you have a bunch of them in your XML enabled to notify and some google searching turned up nothing.
I have no idea what the WLSensors are. I did find a reference to it in the document below on page 188.
I am looking through the config and xml and still cannot seem to workout what they are.
I am not getting any errors in my log but I am not getting events from into HA now.
The event stream shows the events (see the snapshot when I curl the stream below).
curl snapshot showing motion event active
<EventNotificationAlert version="1.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<ipAddress>192.168.2.146</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>xx:xx:xx:xx:xx:xx</macAddress>
<channelID>1</channelID>
<dateTime>2016-12-07T17:18:10+09:30</dateTime>
<activePostCount>84</activePostCount>
<eventType>VMD</eventType>
<eventState>active</eventState>
<eventDescription>Motion alarm</eventDescription>
<DetectionRegionList>
</DetectionRegionList>
</EventNotificationAlert>
--hikboundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 518
<EventNotificationAlert version="1.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<ipAddress>192.168.2.146</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>xx:xx:xx:xx:xx:xx</macAddress>
<channelID>1</channelID>
<dateTime>2016-12-07T17:18:10+09:30</dateTime>
<activePostCount>85</activePostCount>
<eventType>VMD</eventType>
<eventState>active</eventState>
<eventDescription>Motion alarm</eventDescription>
<DetectionRegionList>
</DetectionRegionList>
</EventNotificationAlert>
debug log
16-12-07 17:17:14 homeassistant.loader: Loaded binary_sensor.hikvision from custom_components.binary_sensor.hikvision
16-12-07 17:17:14 homeassistant.bootstrap: Setting up binary_sensor
16-12-07 17:17:14 homeassistant.components.binary_sensor: Setting up binary_sensor.hikvision
16-12-07 17:17:15 homeassistant.core: Bus:Handling <Event state_changed[L]: entity_id=binary_sensor.cam46_help_call, old_state=None, new_state=<state binary_sensor.cam46_help_call=off; last_tripped_time=2016-12-08T03:47:15.121817+10:30, friendly_name=cam46 Help Call @ 2016-12-07T17:17:15.127964+10:30>>
16-12-07 17:17:15 homeassistant.core: Bus:Handling <Event state_changed[L]: entity_id=binary_sensor.cam46_motion, old_state=None, new_state=<state binary_sensor.cam46_motion=off; last_tripped_time=2016-12-08T03:47:15.121794+10:30, sensor_class=motion, friendly_name=cam46 Motion @ 2016-12-07T17:17:15.129856+10:30>>
16-12-07 17:17:15 homeassistant.core: Bus:Handling <Event state_changed[L]: entity_id=binary_sensor.cam46_line_crossing, old_state=None, new_state=<state binary_sensor.cam46_line_crossing=off; last_tripped_time=2016-12-08T03:47:15.121807+10:30, sensor_class=motion, friendly_name=cam46 Line Crossing @ 2016-12-07T17:17:15.132371+10:30>>
16-12-07 17:17:15 homeassistant.core: Bus:Handling <Event state_changed[L]: entity_id=binary_sensor.cam46_field_detection, old_state=None, new_state=<state binary_sensor.cam46_field_detection=off; last_tripped_time=2016-12-08T03:47:15.121811+10:30, sensor_class=motion, friendly_name=cam46 Field Detection @ 2016-12-07T17:17:15.134346+10:30>>
16-12-07 17:17:15 homeassistant.core: Bus:Handling <Event state_changed[L]: entity_id=binary_sensor.cam46_wl_alarm, old_state=None, new_state=<state binary_sensor.cam46_wl_alarm=off; last_tripped_time=2016-12-08T03:47:15.121837+10:30, friendly_name=cam46 WL Alarm @ 2016-12-07T17:17:15.136073+10:30>>
16-12-07 17:17:15 homeassistant.core: Bus:Handling <Event state_changed[L]: entity_id=binary_sensor.cam46_pir_alarm, old_state=None, new_state=<state binary_sensor.cam46_pir_alarm=off; last_tripped_time=2016-12-08T03:47:15.121814+10:30, sensor_class=motion, friendly_name=cam46 PIR Alarm @ 2016-12-07T17:17:15.139284+10:30>>
16-12-07 17:17:15 homeassistant.core: Bus:Handling <Event component_loaded[L]: component=binary_sensor>
Ok, per the document you linked they are defined as part of the āWireless alarm serviceā, which is confusing since your camera model doesnāt seem to have any wireless functions. What firmware version are you running?
It also looks like you are copying the HASS hikvision.py file into a custom components directory. Iām not sure if it will make any difference, but this is designed to be put into the main homeassistant/components/binary_sensor directory. Please try loading it from there and also verify that you have pyDispatcher installed on your system.
Only other thing that might still be creating a problem is the multiple WLSensor items in the event stream. Iām not currently expecting more than one of a given event type so all the WLSensor entries get merged into one sensor in HASS. I should be able to fix that by generating a unique ID for each sensor.
so far it works smooth.
The cameras I have were purchased from China with English firmware. Pretty sure the firmware is modded/hacked/custom.
I do not have a wireless capable camera, but I guess the base firmware they used to mod the cameras did.
I will just ignore these events, but they will be useful for those who do have a camera with wireless capability.
I have checked pydispatcher is installed and have moved the component to the appropriate directory under the app folder rather than the custom_component directory, but this hasnāt made any difference.
Just on a side note I am not sure I am getting the debug logging from the pyhik package.
With debug on I should at least get a return from line 62 of pyhik:
_LOGGING.debug("Initializing new hikvision device at: %s", host)
I do run my HA AND HA-dev under docker containers but that has never impacted this type of thing in the past.
I will dig around to see why I am not getting a full debug log.
Forget my post about debug logging. It was a config error on my part.
@mezz64 I am still not getting any events through to HA. I have added the complete debug log now that it is showing the package debug logging.
16-12-08 12:30:52 homeassistant.loader: Loaded binary_sensor.hikvision from homeassistant.components.binary_sensor.hikvision
16-12-08 12:30:52 homeassistant.bootstrap: Setting up binary_sensor
16-12-08 12:30:52 homeassistant.components.binary_sensor: Setting up binary_sensor.hikvision
16-12-08 12:30:52 pyhik.hikvision: Initializing new hikvision device at: http://192.168.2.146
16-12-08 12:30:53 pyhik.hikvision: Found events: ['VMD', 'linedetection', 'fielddetection', 'PIR', 'callhelp', 'WLSensor', 'WLSensor', 'WLSensor', 'WLSensor', 'WLSensor', 'WLSensor', 'WLSensor', 'WLSensor']
16-12-08 12:30:53 pyhik.hikvision: Initialized Dictionary: {'WL Alarm': [False, 1, 0, datetime.datetime(2016, 12, 8, 12, 30, 53, 32989)], 'PIR Alarm': [False, 1, 0, datetime.datetime(2016, 12, 8, 12, 30, 53, 32959)], 'Field Detection': [False, 1, 0, datetime.datetime(2016, 12, 8, 12, 30, 53, 32955)], 'Help Call': [False, 1, 0, datetime.datetime(2016, 12, 8, 12, 30, 53, 32962)], 'Motion': [False, 1, 0, datetime.datetime(2016, 12, 8, 12, 30, 53, 32879)], 'Line Crossing': [False, 1, 0, datetime.datetime(2016, 12, 8, 12, 30, 53, 32949)]}
16-12-08 12:30:53 pyhik.hikvision: Stream Thread Started: cam46, 2f1c9570-3aa0-11b5-83f6-c056e38fd4da
16-12-08 12:30:53 homeassistant.components.binary_sensor.hikvision: Entity: binary_sensor.cam46_wl_alarm, Options - Ignore: None, Delay: None
16-12-08 12:30:53 homeassistant.components.binary_sensor.hikvision: Entity: binary_sensor.cam46_pir_alarm, Options - Ignore: None, Delay: None
16-12-08 12:30:53 homeassistant.components.binary_sensor.hikvision: Entity: binary_sensor.cam46_field_detection, Options - Ignore: None, Delay: None
16-12-08 12:30:53 homeassistant.components.binary_sensor.hikvision: Entity: binary_sensor.cam46_help_call, Options - Ignore: None, Delay: None
16-12-08 12:30:53 homeassistant.components.binary_sensor.hikvision: Entity: binary_sensor.cam46_motion, Options - Ignore: None, Delay: None
16-12-08 12:30:53 homeassistant.components.binary_sensor.hikvision: Entity: binary_sensor.cam46_line_crossing, Options - Ignore: None, Delay: None
16-12-08 12:30:53 homeassistant.core: Bus:Handling <Event state_changed[L]: entity_id=binary_sensor.cam46_line_crossing, new_state=<state binary_sensor.cam46_line_crossing=off; sensor_class=motion, friendly_name=cam46 Line Crossing, last_tripped_time=2016-12-08T23:00:53.032949+10:30 @ 2016-12-08T12:30:53.037926+10:30>, old_state=None>
16-12-08 12:30:53 homeassistant.core: Bus:Handling <Event state_changed[L]: entity_id=binary_sensor.cam46_motion, new_state=<state binary_sensor.cam46_motion=off; sensor_class=motion, friendly_name=cam46 Motion, last_tripped_time=2016-12-08T23:00:53.032879+10:30 @ 2016-12-08T12:30:53.038544+10:30>, old_state=None>
16-12-08 12:30:53 homeassistant.core: Bus:Handling <Event state_changed[L]: entity_id=binary_sensor.cam46_help_call, new_state=<state binary_sensor.cam46_help_call=off; last_tripped_time=2016-12-08T23:00:53.032962+10:30, friendly_name=cam46 Help Call @ 2016-12-08T12:30:53.039100+10:30>, old_state=None>
16-12-08 12:30:53 homeassistant.core: Bus:Handling <Event state_changed[L]: entity_id=binary_sensor.cam46_field_detection, new_state=<state binary_sensor.cam46_field_detection=off; sensor_class=motion, friendly_name=cam46 Field Detection, last_tripped_time=2016-12-08T23:00:53.032955+10:30 @ 2016-12-08T12:30:53.039725+10:30>, old_state=None>
16-12-08 12:30:53 homeassistant.core: Bus:Handling <Event state_changed[L]: entity_id=binary_sensor.cam46_pir_alarm, new_state=<state binary_sensor.cam46_pir_alarm=off; sensor_class=motion, friendly_name=cam46 PIR Alarm, last_tripped_time=2016-12-08T23:00:53.032959+10:30 @ 2016-12-08T12:30:53.040285+10:30>, old_state=None>
16-12-08 12:30:53 homeassistant.core: Bus:Handling <Event state_changed[L]: entity_id=binary_sensor.cam46_wl_alarm, new_state=<state binary_sensor.cam46_wl_alarm=off; last_tripped_time=2016-12-08T23:00:53.032989+10:30, friendly_name=cam46 WL Alarm @ 2016-12-08T12:30:53.040894+10:30>, old_state=None>
16-12-08 12:30:53 homeassistant.core: Bus:Handling <Event component_loaded[L]: component=binary_sensor>
Iām still suspect of the WLSensor so Iāve made a version to add in some debugging and try to work backwards on figuring this out. Iām moving to only support known sensors for the time being, this means removing WLSensor from the supported list and ignoring it in the event stream.
I think the easiest way to track your issue down is more logging so I pushed a debug branch of pyHik (now at 0.0.5) that will log every event type that is being processed from the event stream. You can find the branch at the link below and can install it via pip as you did the first time around. Please uninstall your current version first and make sure your HASS hikvision.py file requirements points to pyhik version 0.0.5.
https://github.com/mezz64/pyHik/tree/debug
If the event stream processing thread is working correctly this should produce a ton of entries in your log as the videoloss event flows through the stream multiple times per minute.
I have found the problem.
line 249
elif str_line.find('--boundary') != -1:
for my camera it is āāhikboundaryā
FYI,
I added some extra debugging to get the stream as the package see it and dump it to the log.
16-12-08 13:32:17 pyhik.hikvision: Start of event message
16-12-08 13:32:17 pyhik.hikvision: line: b''
16-12-08 13:32:17 pyhik.hikvision: line: b'<EventNotificationAlert version="1.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">'
16-12-08 13:32:17 pyhik.hikvision: line: b'<ipAddress>192.168.2.146</ipAddress>'
16-12-08 13:32:17 pyhik.hikvision: line: b'<portNo>80</portNo>'
16-12-08 13:32:17 pyhik.hikvision: line: b'<protocol>HTTP</protocol>'
16-12-08 13:32:17 pyhik.hikvision: line: b'<macAddress>c0:56:e3:8f:d4:da</macAddress>'
16-12-08 13:32:17 pyhik.hikvision: line: b'<channelID>1</channelID>'
16-12-08 13:32:17 pyhik.hikvision: line: b'<dateTime>2016-12-08T13:32:17+09:30</dateTime>'
16-12-08 13:32:17 pyhik.hikvision: line: b'<activePostCount>275</activePostCount>'
16-12-08 13:32:17 pyhik.hikvision: line: b'<eventType>VMD</eventType>'
16-12-08 13:32:17 pyhik.hikvision: line: b'<eventState>active</eventState>'
16-12-08 13:32:17 pyhik.hikvision: line: b'<eventDescription>Motion alarm</eventDescription>'
16-12-08 13:32:17 pyhik.hikvision: line: b'<DetectionRegionList>'
16-12-08 13:32:17 pyhik.hikvision: line: b'</DetectionRegionList>'
16-12-08 13:32:17 pyhik.hikvision: line: b'</EventNotificationAlert>'
16-12-08 13:32:17 pyhik.hikvision: line: b'--hikboundary'
16-12-08 13:32:17 pyhik.hikvision: Message boundry found
16-12-08 13:32:17 pyhik.hikvision: String Parsed
16-12-08 13:32:17 pyhik.hikvision: Hik Processing Stream
16-12-08 13:32:17 pyhik.hikvision: line: b'Content-Type: application/xml; charset="UTF-8"'
16-12-08 13:32:17 pyhik.hikvision: line: b'Content-Length: 519'
Can you make that change locally and double check it fixes your issue? If it does iāll just expand the check to look for either qualifier.