Skip to content
This repository has been archived by the owner on Mar 19, 2023. It is now read-only.

Commit

Permalink
Tidy attributes and remove classifier from events
Browse files Browse the repository at this point in the history
  • Loading branch information
robmarkcole committed Oct 10, 2019
1 parent 5b9d071 commit 26beba6
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 11 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,8 @@ Configuration variables:
</p>

#### Event `image_processing.object_detected`
An event `image_processing.object_detected` is fired for each object detected above the configured `confidence` threshold. An example use case for this is incrementing a [counter](https://www.home-assistant.io/components/counter/) when a person is detected. The `image_processing.object_detected` event payload includes:
An event `image_processing.object_detected` is fired for each object detected above the configured `confidence` threshold. This is the recommended way to check the confidence of detections, and to keep track of objects that are not configured as the `target` (configure logger level to `debug` to observe events in the Home Assistant logs). An example use case for event is to get an alert when some rarely appearing object is detected, or to increment a [counter](https://www.home-assistant.io/components/counter/). The `image_processing.object_detected` event payload includes:

- `classifier` : the classifier (i.e. `deepstack_object`)
- `entity_id` : the entity id responsible for the event
- `object` : the object detected
- `confidence` : the confidence in detection in the range 0 - 1 where 1 is 100% confidence.
Expand All @@ -98,7 +97,6 @@ An example automation using the `image_processing.object_detected` event is give
#### Event `image_processing.file_saved`
If `save_file_folder` is configured, an new image will be saved with bounding boxes of detected `target` objects, and the filename will include the time of the image capture. On saving this image a `image_processing.file_saved` event is fired, with a payload that includes:

- `classifier` : the classifier (i.e. `deepstack_object`)
- `entity_id` : the entity id responsible for the event
- `file` : the full path to the saved file

Expand Down
10 changes: 2 additions & 8 deletions custom_components/deepstack_object/image_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@

_LOGGER = logging.getLogger(__name__)

CLASSIFIER = "deepstack_object"
CONF_API_KEY = "api_key"
CONF_TARGET = "target"
CONF_TIMEOUT = "timeout"
Expand Down Expand Up @@ -265,7 +264,6 @@ def fire_prediction_events(self, predictions, confidence):
self.hass.bus.fire(
EVENT_OBJECT_DETECTED,
{
"classifier": CLASSIFIER,
ATTR_ENTITY_ID: self.entity_id,
OBJECT: prediction["label"],
ATTR_CONFIDENCE: ds.format_confidence(prediction["confidence"]),
Expand All @@ -275,8 +273,7 @@ def fire_prediction_events(self, predictions, confidence):
def fire_saved_file_event(self, save_path):
"""Fire event when saving a file"""
self.hass.bus.fire(
EVENT_FILE_SAVED,
{"classifier": CLASSIFIER, ATTR_ENTITY_ID: self.entity_id, FILE: save_path},
EVENT_FILE_SAVED, {ATTR_ENTITY_ID: self.entity_id, FILE: save_path}
)

@property
Expand Down Expand Up @@ -307,10 +304,7 @@ def device_state_attributes(self):
"""Return device specific state attributes."""
attr = {}
attr["target"] = self._target
attr["target_confidences"] = self._targets_confidences
attr["summary"] = self._summary
if self._last_detection:
attr["last_detection"] = self._last_detection.strftime("%Y-%m-%d %H:%M:%S")
if hasattr(self, "_save_file_folder"):
attr["save_file_folder"] = self._save_file_folder
attr["summary"] = self._summary
return attr
Binary file modified docs/object_detail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 26beba6

Please sign in to comment.