{% extends "base.html" %} {% block title %}{{ board.name }} – Tuya Cloud Gateway{% endblock %} {% block content %}
{# ── Page header ──────────────────────────────────────────────────── #}

{{ board.name }}

Tuya Cloud Gateway {% if board.is_online %} Online {% else %} Offline {% endif %}
{% if current_user.is_admin() %}
Tuya Settings {% endif %}
{# ── Flash messages ───────────────────────────────────────────────── #} {% with messages = get_flashed_messages(with_categories=true) %} {% if messages %} {% for cat, msg in messages %} {% endfor %} {% endif %} {% endwith %} {# ── No token warning ─────────────────────────────────────────────── #} {% if not has_token %} {% endif %} {# ── Device grid ──────────────────────────────────────────────────── #} {% if devices %}
{% for dev in devices %} {% set icon_cls = { 'switch': 'bi-toggles', 'light': 'bi-lightbulb-fill', 'fan': 'bi-fan', 'sensor': 'bi-thermometer-half', 'cover': 'bi-door-open', }.get(dev.kind, 'bi-plug') %}
{{ dev.name }}
{% if dev.is_online %} Online {% else %} Offline {% endif %}
{{ dev.kind | capitalize }} {% if dev.product_name %} – {{ dev.product_name }} {% endif %}
{# ── Switch / light / fan toggles ─────────────────────────── #} {% if dev.kind in ('switch', 'light', 'fan') and dev.switch_dps %}
{% for dp in dev.switch_dps %} {% set ch_idx = loop.index0 %} {% set ch_on = dev.status.get(dp, False) %}
{% if dev.num_channels == 1 %}Power{% else %}CH{{ loop.index }}{% endif %}
{% endfor %}
{# ── Sensor – show formatted live readings ────────────────── #} {% elif dev.kind == 'sensor' %} {# Hide config/threshold keys that clutter the card #} {% set _skip_suffixes = ['_set', '_alarm', '_convert', '_mode'] %}
{% for k, v in dev.status.items() %} {% set _hide = namespace(val=false) %} {% for sfx in _skip_suffixes %} {% if k.endswith(sfx) %}{% set _hide.val = true %}{% endif %} {% endfor %} {% if not _hide.val %} {% set fv = v | tuya_dp(k, dev.status) %}
{{ k }}
{% if fv is sameas true %}on {% elif fv is sameas false %}off {% else %}{{ fv }}{% endif %}
{% endif %} {% endfor %}
{% endif %}
{% endfor %}
{% else %}

No Tuya devices found.

{% if has_token %}
{% endif %}
{% endif %}
{% endblock %} {% block scripts %} {% endblock %}