Clock that wakes on motion
Show more when someone is near.
{% let near = cap.alarm_motion.value == true %}<div class="face{% if near %} near{% endif %}"> <hd-clock class="time" show="time"></hd-clock> <div class="more"> <hd-clock class="date" show="date" date-style="long"></hd-clock> <p class="who">Someone is here</p> </div></div>The preview runs on a made-up sensor.motion device, so you don’t need a Homey. Edit the template or style to try something; actions don’t reach a device here.
Files
{% let near = cap.alarm_motion.value == true %}<div class="face{% if near %} near{% endif %}"> <hd-clock class="time" show="time"></hd-clock> <div class="more"> <hd-clock class="date" show="date" date-style="long"></hd-clock> <p class="who">Someone is here</p> </div></div>:host { display: block; height: 100%; container-type: size;}.face { position: relative; height: 100%; display: grid; place-items: center;}/* Far: only the time, big. */.time { font: var(--hd-number-weight) 30cqmin / 1 var(--hd-font-display); font-variant-numeric: tabular-nums; transition: scale var(--hd-motion-slow) var(--hd-ease-spring), translate var(--hd-motion-slow) var(--hd-ease-spring);}/* Near: the time makes room and the details rise into view, one after the other. */.near .time { scale: 0.8; translate: 0 -12cqh;}.more { position: absolute; inset-inline: 0; top: 58%; display: grid; justify-items: center; gap: 4px; font: 500 max(13px, 6cqmin) var(--hd-font-ui); color: var(--hd-text-muted);}.more > * { margin: 0; opacity: 0; translate: 0 8px; transition: opacity var(--hd-motion-base) var(--hd-ease-out), translate var(--hd-motion-base) var(--hd-ease-out);}.near .more > * { opacity: 1; translate: 0 0;}.near .more > :nth-child(2) { transition-delay: 60ms;}.date { color: var(--hd-text);}{ "id": "@your-handle/motion-near", "title": "Clock that wakes on motion", "summary": "Show more when someone is near.", "version": "1.0.0", "licence": "MIT", "tags": [], "kind": "widget", "widget": { "kind": "device", "match": { "requires": [ "alarm_motion" ], "optional": [ "measure_battery", "alarm_battery" ] }, "size": { "default": [ 2, 4 ], "min": [ 1, 1 ], "max": [ 4, 8 ] }, "align": { "x": "start", "y": "end" }, "settings": [ { "name": "tileTap", "label": "The tile", "required": false, "group": "tap", "type": "tap", "gesture": "tap", "default": { "type": "none" }, "hold": { "type": "device" }, "double": { "type": "none" }, "allow": [ "toggle", "device", "dashboard", "flow", "mood", "variable", "request" ] } ], "basedOn": "sensor.motion" }}Use it
In the editor, start from the widget it’s based on and paste the template and style; or unzip the package, replace your-handle with your name in the Community and publish it. Build your first widget walks through both.