Skip to content

Commands

Commands are not related to an object on the screen but can get or set global properties or invoke system commands on the device.

Commands can be issued via the Serial commandline, telnet commandline or MQTT.

For MQTT, use the hasp/<nodename>/command topic with payload <keyword> <parameter(s)>

jsonl~

accepted parameters: one or more json formatted lines

Create new objects or update the properties of an existing object. When updating an existing object the obj property is not required and will be ignored.

Each line in the jsonl payload defines one object and has to be in the json format. If the payload exceeds the MQTT buffer of 2 kB it will be cut off to fit, don't send too many lines in a single payload, you can always sends multiple jsonl commands.

Example:

1
jsonl {"obj":"btn","id":14,"x":120,"y":1,"w":30,"h":40,"text_font":"2","text":"Test","text_color":"gray","bg_opa":0,"border_width":0}

For more details see Pages and Objects.

json~

accepted parameters: json array of strings

Use the json command to send multiple commands as an array of strings in one payload.

Example:

1
json ['page 3','backlight {"state":"OFF","brightness":100}','idle off']

This command will change to page 3, turn the backlight on at ~40% brightness and reset the idle timer.

page~

accepted parameters: [1-12], prev, next or back

Switches the display to show the objects from a different page and return the page number in state/page.

Calling the page command without a parameter will return the value of the current page in state/page.

clearpage~

accepted parameters: [0-12] or all

Deletes all objects on a given page. If no page number is specified, it clears the current page. Use clearpage all to clear all objects on all pages.

To delete individual objects, you can issue the pXbY.delete command.

dim~

Deprecated, use backlight instead

light~

Deprecated, use backlight instead

backlight ~

accepted json keys:

  • state: on/off, true/false, 0/1, yes/no
  • brightness: 1..255

Example

backlight {"state":"on","brightness":128} sets the display to half the brightness.

Instead of a json payload, you can use a simple payload. To change the state, use either on/off, true/false, 0, yes/no. A simple integer payload of 1..255 will adjust the brightness.

Example

backlight off
backlight 200 sets the display brightness to ~80%.

moodlight~

accepted json keys:

  • state: on/off, true/false, 0/1, yes/no
  • brightness: 1..255
  • color or
  • r, g, b: 0..255

An RGB moodlight can be controlled by configuring 3 GPIO pins as type Mood Red, Mood Green and Mood blue. These leds can then be controlled together using the moodlight command.

1
2
3
4
moodlight {"state":"off","color":"green"}
moodlight {"state":true,"color":"#ff00e7"}
moodlight {"color":12345}
moodlight {"state":"on","r":255,"g":0,"b":255}
  • The state key accepts boolean values to turn the moodlight on or off
  • The brightness key can be set between 1 and 255 to dim the moodlight
  • The color key accepts color values to set the RGB channels at once
  • Individual r, g and b keys can also be used to set each channel seperately

Calling the moodlight command without parameters (or sending an empty payload to the hasp/<nodename>/command/moodlight topic) returns the current state:

1
"state/moodlight" {"state":"ON","brightness":255,"color":"#ff0000","r":255,"g":0,"b":0}

The color is returned as a hexadecimal value and as individual RGB channels.

idle ~

accepted parameters: off

Clears the idle state of the device and publishes a state/idle = OFF status message.

It resets the idle counter as if a touch event occurred on the device. This is helpful e.g. when you want to wake up the display when an external event has occurred, like a PIR motion sensor.

Calling the idle command without a parameter will return the current idle state short, long or off in the state/idle topic.

wakeup~

Deprecated, use idle off instead

output[x] ~

where [x] is number of the gpio pin (0-39)

accepted json keys:

  • state: on/off, true/false, 0/1, yes/no
  • val: 0..255

Changes the state GPIO pin to on or off. If the pin is configured as a LED or Serial Dimmer then the val key will control the brightness.

Bug

Update to the latest 0.6-dev release, otherwise the relay won't switch without also setting the val property.

Note

If the GPIO is assigned to a group then objects and other GPIOs that share the same groupid will change state accordingly.

input[x] ~

where [x] is number of the gpio pin (0-39)

read-only

Returns a JSON object containing the current state of the input, either on or off

1
input4 => {"state":"on"}

System Commands~

calibrate

Start on-screen touch calibration.

You need to issue a soft reboot command to save the new calibration settings. If you do a hard reset of the device, the calibration settings will be lost.

screenshot

Saves a picture of the current screen to the flash filesystem. You can retrieve it via http://<ip-address>/screenshot.bmp. This can be handy for bug reporting or documentation.

The previous screenshot is overwritten.

statusupdate

Reports the status of the MCU. The response will be posted to the state topic. For example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
    "hasp/<platename>/state/statusupdate" => {
        "node":"plate35",
        "idle":"short",
        "version":"0.5.1",
        "uptime":1813,
        "ssid":"network",
        "rssi":-63,
        "ip":"192.168.4.2",
        "heapFree":125820,
        "heapFrag":35,
        "core":"v3.3.5-1-g85c43024c",
        "canUpdate":"false",
        "page":1,
        "numPages":12,
        "tftDriver":"ST7789",
        "tftWidth":240,
        "tftHeight":320
    }

reboot or restart

Saves any changes in the configuration file and reboots the device.

update

accepted parameters: [url]

Update the firmware from the url provided. Reboots when update was successful.

factoryreset

Clear the filesystem and EEPROM and reboot the device in its initial state.

Warning

There is no confirmation prompt nor an undo function!

Configuration Settings~

Wi-FI~

ssid

Set network name of the access point to connect to.

pass

Set the optional password for the access point to connect to.

MQTT~

nodename

Set the nodename of the device and mqtt topic for the node to hasp/<nodename>/

mqtthost

Set the IP address or nodename of the mqtt broker.

mqttport

Set the port of the mqtt broker.

mqttuser

Set the optional username for the mqtt broker.

mqttpass

Set the optional password for the mqtt broker.

config/submodule~

You can get or set the configuration of an openHASP submodule in json format. To get the configuration, use the command config/<submodule>. The result will be published to hasp/<nodename>/state/config. Passwords will be omitted from the result.

1
2
3
4
5
6
7
8
config/wifi
config/mqtt
config/http
config/mdns
config/hasp {"startdim":255}
config/gui
config/debug {"tele":300}
config/gpio

To update the configuration simply issue the same command config/<submodule> with updated json payload.


Last update: 2022-06-04
Back to top