Skip to main content

A tool to manage all of your openHASP device configs in a centralized place.

Project description

openhasp-config-manager

The missing management layer for your openHASP setup. A powerful suite of tools to simplify hardware UI design, combining a logic-aware config engine with a robust API client and deployment automation.

Features

๐Ÿ—๏ธ Advanced Configuration Engine

  • ๐Ÿ  Centralized Management: Manage an unlimited fleet of devices from one folder structure with shared configuration support.
  • ๐Ÿ› ๏ธ Smart JSONL Preprocessing:
    • Multiline Support: Write clean, readable blocks instead of giant single-line strings.
    • Jinja2 Templating: Power your UI with logic, math, and cross-object variables (e.g., {{ p1b1.y + 10 }}).
    • Comments: Use // to document your layout logic directly inside your .jsonl files.
    • YAML Variables: Define global and local variables to reuse values across your entire setup.
  • ๐ŸŽจ Global Theme Engine: Define styles (colors, fonts, radii) once and apply them to all objects instantly.

๐Ÿšข Smart Deployment & Validation

  • ๐Ÿ›ก๏ธ Early Error Detection: Automatically catch syntax mistakes in .jsonl and .cmd files before they hit your hardware.
  • ๐Ÿ”„ Delta Deployments: Save time and flash wearโ€”only upload what changed.
  • ๐Ÿ” Visual Diffs: Review exactly what will change with a git-style +/- line-by-line output.
  • ๐Ÿ“บ GUI Preview (WIP): Inspect and prototype your screens in a digital previewer before deploying.

๐Ÿ”Œ API & Interaction

  • ๐Ÿ“ก Unified API Client: Interact with your plates via a single Python interface over Web or MQTT.
  • โšก Command Execution: Send openHASP commands programmatically.
  • ๐Ÿ”” Real-time Events: Subscribe to button presses, state updates, and touch events as they happen.
  • ๐Ÿช„ AppDaemon Integration Utilities: Seamlessly integrate with AppDaemon for advanced automations and logic.

CLI

> openhasp-config-manager -h
Usage: openhasp-config-manager [OPTIONS] COMMAND [ARGS]...

Options:
  --version   Show the version and exit.
  -h, --help  Show this message and exit.

Commands:
  cmd         Sends a command request to a device.
  deploy      Combines the generation and upload of a configuration.
  generate    Generates the output files for all devices in the given...
  help        Show this message and exit.
  listen      Sends a state update request to a device.
  logs        Prints the logs of a device.
  screenshot  Requests a screenshot from the given device and stores it...
  shell       Connects to the telnet server of a device.
  state       Sends a state update request to a device.
  upload      Uploads the previously generated configuration to their...
  vars        Prints the variables accessible in a given path.

๐Ÿ› ๏ธ Project Status

I use openhasp-config-manager exclusively to manage my own openHASP devices. While it is my "daily driver", please keep in mind:

  • In Development: Iโ€™m actively adding tests and refining features to make it more robust.
  • Rough Edges: Error logging is still a bit basic. If something goes wrong, the logs might require some "detective work" to figure out the exact cause.
  • Experimental: Itโ€™s stable for my needs, but since every openHASP setup is unique, you might run into edge cases I haven't hit yet.

If you like the project and want to help polish those error logs or add features, Iโ€™m always happy to review an issue or a PR!

Setup

Docker

docker run -it --rm \
  --name openhasp-config-manager \
  --user 1000:1000 \
  -v "./openhasp-configs:/app/openhasp-configs" \
  -v "./output:/app/output" \
  ghcr.io/markusressel/openhasp-config-manager

Installation

Since openhasp-config-manager needs some dependencies (see here) it is recommended to install it inside a virtualenv.

venv-install

venv-install is a little helper tool to ease the installation, management and usage of python cli tools in venvs.

venv-install openhasp-config-manager openhasp-config-manager
openhasp-config-manager -h

Manual

