evilmarty / mjpeg-timelapse

Mjpeg Timelapse integration for Home Assistant
MIT License
24 stars 4 forks source link

Error-Log: Platform mjpeg_timelapse does not generate unique IDs. #4

Closed snoopy0815 closed 2 years ago

snoopy0815 commented 2 years ago

Whilst trying to setup two timelapse configuration entities for the same camera stream I stumbled across this error-log. Use-case: Setup two different timelapse configurations from same camera-url. e.g. one for long time timelapse - everyday at 12:00 o'clock - preserve for 1 year and another from the same camera-url with short time timelapse - just the current day every 5 minutes - preserve for 1 day

unfortunately this is not possible, due to the fact that the url is used to generate the unique ID for home assistant.

possible fix: use the given name to generate the unique ID?

camera.py instead of:

[...]
self._attr_unique_id = hashlib.sha256(self._attr_image_url.encode("utf-8")).hexdigest()

use:

[...]
self._attr_unique_id = hashlib.sha256(self._attr_name.encode("utf-8")).hexdigest()

cheers!

evilmarty commented 2 years ago

The other option is to just change the URL by appending a query string.