Skip to content

Commit

Permalink
Merge pull request #6 from korapp/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
korapp authored Sep 13, 2023
2 parents 8fc52c4 + b8454b2 commit 705dbda
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 13 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,15 @@ Add Home Assistant to your plasma desktop.

* Active KDE Wallet
* Qt >= 5.14, KDE Frameworks >= 5.77, KDE Plasma >= 5.19 (e.g. Kubuntu 21.04 and newer)
* **qml-module-qtwebsockets package installed (for Debian/Ubuntu based distro)**\
Please remember to restart plasma or re-login after installing the dependency.
* **Qt WebSocket package installed**

Base | Required package
--|--
Debian, Ubuntu | qml-module-qtwebsockets
Arch, Fedora | qt5-websockets
openSUSE | libQt5WebSockets5

Please remember to restart plasma or re-login after installing the dependency.

## Installation

Expand Down
2 changes: 0 additions & 2 deletions package/contents/code/model.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const toggleableDomains = ['switch', 'light', 'cover'];
const activeStates = ['on', 'open'];

function getDisplayValue({ state, domain, attribute, attributes }) {
Expand All @@ -22,7 +21,6 @@ export function Entity({ entity_id = '', domain, name, icon, attribute = '', def
this.default_action = default_action
this.active = activeStates.includes(state)
this.domain = entity_id.substring(0, entity_id.indexOf('.'))
this.toggleable = toggleableDomains.includes(this.domain)
this.state = state
this.value = getDisplayValue({ state, domain: this.domain, attribute, attributes })
}
Expand Down
18 changes: 13 additions & 5 deletions package/contents/ui/ConfigGeneral.qml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,12 @@ Kirigami.FormLayout {
TextField {
id: url
onEditingFinished: Secrets.entryKey = url.text
placeholderText: "http://homeassistant.local:8123"
Kirigami.FormData.label: i18n("Home Assistant URL")
}

Kirigami.InlineMessage {
text: `<a href="${url.text}/profile">${i18n("Get token from your HA profile page")}</a>`
onLinkActivated: Qt.openUrlExternally(link)
visible: !token.text && url.text
Layout.fillWidth: true
Label {
text: i18n("Make sure the URL includes the protocol and port. For example:\nhttp://homeassistant.local:8123\nhttps://example.duckdns.org")
}

TextField {
Expand All @@ -38,6 +36,16 @@ Kirigami.FormLayout {
Kirigami.FormData.label: i18n("Token")
}

Label {
text: i18n("Get token from your profile page")
}

Label {
text: `<a href="${url.text}/profile">${url.text}/profile</a>`
onLinkActivated: Qt.openUrlExternally(link)
visible: url.text
}

Item {
Kirigami.FormData.isSection: true
Kirigami.FormData.label: i18n("Look")
Expand Down
4 changes: 1 addition & 3 deletions package/contents/ui/Entity.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ import 'mdi'

PlasmaComponents3.Button {
enabled: !!model.default_action.service
checkable: model.toggleable
checked: model.active
down: model.active
flat: plasmoid.configuration.flat
onClicked: ha.callService(model.default_action)
onCheckedChanged: ha.callService(model.default_action)

contentItem: GridLayout {
id: grid
Expand Down
2 changes: 1 addition & 1 deletion package/contents/ui/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Item {
subscribe()
onItemsChanged.connect(subscribe)
}
onStateChanged: updateState(state)
}

function updateState(event) {
Expand Down Expand Up @@ -64,6 +65,5 @@ Item {
const entities = items.map(i => i.entity_id)
ha.getStates(entities).then(initState)
subscription = ha.subscribeState(entities)
ha.onStateChanged.connect(updateState)
}
}

0 comments on commit 705dbda

Please sign in to comment.