Manual Installation & Uninstallation
mkdir -p ~/venvs/openhasp-config-manager
python3 -m venv ~/venvs/openhasp-config-manager
source ~/venvs/openhasp-config-manager/bin/activate
pip3 install openhasp-config-manager

And to use it:

source ~/venvs/openhasp-config-manager/bin/activate
openhasp-config-manager -h
openhasp-config-manager analyze -c "./openhasp-configs"
...

Uninstall

deactivate
rm -rf ~/venvs/openhasp-config-manager

Getting Started

openhasp-config-manager is first and foremost a configuration management system. Simply follow the basic folder structure and config deployment will become trivial. Please read all of this, as it is very important to understand the basic structure on which everything relies.

๐Ÿ“ Folder Structure

The following folders should reside inside a single parent folder, f.ex. named openhasp-configs. This folder can be located anywhere you like, but must be accessible to openhasp-config-manager when executing.

  • common: The common subdirectory can be used for files that should be included on all device. This folder is optional.
  • devices: The devices folder is required. It must contain one subfolder for each openHASP device you want to configure using openhasp-config-manager. It is recommended to name subfolders according to the physical devices associated with them.
    • touch_down_1 (example device folder)
      • A device folder contains *.jsonl, *.cmd and other files which should only be uploaded to that particular device.
      • You can create arbitrary nested folder structures for organizing the files. There is a limit to the file name length though, see FAQ
      • You must provide a config.json file, see config.json for more info.

A more advanced configuration layout could look something like this:

openhasp-configs
โ”œโ”€โ”€ common
โ”‚ย ย  โ”œโ”€โ”€ content
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ card.jsonl
โ”‚ย ย  โ”œโ”€โ”€ dialog
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ connected.jsonl
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ offline.jsonl
โ”‚ย ย  โ”œโ”€โ”€ navigation_bar.jsonl
โ”‚ย ย  โ””โ”€โ”€ page_header.jsonl
โ””โ”€โ”€ devices
    โ””โ”€โ”€ touch_down_1
        โ”œโ”€โ”€ 0_home
        โ”‚ย ย  โ”œโ”€โ”€ 0_header.jsonl
        โ”‚ย ย  โ”œโ”€โ”€ 1_content.jsonl
        โ”‚ย ย  โ””โ”€โ”€ page.cmd
        โ”œโ”€โ”€ 5_about
        โ”‚ย ย  โ”œโ”€โ”€ 0_header.jsonl
        โ”‚ย ย  โ”œโ”€โ”€ 1_content.jsonl
        โ”‚ย ย  โ””โ”€โ”€ page.cmd
        โ”œโ”€โ”€ boot.cmd
        โ”œโ”€โ”€ config.json
        โ”œโ”€โ”€ offline.cmd
        โ””โ”€โ”€ online.cmd

โš™๏ธ Plate Setup (config.json)

openhasp-config-manager makes use of the config.json on your plate by extracting information like the screen orientation. It even allows you to deploy changes within the config.json file.

Note: Since the official API does not support uploading the full file, only settings which can also be set through the web ui on the plate itself are currently supported.

