Generate configuration files for OpenHASP (JSONL) and Home Assistant (YAML) from a single PHP configuration file.
Designed for use with the SenseCAP Indicator D1 (480x480px display) running openHASP firmware.
- PHP 7.4 or higher (CLI)
- OpenHASP device with firmware installed
- Home Assistant with OpenHASP integration
git clone https://github.com/yourusername/hasspanel.git
cd hasspanelCopy the example configuration and customize it:
cp config.example.php config.phpEdit config.php to define your device and entities:
<?php
require_once('icons.php');
require_once('util.php');
// Panel identification
$device = array(
'node' => 'your_panel_name', // OpenHASP device name
'banner' => 'Your Home Panel', // Header text displayed on panel
);
// Define switches (toggleable entities)
map_to_rows([
'icon' => '%0%',
'label' => '%1%',
'type' => 'switch',
'default' => '0',
'on_value' => 'On',
'off_value' => 'Off',
'entity' => '%2%',
], array(
[ 'lightbulb', 'Living Room', 'switch.living_room_light' ],
[ 'ceiling-light', 'Kitchen', 'light.kitchen' ],
));
// Define sensors (read-only text display)
map_to_rows([
'icon' => '%0%',
'label' => '%1%',
'type' => 'text',
'default' => 'n/a',
'entity' => '%2%',
], array(
[ 'thermometer', 'Temperature', 'sensor.indoor_temperature' ],
[ 'water-percent', 'Humidity', 'sensor.indoor_humidity' ],
));Generate the OpenHASP JSONL file (upload to your device):
php genhasp.php > pages.jsonlGenerate the Home Assistant YAML (add to your HA configuration):
php genhass.php > openhasp.yaml- Upload
pages.jsonlto your OpenHASP device via its web interface - Add the contents of
openhasp.yamlto your Home Assistant configuration - Restart Home Assistant
See icons.php for a full list of available icons. Common icons include:
| Icon Name | Use Case |
|---|---|
lightbulb |
General lights |
ceiling-light |
Ceiling fixtures |
outdoor-lamp |
Outdoor lighting |
thermometer |
Temperature sensors |
door-closed |
Door sensors |
garage-variant |
Garage doors |
fan |
Fan controls |
power-plug |
Smart plugs |
Interactive toggle for switch.* and light.* entities:
'type' => 'switch'Read-only display for sensors:
'type' => 'text',
'format' => '%s°F', // Optional format stringhasspanel/
├── config.php # Your panel configuration
├── config.example.php # Example configuration
├── common.php # Layout engine and object generation
├── genhasp.php # OpenHASP JSONL generator
├── genhass.php # Home Assistant YAML generator
├── icons.php # Icon name to Unicode mapping
├── util.php # Utility functions
└── README.md
MIT