Skip to content

openhab-item@phoehnel: Initial submission#8461

Open
phoehnel wants to merge 2 commits intolinuxmint:masterfrom
phoehnel:openhab-item-phoehnel
Open

openhab-item@phoehnel: Initial submission#8461
phoehnel wants to merge 2 commits intolinuxmint:masterfrom
phoehnel:openhab-item-phoehnel

Conversation

@phoehnel
Copy link
Copy Markdown

New applet to display and control OpenHAB smart home items from the Cinnamon panel.

Features

  • Supports Switch, Dimmer, Number, String, Contact, Rollershutter, Color, DateTime, Player, and Group items
  • Multi-instance — add the applet multiple times for different items
  • Shared server configuration across instances (stored in $XDG_CONFIG_HOME with Gio.FileMonitor)
  • Double-click toggle for Switch/Dimmer items
  • Scroll-wheel dimmer control directly on the panel
  • Color items with live color swatch on panel and brightness slider in popup
  • Additional items in popup menu (e.g. lamp switch + brightness dimmer together)
  • Read-only mode, auto-close popup, configurable tooltip, custom icons
  • Soup 2/3 compatible HTTP client with optional Bearer token auth

Technical notes

  • All timers cleaned up in on_applet_removed_from_panel() using GLib.SOURCE_REMOVE/GLib.SOURCE_CONTINUE
  • Clutter events return Clutter.EVENT_STOP/Clutter.EVENT_PROPAGATE
  • All async network I/O (Soup)
  • No writes to installation directory — config stored via GLib.get_user_config_dir()
  • Compatible with SpiderMonkey 102+ (Cinnamon 5.4–6.6)

@github-actions
Copy link
Copy Markdown
Contributor

Best-practices scanner

This is a regex-based check for API usage that can pose security, performance or
maintainability issues, or that may already be provided by Cinnamon. Having code flagged
by it doesn't automatically disqualify a pull request.

This check is not perfect will not replace a normal review.


Found 13 potential issue(s):

⚠️ lang_bind

openhab-item@phoehnel/files/openhab-item@phoehnel/applet.js:74

this.actor.connect("scroll-event", Lang.bind(this, this._onScrollEvent));

Lang.bind() is deprecated. Use arrow functions (() => {}) or Function.prototype.bind() instead.

openhab-item@phoehnel/files/openhab-item@phoehnel/applet.js:77

this.menu.connect("open-state-changed", Lang.bind(this, this._onMenuOpenStateChanged));

Lang.bind() is deprecated. Use arrow functions (() => {}) or Function.prototype.bind() instead.

openhab-item@phoehnel/files/openhab-item@phoehnel/applet.js:80

this._serverConfig.startMonitor(Lang.bind(this, this._onSharedConfigChanged));

Lang.bind() is deprecated. Use arrow functions (() => {}) or Function.prototype.bind() instead.

openhab-item@phoehnel/files/openhab-item@phoehnel/applet.js:89

this.settings.bind("serverUrl", "serverUrl", Lang.bind(this, this._onServerSettingsChanged));

Lang.bind() is deprecated. Use arrow functions (() => {}) or Function.prototype.bind() instead.

openhab-item@phoehnel/files/openhab-item@phoehnel/applet.js:90

this.settings.bind("apiToken", "apiToken", Lang.bind(this, this._onServerSettingsChanged));

Lang.bind() is deprecated. Use arrow functions (() => {}) or Function.prototype.bind() instead.

openhab-item@phoehnel/files/openhab-item@phoehnel/applet.js:91

this.settings.bind("pollInterval", "pollInterval", Lang.bind(this, this._onPollIntervalChanged));

Lang.bind() is deprecated. Use arrow functions (() => {}) or Function.prototype.bind() instead.

openhab-item@phoehnel/files/openhab-item@phoehnel/applet.js:92

this.settings.bind("itemName", "itemName", Lang.bind(this, this._onItemChanged));

Lang.bind() is deprecated. Use arrow functions (() => {}) or Function.prototype.bind() instead.

openhab-item@phoehnel/files/openhab-item@phoehnel/applet.js:93

this.settings.bind("itemLabel", "itemLabel", Lang.bind(this, this._onDisplayChanged));

Lang.bind() is deprecated. Use arrow functions (() => {}) or Function.prototype.bind() instead.

openhab-item@phoehnel/files/openhab-item@phoehnel/applet.js:94

this.settings.bind("additionalItems", "additionalItems", Lang.bind(this, this._onItemChanged));

Lang.bind() is deprecated. Use arrow functions (() => {}) or Function.prototype.bind() instead.

openhab-item@phoehnel/files/openhab-item@phoehnel/applet.js:97

this.settings.bind("showIcon", "optShowIcon", Lang.bind(this, this._onDisplayChanged));

Lang.bind() is deprecated. Use arrow functions (() => {}) or Function.prototype.bind() instead.

⚠️ sync_file_get_contents

openhab-item@phoehnel/files/openhab-item@phoehnel/serverConfig.js:25

let [ok, contents] = GLib.file_get_contents(this._configPath);

Synchronous file_get_contents() blocks the main loop.
Use Gio.File.load_contents_async() instead.

⚠️ sync_file_query_exists

openhab-item@phoehnel/files/openhab-item@phoehnel/serverConfig.js:22

if (!file.query_exists(null)) {

query_exists() is a synchronous call that can block on slow/network filesystems.
Prefer attempting the operation and handling a Gio.IOErrorEnum.NOT_FOUND error instead.

openhab-item@phoehnel/files/openhab-item@phoehnel/serverConfig.js:59

if (!file.query_exists(null)) {

query_exists() is a synchronous call that can block on slow/network filesystems.
Prefer attempting the operation and handling a Gio.IOErrorEnum.NOT_FOUND error instead.


Automated pattern check.

  Replace all Lang.bind() calls with arrow functions and .bind(),
  convert synchronous file_get_contents() to Gio.File.load_contents_async(),
  and remove query_exists() calls in favor of try/catch error handling.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant