Matter Door/Window Sensor and Google Home: Script for Announcing Door Open and Close Events

The Matter standard enables smart home devices from different manufacturers to work together in a reliable and secure way. One common use case is detecting when a door is opened or closed and announcing this event through Google Home speakers or sending notifications to connected devices.

This article demonstrates how to configure Google Home to announce door events using Matter-compatible sensors such as the Aqara Door and Window Sensor P2. The example uses Google Home script automations to broadcast voice announcements and trigger mobile notifications whenever the entrance door changes state.

Requirements

  • A Matter-compatible door and window sensor.
  • A Google Speaker for announcements.
  • The Google Home application with the script editor enabled, accessible via the web interface at https://home.google.com/ .

Door Closed Announcement Script

The following script broadcasts a voice message and sends a notification when the door transitions to the closed state (sensor reports openPercent = 0):

metadata:
  name: Door closed announcement
  description: Announce when the door is closed
automations:
  - starters:
      - type: device.state.OpenClose
        device: Entrance door - Entryway
        state: openPercent
        is: 0
    actions:
      - type: assistant.command.Broadcast
        message: The door was closed

      - type: home.command.Notification
        title: The door was closed
        body: The door was closedCode language: YAML (yaml)

Note: Replace "Entrance door - Entryway" in the scripts with the actual name of the Matter-compatible door and window sensor as configured in Google Home. The device name must match exactly for the automations to work correctly.

When the door closes, the Google Assistant broadcasts “The door was closed” on all Google Home devices in the household, and a push notification with the same text is sent to connected mobile devices.

Door Open Announcement Script

The following script performs the same action when the door opens (sensor reports openPercent = 100):

metadata:
  name: Door open announcement
  description: Announce when the door is open
automations:
  - starters:
      - type: device.state.OpenClose
        device: Entrance door - Entryway
        state: openPercent
        is: 100
    actions:
      - type: assistant.command.Broadcast
        message: The door was opened

      - type: home.command.Notification
        title: The door was opened
        body: The door was openedCode language: YAML (yaml)

Note: Replace "Entrance door - Entryway" in the scripts with the actual name of the Matter-compatible door and window sensor as configured in Google Home. The device name must match exactly for the automations to work correctly.

In this case, Google Assistant announces “The door was opened” and the same message is sent as a push notification.

Conclusion

Combining a Matter-compatible door sensor with Google Home scripts provides real-time feedback whenever a door is opened or closed. It delivers both audible alerts throughout the home and push notifications to mobile devices, enhancing awareness and security.

quick-sdcv.el, a package that enables Emacs to function as an offline dictionary using sdcv

Build Status MELPA MELPA Stable License

The quick-sdcv.el package serves as a lightweight Emacs interface for the sdcv command-line interface, which is the console version of the StarDict dictionary application.

This package enables Emacs to function as an offline dictionary.

This integration allows users to access sdcv dictionary functionalities directly within the Emacs environment, leveraging the capabilities of sdcv to look up words and translations from various dictionary files.

Here are the main interactive functions:

  • quick-sdcv-search-at-point: Searches the word around the cursor and displays the result in a buffer.
  • quick-sdcv-search-input: Searches the input word and displays the result in a buffer.

If this enhances your workflow, please show your support by ⭐ starring quick-sdcv on GitHub to help more Emacs users discover its benefits.

Table of Contents

Prerequisite

  • The sdcv command. (It can usually be installed by installing the sdcv package.)
  • Download dictionaries from: http://download.huzheng.org/ . Once the dictionaries are downloaded, extract them into /usr/share/stardict/dic/, or configure the variable quick-sdcv-dictionary-data-dir in the Emacs configuration to specify an alternative dictionary path.

Installation

To install quick-sdcv on Emacs from MELPA:

  1. If you haven’t already done so, add MELPA repository to your Emacs configuration.

  2. Add the following code at the very beginning of your init.el file, before all other packages:

    (use-package quick-sdcv
    :ensure t
    :custom
    (quick-sdcv-dictionary-prefix-symbol "►")
    (quick-sdcv-ellipsis " ▼"))

