Skip to content

Home Information - Your home, your data, organized.

Python

Enhance Entity History Modal with Video Browsing (#116)

Tony C9962cbbd0d28
diff --git a/src/hi/apps/entity/templates/entity/panes/entity_state_status_card.html b/src/hi/apps/entity/templates/entity/panes/entity_state_status_card.html
index 52afe43a..95fd4b07 100644
--- a/src/hi/apps/entity/templates/entity/panes/entity_state_status_card.html
+++ b/src/hi/apps/entity/templates/entity/panes/entity_state_status_card.html
@@ -24,6 +24,18 @@
<div class="align-self-center">
{{ entity_state_status_data.entity_state.name }}
</div>
+ <div class="align-self-center ml-auto">
+ {% with sensor_response=entity_state_status_data.latest_sensor_response %}
+ {% if sensor_response and sensor_response.sensor.provides_video_stream %}
+ <small>
+ <a href="{% url 'console_entity_video_sensor_history' entity_id=sensor_response.sensor.entity_state.entity.id sensor_id=sensor_response.sensor.id %}"
+ data-async="true" class="text-muted">
+ 📹 Browse Video
+ </a>
+ </small>
+ {% endif %}
+ {% endwith %}
+ </div>
</div>
{% empty %}
diff --git a/src/hi/apps/sense/templates/sense/panes/sensor_history_list.html b/src/hi/apps/sense/templates/sense/panes/sensor_history_list.html
index 4fb022f9..6b6fc6e7 100644
--- a/src/hi/apps/sense/templates/sense/panes/sensor_history_list.html
+++ b/src/hi/apps/sense/templates/sense/panes/sensor_history_list.html
@@ -4,10 +4,19 @@
{% for sensor_history in sensor_history_list %}
<li>
{% if sensor_history.details %}
- <a href="{% url 'sense_sensor_history_details' sensor_history_id=sensor_history.id %}"
- data-async="true">
- {{ sensor_history.response_datetime|localtime }} : {{ sensor_history.value }}
- </a>
+ {% if sensor.provides_video_stream and sensor_history.has_video_stream %}
+ {# Redirect video streams to enhanced video browser #}
+ <a href="{% url 'console_entity_video_sensor_history_detail' entity_id=sensor.entity_state.entity.id sensor_id=sensor.id sensor_history_id=sensor_history.id %}"
+ data-async="true">
+ {{ sensor_history.response_datetime|localtime }} : {{ sensor_history.value }}
+ </a>
+ {% else %}
+ {# Use existing sensor history details modal for non-video sensors #}
+ <a href="{% url 'sense_sensor_history_details' sensor_history_id=sensor_history.id %}"
+ data-async="true">
+ {{ sensor_history.response_datetime|localtime }} : {{ sensor_history.value }}
+ </a>
+ {% endif %}
{% else %}
{{ sensor_history.response_datetime|localtime }} : {{ sensor_history.value }}
{% endif %}
@@ -16,8 +25,15 @@
<div><em>No history.</em></div>
{% endfor %}
{% if show_all_link and sensor_history_list %}
- <a href="{% url 'sense_sensor_history' sensor_id=sensor.id %}"
- data-async="true">&gt;&gt; See All</a>
+ {% if sensor.provides_video_stream %}
+ {# Redirect to enhanced video browser for video sensors #}
+ <a href="{% url 'console_entity_video_sensor_history' entity_id=sensor.entity_state.entity.id sensor_id=sensor.id %}"
+ data-async="true">&gt;&gt; See All</a>
+ {% else %}
+ {# Use existing sensor history modal for non-video sensors #}
+ <a href="{% url 'sense_sensor_history' sensor_id=sensor.id %}"
+ data-async="true">&gt;&gt; See All</a>
+ {% endif %}
{% endif %}
</ul>
-{% endtimezone %}
+{% endtimezone %}
\ No newline at end of file