commit 3deb536717417c340d899e29891b91f9f22a4b82 Author: Dustin C. Hatch Date: Wed Dec 7 10:47:17 2022 -0600 Initial commit diff --git a/ll-strategy-device-buttons.js b/ll-strategy-device-buttons.js new file mode 100644 index 0000000..6fa0b29 --- /dev/null +++ b/ll-strategy-device-buttons.js @@ -0,0 +1,54 @@ +// vim: set sw=2 ts=2 sts=2 et : + +class StrategyDeviceButtons { + + static async generateView(info) { + const { device_name } = info.view.strategy.options; + + const [devices, entities] = await Promise.all([ + info.hass.callWS({ type: "config/device_registry/list" }), + info.hass.callWS({ type: "config/entity_registry/list" }), + ]); + + const cards = []; + + let device_id; + for (const device of devices) { + if (device.name == device_name) { + device_id = device.id; + break; + } + } + if (!device_id) { + console.error("Could not find device id"); + } + + for (const entity of entities) { + if (device_id && entity.device_id == device_id) { + cards.push({ + type: "button", + entity: entity.entity_id, + show_state: true, + tap_action: { + action: "toggle", + }, + }); + } + } + + return { + "type": "panel", + "cards": [ + { + type: "grid", + columns: 4, + cards, + }, + ], + }; + + } + +} + +customElements.define("ll-strategy-device-buttons", StrategyDeviceButtons); diff --git a/sync-hass.zsh b/sync-hass.zsh new file mode 100644 index 0000000..9b15a21 --- /dev/null +++ b/sync-hass.zsh @@ -0,0 +1,9 @@ +#!/bin/zsh +# vim: set sw=4 ts=4 sts=4 et : + +inotifywait -m -e close_write . \ + | while read _ _ name; do + [[ ${name} = *.js ]] || continue + printf 'put %s\n' "${name}" + done \ + | sftp homeassistant@hass2.pyrocufflink.blue:www/resources/