Usage

To retrieve the word under the cursor and display its definition in a buffer:

(quick-sdcv-search-at-point)

To prompt the user for a word and display its definition in a buffer:

(quick-sdcv-search-input)

Customizations

To create a unique buffer for each word lookup, set the following:

;; Controls whether each word lookup creates a separate buffer.
;; Its default value is nil, but it can be set to t to enable unique buffers.
;;
;; When non-nil, a distinct buffer is created for each word searched. For
;; example, searching for the word "computer" produces a buffer named
;; "*sdcv:computer*". When nil, all lookups share the same buffer, typically
;; named "*sdcv*".
;;
;; The naming of unique buffers can be further customized using the variables:
;; - 'quick-sdcv-buffer-name-prefix'
;; - 'quick-sdcv-buffer-name-separator'
;; - 'quick-sdcv-buffer-name-suffix'
(setq quick-sdcv-unique-buffers t)

To perform exact word searches (as opposed to fuzzy searches), use:

;; To perform exact word searches (as opposed to fuzzy searches), use:
(setq quick-sdcv-exact-search t)

To change the prefix character used before dictionary names, replacing the default -->, set:

;; To change the prefix character used before dictionary names, replacing the
;; default `-->`, set:
(setq quick-sdcv-dictionary-prefix-symbol "►")

Customize the quick-sdcv dictionaries ellipsis display:

