neiam
/home-assistant-plasmoid
Home Assistant Plasmoid
public · Issues · Pulls · Labels · Forks · Compare · Actions success · Badges · Packages
⭐
Log in to mark this repository.
pleasehelp
6924a66 · gmorell · 2025-06-23 20:12
Files changed
added
README.md
+73
−0
@@ -0,0 +1,73 @@
| 1 | +# Home Assistant Control Widget for Plasma 6 | |
| 2 | + | |
| 3 | +This is a Plasma 6 compatible widget for controlling Home Assistant entities from your KDE desktop. | |
| 4 | + | |
| 5 | +## Version 2.0 Changes (Plasma 6 Compatibility) | |
| 6 | + | |
| 7 | +This widget has been updated for Plasma 6 compatibility with the following changes: | |
| 8 | + | |
| 9 | +### Key Updates: | |
| 10 | +1. **Qt/QML Imports**: Updated to use version-less imports compatible with Qt6 | |
| 11 | +2. **Kirigami Integration**: Added proper Kirigami units and theming | |
| 12 | +3. **Configuration System**: Updated to use KCM.SimpleKCM for better integration | |
| 13 | +4. **Icon Handling**: Replaced deprecated PlasmaCore.IconItem with Kirigami.Icon | |
| 14 | +5. **Internationalization**: Added proper i18n() calls for all user-visible strings | |
| 15 | +6. **Layout Improvements**: Better responsive design using Kirigami.Units | |
| 16 | +7. **Tooltips**: Added proper tooltip integration | |
| 17 | + | |
| 18 | +### Technical Changes: | |
| 19 | +- Removed version numbers from import statements | |
| 20 | +- Updated `PlasmaCore.IconItem` to `Kirigami.Icon` | |
| 21 | +- Updated configuration UI to use `KCM.SimpleKCM` | |
| 22 | +- Added `QtQuick.Controls` as `QQC2` alias | |
| 23 | +- Updated action calls to use `plasmoid.internalAction()` | |
| 24 | +- Added proper switchWidth/switchHeight properties for compact representation | |
| 25 | + | |
| 26 | +## Installation | |
| 27 | + | |
| 28 | +The widget is installed in the standard Plasma widget location: | |
| 29 | +``` | |
| 30 | +~/.local/share/plasma/plasmoids/org.neiam.kde.homeassistant/ | |
| 31 | +``` | |
| 32 | + | |
| 33 | +## Configuration | |
| 34 | + | |
| 35 | +1. Right-click the widget and select "Configure" | |
| 36 | +2. Enter your Home Assistant URL (e.g., http://homeassistant.local:8123) | |
| 37 | +3. Enter your long-lived access token from Home Assistant | |
| 38 | +4. Set the update interval (5-300 seconds) | |
| 39 | + | |
| 40 | +## Compatibility | |
| 41 | + | |
| 42 | +- **Plasma 6+**: Fully compatible | |
| 43 | +- **Qt 6+**: Required | |
| 44 | +- **KDE Frameworks 6+**: Required | |
| 45 | + | |
| 46 | +## Development Notes | |
| 47 | + | |
| 48 | +This widget serves as a foundation for Home Assistant integration. Future versions may include: | |
| 49 | +- Entity state display | |
| 50 | +- Entity control buttons | |
| 51 | +- Custom entity selection | |
| 52 | +- Real-time updates via WebSocket | |
| 53 | + | |
| 54 | +## Files Structure | |
| 55 | + | |
| 56 | +``` | |
| 57 | +contents/ | |
| 58 | +├── config/ | |
| 59 | +│ ├── config.qml # Configuration categories | |
| 60 | +│ └── main.xml # Configuration schema | |
| 61 | +└── ui/ | |
| 62 | + ├── main.qml # Main widget UI | |
| 63 | + └── configGeneral.qml # Configuration page UI | |
| 64 | +metadata.json # Widget metadata | |
| 65 | +``` | |
| 66 | + | |
| 67 | +## Troubleshooting | |
| 68 | + | |
| 69 | +If the widget doesn't load: | |
| 70 | +1. Check Plasma version (must be 6+) | |
| 71 | +2. Verify all files are in the correct location | |
| 72 | +3. Restart Plasma: `systemctl --user restart plasma-plasmashell` | |
| 73 | +4. Check system logs: `journalctl --user -f | grep plasma` |
added
contents/config/config.qml
+10
−0
@@ -0,0 +1,10 @@
| 1 | +import QtQuick | |
| 2 | +import org.kde.plasma.configuration | |
| 3 | + | |
| 4 | +ConfigModel { | |
| 5 | + ConfigCategory { | |
| 6 | + name: i18n("General") | |
| 7 | + icon: "configure" | |
| 8 | + source: "configGeneral.qml" | |
| 9 | + } | |
| 10 | +} |
added
contents/config/main.xml
+31
−0
@@ -0,0 +1,31 @@
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" | |
| 3 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| 4 | + xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 | |
| 5 | + http://www.kde.org/standards/kcfg/1.0/kcfg.xsd"> | |
| 6 | + <kcfgfile name=""/> | |
| 7 | + | |
| 8 | + <group name="General"> | |
| 9 | + <entry name="homeAssistantUrl" type="String"> | |
| 10 | + <label>Home Assistant URL</label> | |
| 11 | + <default>http://homeassistant.local:8123</default> | |
| 12 | + </entry> | |
| 13 | + | |
| 14 | + <entry name="accessToken" type="String"> | |
| 15 | + <label>Access Token</label> | |
| 16 | + <default></default> | |
| 17 | + </entry> | |
| 18 | + | |
| 19 | + <entry name="updateInterval" type="Int"> | |
| 20 | + <label>Update Interval (seconds)</label> | |
| 21 | + <default>30</default> | |
| 22 | + </entry> | |
| 23 | + </group> | |
| 24 | + | |
| 25 | + <group name="Entities"> | |
| 26 | + <entry name="selectedEntities" type="StringList"> | |
| 27 | + <label>Selected Entities</label> | |
| 28 | + <default></default> | |
| 29 | + </entry> | |
| 30 | + </group> | |
| 31 | +</kcfg> |
added
contents/ui/configGeneral.qml
+36
−0
@@ -0,0 +1,36 @@
| 1 | +import QtQuick | |
| 2 | +import QtQuick.Controls as QQC2 | |
| 3 | +import QtQuick.Layouts | |
| 4 | +import org.kde.kirigami as Kirigami | |
| 5 | +import org.kde.kcmutils as KCM | |
| 6 | + | |
| 7 | +KCM.SimpleKCM { | |
| 8 | + id: configGeneral | |
| 9 | + | |
| 10 | + property alias cfg_homeAssistantUrl: homeAssistantUrlField.text | |
| 11 | + property alias cfg_accessToken: accessTokenField.text | |
| 12 | + property alias cfg_updateInterval: updateIntervalSpinBox.value | |
| 13 | + | |
| 14 | + Kirigami.FormLayout { | |
| 15 | + QQC2.TextField { | |
| 16 | + id: homeAssistantUrlField | |
| 17 | + Kirigami.FormData.label: i18n("Home Assistant URL:") | |
| 18 | + placeholderText: i18n("http://homeassistant.local:8123") | |
| 19 | + } | |
| 20 | + | |
| 21 | + QQC2.TextField { | |
| 22 | + id: accessTokenField | |
| 23 | + Kirigami.FormData.label: i18n("Access Token:") | |
| 24 | + placeholderText: i18n("Long-lived access token from Home Assistant") | |
| 25 | + echoMode: TextInput.Password | |
| 26 | + } | |
| 27 | + | |
| 28 | + QQC2.SpinBox { | |
| 29 | + id: updateIntervalSpinBox | |
| 30 | + Kirigami.FormData.label: i18n("Update Interval (seconds):") | |
| 31 | + from: 5 | |
| 32 | + to: 300 | |
| 33 | + value: 30 | |
| 34 | + } | |
| 35 | + } | |
| 36 | +} |
added
contents/ui/main.qml
+69
−0
@@ -0,0 +1,69 @@
| 1 | +import QtQuick | |
| 2 | +import QtQuick.Layouts | |
| 3 | +import org.kde.plasma.plasmoid | |
| 4 | +import org.kde.plasma.core as PlasmaCore | |
| 5 | +import org.kde.plasma.components as PlasmaComponents3 | |
| 6 | +import org.kde.kirigami as Kirigami | |
| 7 | + | |
| 8 | +PlasmoidItem { | |
| 9 | + id: root | |
| 10 | + | |
| 11 | + Layout.minimumWidth: Kirigami.Units.gridUnit * 8 | |
| 12 | + Layout.minimumHeight: Kirigami.Units.gridUnit * 4 | |
| 13 | + Layout.preferredWidth: Kirigami.Units.gridUnit * 12 | |
| 14 | + Layout.preferredHeight: Kirigami.Units.gridUnit * 6 | |
| 15 | + | |
| 16 | + switchWidth: Kirigami.Units.gridUnit * 5 | |
| 17 | + switchHeight: Kirigami.Units.gridUnit * 5 | |
| 18 | + | |
| 19 | + Plasmoid.backgroundHints: PlasmaCore.Types.DefaultBackground | PlasmaCore.Types.ConfigurableBackground | |
| 20 | + | |
| 21 | + property string homeAssistantUrl: plasmoid.configuration.homeAssistantUrl | |
| 22 | + property string accessToken: plasmoid.configuration.accessToken | |
| 23 | + property int updateInterval: plasmoid.configuration.updateInterval | |
| 24 | + | |
| 25 | + fullRepresentation: ColumnLayout { | |
| 26 | + anchors.fill: parent | |
| 27 | + anchors.margins: Kirigami.Units.smallSpacing | |
| 28 | + | |
| 29 | + PlasmaComponents3.Label { | |
| 30 | + text: i18n("Home Assistant Control") | |
| 31 | + font.bold: true | |
| 32 | + Layout.alignment: Qt.AlignHCenter | |
| 33 | + } | |
| 34 | + | |
| 35 | + PlasmaComponents3.Label { | |
| 36 | + text: i18n("Configure the widget to connect to your Home Assistant instance") | |
| 37 | + wrapMode: Text.WordWrap | |
| 38 | + Layout.fillWidth: true | |
| 39 | + Layout.alignment: Qt.AlignHCenter | |
| 40 | + horizontalAlignment: Text.AlignHCenter | |
| 41 | + } | |
| 42 | + | |
| 43 | + PlasmaComponents3.Button { | |
| 44 | + text: i18n("Configure") | |
| 45 | + Layout.alignment: Qt.AlignHCenter | |
| 46 | + onClicked: plasmoid.internalAction("configure").trigger() | |
| 47 | + } | |
| 48 | + | |
| 49 | + Item { | |
| 50 | + Layout.fillHeight: true | |
| 51 | + } | |
| 52 | + } | |
| 53 | + | |
| 54 | + compactRepresentation: Kirigami.Icon { | |
| 55 | + source: plasmoid.icon | |
| 56 | + anchors.fill: parent | |
| 57 | + | |
| 58 | + PlasmaCore.ToolTipArea { | |
| 59 | + anchors.fill: parent | |
| 60 | + mainText: i18n("Home Assistant Control") | |
| 61 | + subText: i18n("Click to open") | |
| 62 | + } | |
| 63 | + | |
| 64 | + MouseArea { | |
| 65 | + anchors.fill: parent | |
| 66 | + onClicked: root.expanded = !root.expanded | |
| 67 | + } | |
| 68 | + } | |
| 69 | +} |
added
metadata.json
+21
−0
@@ -0,0 +1,21 @@
| 1 | +{ | |
| 2 | + "KPlugin": { | |
| 3 | + "Authors": [ | |
| 4 | + { | |
| 5 | + "Email": "gmp@gmp.io", | |
| 6 | + "Name": "Gabe" | |
| 7 | + } | |
| 8 | + ], | |
| 9 | + "Category": "System Information", | |
| 10 | + "Description": "Control Home Assistant entities from your desktop", | |
| 11 | + "Icon": "home", | |
| 12 | + "Id": "org.neiam.kde.homeassistant", | |
| 13 | + "Name": "Home Assistant Control", | |
| 14 | + "Version": "2.0", | |
| 15 | + "Website": "http://neiam.org" | |
| 16 | + }, | |
| 17 | + "KPackageStructure": "Plasma/Applet", | |
| 18 | + "X-Plasma-API": "declarativeappletscript", | |
| 19 | + "X-Plasma-MainScript": "ui/main.qml", | |
| 20 | + "X-KDE-PlasmaDesktopFile": "Plasma/Applet" | |
| 21 | +} |
Parents: