Initial commit
commit
3deb536717
|
@ -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);
|
|
@ -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/
|
Loading…
Reference in New Issue