;; Customize the *quick-sdcv* dictionaries ellipsis display. In quick-sdcv
;; buffers, `outline-minor-mode' is enabled by default, which allows sections
;; corresponding to individual dictionaries to be folded. The ellipsis (…)
;; indicates a folded section, making it easy to collapse all dictionaries and
;; expand only those of interest
(setq quick-sdcv-ellipsis " ▼")

To customize the sdcv history size:

;; Customize the sdcv history size
(setq quick-sdcv-hist-size 100)

To specify the path to the sdcv executable:

;; Specify the path to the sdcv executable:
(setq quick-sdcv-program "/path/to/sdcv")

To customize the naming convention of the SDCV buffer:

;; Customize the naming convention of the SDCV buffer:
(setq quick-sdcv-buffer-name-prefix "*sdcv"
      quick-sdcv-buffer-name-separator ":"
      quick-sdcv-buffer-name-suffix "*")

To specify a list of dictionaries (NOT RECOMMENDED. It is better to let sdcv show all dictionaries):

;; To specify a list of dictionaries (NOT RECOMMENDED. It is better to let sdcv
;; show all dictionaries):
(setq quick-sdcv-dictionary-complete-list '("stardict-WordNet"
                                            "stardict-Webster"
                                            "stardict-eng_eng_main"))

Usage

Below are the commands you can use:

Command Description
quick-sdcv-search-at-point Searches the word around the cursor and displays the result in a buffer.
quick-sdcv-search-input Searches the input word and displays the result in a buffer.

If the current mark is active, the quick-sdcv will translate the region string; otherwise, they will translate the word around the cursor.

Frequently asked question

How to make the sdcv buffer replace the current buffer?

To make K search for the word using quick-sdcv when editing Markdown, you can customize the behavior as follows:

(add-to-list 'display-buffer-alist '("\\*sdcv"
                                       (display-buffer-same-window)))

How to make links appear as links in an sdcv buffer?

To ensure that links appear as clickable links in the SDCV buffer while using quick-sdcv, add the following hook:

(add-hook 'quick-sdcv-mode-hook #'goto-address-mode)

Evil mode: How to configure the default K key to search for words using quick-sdcv?

In Evil-mode, the K key in normal mode typically triggers a help function. While viewing a word’s definition in a quick-sdcv buffer, pressing K in normal mode jumps to the definition of the word at point.

This behavior can be configured in other modes, allowing, for instance, the definition of a word to be displayed by pressing K while editing a Markdown or Org file.

For example, to configure K to search for a word using quick-sdcv when editing Markdown or Org files, use the following customization:

(dolist (mode-hook '(markdown-mode-hook org-mode-hook))
  (add-hook mode-hook
            (lambda ()
              (setq-local evil-lookup-func #'quick-sdcv-search-at-point))))

What is the difference between sdcv and quick-sdcv Emacs packages?

The quick-sdcv Emacs package is a fork of sdcv.el version 3.4, which is available on MELPA. The primary differences between the two packages are as follows:

  • Less dependencies: Quick-sdcv does not require any external dependencies; sdcv, on the other hand, installs popup, pos-tip, and showtip.
  • Customize the buffer name:: New variables to customize whether the word is included in the buffer name, as well as the prefix, separator, and suffix of the buffer name (quick-sdcv-unique-buffers, quick-sdcv-buffer-name-prefix, quick-sdcv-buffer-name-separator, and quick-sdcv-buffer-name-suffix). When the buffer is dedicated to a specific word, refresh it only when the buffer is created.
  • Improved Outline Minor Mode: The quick-sdcv package fixes the outline minor mode for dictionary folding, enabling users to collapse all definitions for quicker navigation through dictionaries.
  • Default Language Settings: Various issues have been addressed, including changing the default language setting from Chinese (zh) to nil, providing a more neutral starting point.
  • Buffer Customization: The quick-sdcv package employs display-buffer, allowing users to customize the display of the sdcv buffer and control its placement through display-buffer-alist.
  • Removal of bugs and Warnings: All Emacs warnings have been eliminated and bugs fixed. (e.g., when sdcv-search-at-point cannot locate the word under the cursor)
  • Code Simplification: The code has been simplified by removing unused variables and omitting features like posframe, text-to-speech using the ‘say’ command, the quick-sdcv-env-lang variable, and functions such as (quick-sdcv-scroll-up-one-line, quick-sdcv-scroll-down-one-line, quick-sdcv-next-line and quick-sdcv-prev-line) which are similar Emacs features. This simplification makes quick-sdcv easier to understand, maintain, and use by focusing solely on dictionary lookup functionality. Features like posframe and text-to-speech, which are not essential to core usage, are better suited as separate packages.
  • Keybindings removal: The default keybindings have been removed from quick-sdcv-mode to prevent conflicts with other modes and keeps the mode lightweight and adaptable for users’ preferences.
  • New options: quick-sdcv-ellipsis, quick-sdcv-hist-size, quick-sdcv-exact-search, quick-sdcv-buffer-name-prefix, quick-sdcv-buffer-name-separator, quick-sdcv-buffer-name-suffix, quick-sdcv-verbose
  • Various improvements: Unset the SDCV_PAGER environment variable, Ensure the buffer and the SDCV output are in UTF-8, Enhance dictionary representation with UTF-8 characters, Implement error handling for cases when the sdcv program is not found.

Links

Other Emacs packages by the same author:

  • minimal-emacs.d: This repository hosts a minimal Emacs configuration designed to serve as a foundation for your vanilla Emacs setup and provide a solid base for an enhanced Emacs experience.
  • compile-angel.el: Speed up Emacs! This package guarantees that all .el files are both byte-compiled and native-compiled, which significantly speeds up Emacs.
  • outline-indent.el: An Emacs package that provides a minor mode that enables code folding and outlining based on indentation levels for various indentation-based text files, such as YAML, Python, and other indented text files.
  • vim-tab-bar.el: Make the Emacs tab-bar Look Like Vim’s Tab Bar.
  • easysession.el: Easysession is lightweight Emacs session manager that can persist and restore file editing buffers, indirect buffers/clones, Dired buffers, the tab-bar, and the Emacs frames (with or without the Emacs frames size, width, and height).
  • elispcomp: A command line tool that allows compiling Elisp code directly from the terminal or from a shell script. It facilitates the generation of optimized .elc (byte-compiled) and .eln (native-compiled) files.
  • tomorrow-night-deepblue-theme.el: The Tomorrow Night Deepblue Emacs theme is a beautiful deep blue variant of the Tomorrow Night theme, which is renowned for its elegant color palette that is pleasing to the eyes. It features a deep blue background color that creates a calming atmosphere. The theme is also a great choice for those who miss the blue themes that were trendy a few years ago.
  • Ultyas: A command-line tool designed to simplify the process of converting code snippets from UltiSnips to YASnippet format.
  • dir-config.el: Automatically find and evaluate .dir-config.el Elisp files to configure directory-specific settings.
  • flymake-bashate.el: A package that provides a Flymake backend for the bashate Bash script style checker.
  • flymake-ansible-lint.el: An Emacs package that offers a Flymake backend for ansible-lint.
  • inhibit-mouse.el: A package that disables mouse input in Emacs, offering a simpler and faster alternative to the disable-mouse package.
  • enhanced-evil-paredit.el: An Emacs package that prevents parenthesis imbalance when using evil-mode with paredit. It intercepts evil-mode commands such as delete, change, and paste, blocking their execution if they would break the parenthetical structure.
  • stripspace.el: Ensure Emacs Automatically removes trailing whitespace before saving a buffer, with an option to preserve the cursor column.
  • persist-text-scale.el: Ensure that all adjustments made with text-scale-increase and text-scale-decrease are persisted and restored across sessions.
  • pathaction.el: Execute the pathaction command-line tool from Emacs. The pathaction command-line tool enables the execution of specific commands on targeted files or directories. Its key advantage lies in its flexibility, allowing users to handle various types of files simply by passing the file or directory as an argument to the pathaction tool. The tool uses a .pathaction.yaml rule-set file to determine which command to execute. Additionally, Jinja2 templating can be employed in the rule-set file to further customize the commands.

How I Designed an Ergonomic Workstation for IT Specialists to Enhance Focus, Comfort, and Efficiency

In modern software development and system administration, where prolonged computer use is routine, an optimized workstation is not a luxury but a necessity. The workspace I designed balances ergonomics, efficiency, and versatility. I’m sharing it here because I believe it’s always valuable to see how other IT specialists configure their setups, gain inspiration, and exchange ideas. Feel free to share your own workstation with me in the comments.

This is the ergonomic and productive workstation I designed to support sustained focus, comfort, and efficiency:

Sit-stand desk converter

The central element of the setup is the sit-stand desk converter. This adjustable mechanism allows transitions between sitting and standing positions. Alternating posture mitigates the risks associated with prolonged sedentary behavior, such as musculoskeletal discomfort and reduced metabolic health. Additionally, standing intermittently enhances alertness and cognitive engagement, factors I find critical during intensive coding or system monitoring tasks.

Split ergonomic keyboard

I rely on a split ergonomic keyboard to minimize ulnar deviation and allow my wrists to maintain a neutral alignment. This configuration alleviates strain on the median nerve, which is associated with repetitive strain injuries such as carpal tunnel syndrome. The tented design, coupled with wrist rests, promotes a relaxed forearm posture, reducing muscular fatigue during extended typing sessions.

I place the mouse and keypad in the middle, as it provides easier access than positioning them on the right side, ensuring my hands remain in a more neutral, less strained position.

The split keyboard is a mechanical model with Cherry MX Blue switches, providing tactile feedback optimal for intensive typing sessions.

Vertical and trackball mice

I use four distinct mice to accommodate diverse workflows and to mitigate repetitive strain.

I make deliberate use of both a vertical mouse and a trackball mouse to diversify input modalities. The vertical mouse maintains the forearm in a handshake position, minimizing pronation stress on the forearm muscles. Conversely, the trackball mouse eliminates the need for extensive wrist and arm movement, relying instead on finger manipulation. Alternating between these devices distributes musculoskeletal load, which I have found effective in mitigating repetitive strain risks.

External microphone with boom arm

An external cardioid microphone mounted on a boom arm optimizes voice clarity during virtual meetings or recordings I occasionally produce. The boom arm’s adjustability ensures optimal microphone placement without encroaching on desk real estate, and the microphone’s position at mouth level enhances audio quality while minimizing ambient noise capture.

Two computers

My workspace includes two computers: one for professional responsibilities, focused on secure infrastructure management and corporate development, and another for personal projects, supporting exploratory programming, open-source contributions, and experimental configurations.

Second curved monitor

A second curved monitor is positioned to the left, though it is not visible in the picture. I dedicate it primarily to multimedia tasks. By isolating these activities on a separate screen, I keep my primary workspace uncluttered and maintain an uninterrupted focus on development and system administration tasks. The curved design of the second monitor enhances immersion and reduces eye strain when glancing between displays, contributing to a more comfortable and efficient multitasking environment.

Conclusion

The workstation I maintain embodies a deliberate synthesis of ergonomic principles and productivity. Each component, from input devices to display configurations, is selected to minimize physical strain while maximizing functional efficiency. For a professional engaged in cognitively demanding, prolonged computing tasks, this setup harmonizes comfort with operational efficacy in a way that continually supports both focus and well-being.

Productivity: Time-saving tips for the digital age

Your computer is a powerful tool for enhancing productivity at work, but it can also be a significant source of inefficiency. Your time is a valuable resource. If, after hours of working at your computer, you find yourself accomplishing little, you may be among the many individuals distracted by the lure of the internet and digital technology.

If you excel at time management, having schedules, goals, and structure in place is commendable. However, the effectiveness of time management diminishes if the time allocated is not directed toward advancing meaningful tasks.

This article does not aim to teach you how to organize your time. Instead, it provides tips to help you avoid common pitfalls that lead to wasted time.

Below, you will find practical and tested advice to help you reclaim your day and accomplish significant tasks with the same level of effort:

  1. No mobile phone: Not everyone can do this, but for those who can, it’s worth a reminder. Personal (and sometimes even professional) phones can eat up your time with long, trivial conversations or spontaneous invitations. Put it on silent, or better yet, turn it off!
  2. Disable notifications: Notifications can constantly pull your attention. Notifications are a major distraction; disable them all!
  3. Avoid temptation: If you’ve stopped notifications, don’t actively seek distractions like social media, RSS readers, or irrelevant Google searches. These create even more temptations and waste your time.
  4. Enhance your email usage: Use a single email inbox by redirecting all accounts there. Set filters for less urgent emails, such as newsletters, and check your inbox sparingly; perhaps once an hour. Aim for an empty inbox to ease mental clutter.
  5. Disconnect from the internet: If your work doesn’t require internet access, disconnect! This significantly reduces distractions.
  6. Avoid radio, TV, Youtube, etc.: Background noise from radio or TV can distract you. Instead, consider curated podcasts to enjoy during breaks or after completing critical tasks.
  7. Organize your workspace: A clutter-free desk (physical or virtual) helps your mind focus. Keep only essential items visible. Create a well-organized folder structure on your computer for easy navigation.
  8. Separate work and personal accounts: Use separate user accounts on your computer for work and personal activities. This separation reduces the temptation to engage in distractions during work hours.
  9. Focus your internet searches: Avoid straying into unrelated topics when using search engines. Postpone non-urgent research for later.
  10. Defer non-urgent tasks: Keep a notebook to record non-urgent tasks for later. This helps reduce stress by freeing you from the pressure of trying to remember everything.

By implementing at least six of these recommendations, you will observe noticeable improvements in productivity and efficiency. You will gain more time and energy to focus on tasks that hold greater significance.

Regularly take breaks to maintain optimal mental performance and enhance productivity. Scheduling tools such as Workrave, can assist in managing breaks and preventing fatigue.

It is my hope that this article enables you to optimize your time effectively. If you have additional strategies to share, consider contributing them—they could be invaluable to others!