Currently Amcrest supports multiple services but not corresponding sensors to see if they worked or not.
Please include in binary_sensor:
BINARY_SENSOR_MOTION_DETECTION = "motion_detection"
BINARY_SENSOR_RECORD_ON_MOTION = "record_on_motion"
BINARY_SENSOR_AUDIO = "audio"
.
.
.
BINARY_SENSOR_MOTION_DETECTION: ("Motion Detection", None, "mdi:motion-sensor"),
BINARY_SENSOR_RECORD_ON_MOTION: ("Record on Motion", None, "mdi:record-rec"),
BINARY_SENSOR_AUDIO: ("Audio", DEVICE_CLASS_SOUND, None),
.
.
.
def __extract_status(self, dahua_attribute):
ret = self._api.motion_detection
full_dahua_attribute = ".{}=".format(dahua_attribute)
status = [s for s in ret.split() if full_dahua_attribute in s][0]\
.split('=')[-1]
if status.lower() == 'true':
return True
else:
return False
def update(self):
"""Update entity."""
if not self.available:
return
_LOGGER.debug("Updating %s binary sensor", self._name)
try:
if self._sensor_type == BINARY_SENSOR_MOTION_DETECTED:
self._state = self._api.is_motion_detected
elif self._sensor_type == BINARY_SENSOR_ONLINE:
self._state = self._api.available
elif self._sensor_type == BINARY_SENSOR_MOTION_DETECTION:
self._state = self.__extract_status('Enable')
elif self._sensor_type == BINARY_SENSOR_RECORD_ON_MOTION:
self._state = self.__extract_status('RecordEnable')
elif self._sensor_type == BINARY_SENSOR_AUDIO:
self._state = self._api.audio_enabled