However, the official config.json file doesn't provide enough info for openhasp-config-manager to enable all of its features. To fix that we need to add a custom section to the file.

  1. Download your config.json via the openHASP web browser, see official docs.
  2. Append the openhasp_config_manager block, adjusting the values as needed.
{
  "openhasp_config_manager": {
    "device": {
      "ip": "192.168.5.134",
      "screen": {
        "width": 320,
        "height": 480
      }
    }
  },
  "wifi": {
    "ssid": "Turris IoT",
    ...
  }
  ... rest of config ...

๐Ÿง  Config File Preprocessing

openhasp-config-manager runs all configuration files through various preprocessors, which allow us to use features the original file formats do not support by themselves, like f.ex. templating.

๐Ÿ“ Multiline JSONL files

While the JSONL file format requires each object to be on a single line, openhasp-config-manager allows you to add as many line breaks as you wish. This makes it much easier to edit, since a config like this:

{
  "page": 0,
  "id": 31,
  "obj": "msgbox",
  "text": "%ip%",
  "auto_close": 5000
}

will be deployed like this:

{"page": 0, "id": 31, "obj": "msgbox", "text": "%ip%", "auto_close": 5000}

Comments

Neither JSON nor JSONL allows comments, but openhasp-config-manager does! You can mark comments by prefixing them with a double forward-slash:

// File description
{
  // Object Description
  "page": 0,
  "id": 31,
  // Property Description
  "obj": "msgbox",
  "text": "%ip%",
  "auto_close": 5000
}

๐Ÿช„ Templating

You can use Jinja2 templates inside all jsonl object values. To access the value of another object in a template, you can use the pXbY syntax established by openHASP, where X is the page of an object and Y is its id. openhasp-config-manager even tries to resolve templates that lead to other templates. Be careful not to create loops in this way though.

You can use the full functionality of Jinja2 like f.ex. math operations, function calls or type conversions.

{
  "page": 1,
  "id": 1,
  "x": 0,
  "y": 0,
  ...
}

  {
    "page": 1,
    "id": 2,
    "x": "{{ p1b1.x }}",
    "y": "{{ p1b1.y + 10 }}",
    ...
  }

๐Ÿ“ฆ Variables & Scoping

Besides accessing other objects, you can also define custom variables yourself, which can then be referenced inside of templates. Variables are defined using *.yaml files. If you decided to use a subfolder structure to organize your configuration files you can use these folders to also set the scope of variables. More specific variable definitions (longer path) will override less specific ones.

Global

Global variables can be specified by creating *.yaml files inside the root config folder (f.ex. openhasp-configs).

Example:

openhasp-configs/global.vars.yaml

about:
  page_title: "About"

To access this variable, use a Jinja2 template:

openhasp-configs/common/about_page.jsonl

{
  "page": 9,
  "id": 1,
  ...
  "title": "{{ about.page_title }}",
  ...
}
Device specific

Device specific variables can be specified by creating *.yaml files inside any of the sub-folders of a device folder.

Note

Device specific variables will override global variables, given the same name.

Example:

openhasp-configs/device/my_device/device.vars.yaml

page_title: "My Device"

openhasp-configs/device/my_device/some_folder/some_page.jsonl

{
  "page": 1,
  "id": 1,
  ...
  "title": "{{ page_title }}",
  ...
}

openhasp-configs/device/my_device/some_other_folder/some_page.jsonl

{
  "page": 2,
  "id": 1,
  ...
  "title": "{{ page_title }}",
  ...
}

Printing variables

If you are not sure what variables are accessible in a given path, you can use the vars command, which will give you a copy&paste ready output of all variables for a given directory:

> openhasp-config-manager vars -c openhasp-configs -p devices/touch_down_1/home
common.navbar.first_page: 1
common.navbar.last_page: 4
...
header.title: Home

๐ŸŽจ Theming

To specify default property values for an object type, simply define them as a variable under theme.obj.<obj-type>, where <obj-type> is the value of the obj property of the object.

The keys used must conform to the naming of the object properties as specified in OpenHasp, see: https://www.openhasp.com/latest/design/objects/

For example, to make the background color of all buttons red by default, define:

theme.yaml

theme:
  obj:
    btn:
      bg_color: "#FF0000"

in a global variable file named theme.yaml located at the root of your configurations directory openhasp-configs/theme.yaml.

Deployment

To deploy your configurations to the already connected openHASP devices, simply use the generate, upload or deploy commands of openhasp-config-manager.

Note openhasp-config-manager needs direct IP access as well as an enabled webservice on the plate to be able to deploy files to the device. To enable the webservice try: openhasp-config-manager cmd -d plate35 -C service -p "start http"

Run commands

While openhasp-config-manager is first and foremost a config management system, it also allows you to run commands on a device by issuing MQTT messages without the need to install a separate MQTT client first. Note that the MQTT server still needs to be running and also has to be reachable from your local machine for this to work.

For a list of possible commands to send to a device, take a look at the official documentation: https://openhasp.haswitchplate.com/latest/commands/

> openhasp-config-manager cmd -c ./openhasp-configs -d plate35 -C backlight -p "{\"state\":\"on\",\"brightness\":128}"

AppDaemon Integration Utilities

If you want to integrate your openHASP devices with AppDaemon, openhasp-config-manager contains some utilities to make this process easier.

Plate Controller

The OpenHaspController class provides a high-level interface to manage the state of your plate, send commands and listen to events. See: openhasp_config_manager/ad/README.md for more details and examples.

API Client

If you don't want to use all of the file-tree related features of openhasp-config-manager, but still want to interact with your openHASP devices using python and the official API, you can use the OpenHaspClient class to do so. It provides a simple interface to interact with a plate, send commands, listen to events and state updates.

See

to see how to use it.

FAQ

How do I see device logs?

Try the logs command (this does require network access to the device):

> openhasp-config-manager logs -d plate35

If that doesn't work, open a terminal and run the following command with the device connected via USB cable:

bash -c "screen -q -L -Logfile device.log /dev/ttyUSB0 115200 &> /dev/null; tail -F device.log; killall screen"

Output file name length must not exceed 30 characters

openHASP doesn't support subfolders. To keep your local project organized, the manager flattens your structure during upload (e.g., folder/page.jsonl becomes folder_page.jsonl). So f.ex. the file in the following structure:

openhasp-configs
โ””โ”€โ”€ devices
    โ””โ”€โ”€ touch_down_1
        โ””โ”€โ”€ 0_home
            โ””โ”€โ”€ 0_header.jsonl

would be uploaded to the touch_down_1 device with the name 0_home_0_header.jsonl.

To avoid the "Output file name length must not exceed 30 characters" error, make sure that the flattened file name (including the device folder prefix) does not exceed 30 characters.

Contributing

GitHub is for social coding: if you want to write code, I encourage contributions through pull requests from forks of this repository. Create GitHub tickets for bugs and new features and comment on the ones that you are interested in.

License

openhasp-config-manager is free software: you can redistribute it and/or modify
it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openhasp_config_manager-0.8.2.tar.gz (90.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

openhasp_config_manager-0.8.2-py3-none-any.whl (128.8 kB view details)

Uploaded Python 3

File details

Details for the file openhasp_config_manager-0.8.2.tar.gz.

File metadata

  • Download URL: openhasp_config_manager-0.8.2.tar.gz
  • Upload date:
  • Size: 90.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for openhasp_config_manager-0.8.2.tar.gz
Algorithm Hash digest
SHA256 1c42cc0cb6e889c4427f2e05ad9ecf62e1b6d5409df43b860c4bf575843a806b
MD5 f383b2e4e039361cea9d3f14054fd138
BLAKE2b-256 938929d6329b2b4f460d92f3756a5009e1bd43e3f1d03d6cacc0ceb00052bc26

See more details on using hashes here.

Provenance

The following attestation bundles were made for openhasp_config_manager-0.8.2.tar.gz:

Publisher: python_publish.yaml on markusressel/openhasp-config-manager

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file openhasp_config_manager-0.8.2-py3-none-any.whl.

File metadata

File hashes

Hashes for openhasp_config_manager-0.8.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d026683ee0de3ebb10eaea06f700c21d64ef84a81c5a6d199ef96b096f957bfb
MD5 1a05a80a6b1b51adfe17504bf3bdcda7
BLAKE2b-256 17f0cb94e1914493d3e8e369d039a33dd2c2529f8f12eba0283c1d4486c58cc3

See more details on using hashes here.

Provenance

The following attestation bundles were made for openhasp_config_manager-0.8.2-py3-none-any.whl:

Publisher: python_publish.yaml on markusressel/openhasp-config-manager

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page